source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | prograils/lit | https://github.com/prograils/lit | app/models/lit/localization_key.rb | Ruby | mit | 300 | master | 2,995 | module Lit
class LocalizationKey < Lit::Base
attr_accessor :interpolated_key
## SCOPES
scope :completed, -> { where(is_completed: true) }
scope :not_completed, -> { where(is_completed: false) }
scope :starred, -> { where(is_starred: true) }
scope :ordered, -> { order(localization_key: :asc) }... |
github | prograils/lit | https://github.com/prograils/lit | app/models/lit/localization.rb | Ruby | mit | 300 | master | 3,209 | module Lit
class Localization < Lit::Base
serialize :translated_value
serialize :default_value
## SCOPES
scope :changed, -> { where is_changed: true }
scope :not_changed, -> { where is_changed: false }
# @HACK: dirty, find a way to round date to full second
scope :after, lambda { |dt| wh... |
github | prograils/lit | https://github.com/prograils/lit | app/models/lit/incomming_localization.rb | Ruby | mit | 300 | master | 3,042 | module Lit
class IncommingLocalization < ActiveRecord::Base
serialize :translated_value
## ASSOCIATIONS
belongs_to :locale
belongs_to :localization_key
belongs_to :localization
belongs_to :source
## ACCESSORS
attr_accessible unless defined?(::ActionController::StrongParameters)
... |
github | prograils/lit | https://github.com/prograils/lit | app/helpers/lit/localizations_helper.rb | Ruby | mit | 300 | master | 732 | module Lit
module LocalizationsHelper
def draw_icon(icon, opts = {})
raw "<i class=\"fa fa-#{icon} #{opts[:class]}\" " \
"title=\"#{opts[:title]}\" ></i>"
end
def ejs(val)
escape_javascript val.to_s
end
def locale_flag locale
locale = locale.to_s.upcase[0,2]
loc... |
github | prograils/lit | https://github.com/prograils/lit | app/helpers/lit/frontend_helper.rb | Ruby | mit | 300 | master | 2,872 | module Lit::FrontendHelper
include ActionView::Helpers::TranslationHelper
module TranslationKeyWrapper
def translate(key, options = {})
count = options[:count]
options = options.with_indifferent_access
key = scope_key_by_partial(key)
key = pluralized_key(key, count) if count
cont... |
github | prograils/lit | https://github.com/prograils/lit | app/services/remote_interactor_service.rb | Ruby | mit | 300 | master | 1,261 | class RemoteInteractorService
def initialize(source)
@source = source
end
def send_request(path, query_values = {})
uri = initialize_uri(path, query_values)
req = initialize_request(uri)
connection = initialize_connection(uri)
perform_request(connection, req)
rescue => e
return unless d... |
github | prograils/lit | https://github.com/prograils/lit | app/services/synchronize_source_service.rb | Ruby | mit | 300 | master | 1,736 | class SynchronizeSourceService
def initialize(source, auto_accept = false)
@source = source
@auto_accept = auto_accept
end
def execute
synchronize_localizations
update_timestamps
end
private
def synchronize_localizations
after_date = @source.last_updated_at&.to_fs(:db)
result = in... |
github | prograils/lit | https://github.com/prograils/lit | app/queries/localization_key_search_query.rb | Ruby | mit | 300 | master | 1,945 | class LocalizationKeySearchQuery
def initialize(scope, params = {})
@scope = scope
@params = params.to_h
.reverse_merge(@scope.default_search_options)
.with_indifferent_access
end
def perform
order_data
search_key_prefix
search_key
search_completed
... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/localization_keys_controller.rb | Ruby | mit | 300 | master | 4,675 | module Lit
class LocalizationKeysController < ::Lit::ApplicationController
before_action :find_localization_scope, except: %i[destroy find_localization]
before_action :find_localization_key, only: %i[star destroy change_completed restore_deleted]
def index
get_localization_keys
end
def not... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/locales_controller.rb | Ruby | mit | 300 | master | 649 | require_dependency 'lit/application_controller'
module Lit
class LocalesController < ApplicationController
def index
@locales = Locale.ordered
respond_to do |format|
format.html # index.html.erb
format.json { render json: @locales }
end
end
def hide
@locale = Loc... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/localizations_controller.rb | Ruby | mit | 300 | master | 2,032 | module Lit
class LocalizationsController < ::Lit::ApplicationController
before_action :find_localization_key
before_action :find_localization
def show
render json: { value: @localization.translation }
end
def edit
@localization.translated_value = @localization.translation
respo... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/incomming_localizations_controller.rb | Ruby | mit | 300 | master | 1,389 | require_dependency 'lit/application_controller'
module Lit
class IncommingLocalizationsController < ApplicationController
before_action :find_source_and_incomming_localizations
before_action :find_icomming_localization, only: %i[accept destroy]
def index; end
def accept
@incomming_localizatio... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/request_keys_store.rb | Ruby | mit | 300 | master | 200 | module Lit::RequestKeysStore
extend ::ActiveSupport::Concern
included { before_action :init_request_keys }
private
def init_request_keys
Thread.current[:lit_request_keys] = {}
end
end |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/sources_controller.rb | Ruby | mit | 300 | master | 1,598 | require_dependency 'lit/application_controller'
module Lit
class SourcesController < ApplicationController
before_action :find_source, except: %i[index new create]
def index
@sources = Source.all
end
def show; end
def new
@source = Source.new
end
def edit; end
def sync... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/request_info_store.rb | Ruby | mit | 300 | master | 221 | module Lit::RequestInfoStore
extend ::ActiveSupport::Concern
included { before_action :store_request_path }
private
def store_request_path
Thread.current[:lit_current_request_path] = request&.path
end
end |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/application_controller.rb | Ruby | mit | 300 | master | 1,026 | module Lit
class ApplicationController < ActionController::Base
unless respond_to?(:before_action)
alias before_action before_filter
alias after_action after_filter
end
before_action :authenticate
before_action :stop_hits_counter
after_action :restore_hits_counter
private
def... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/cloud_translations_controller.rb | Ruby | mit | 300 | master | 993 | # frozen_string_literal: true
module Lit
class CloudTranslationsController < ::Lit::ApplicationController
def show
params.delete(:from) if params[:from] == 'auto'
@target_localization = Localization.find(params[:localization_id])
@localization_key = @target_localization.localization_key
i... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/api/v1/localization_keys_controller.rb | Ruby | mit | 300 | master | 576 | require_dependency 'lit/api/v1/base_lit_controller'
module Lit
class Api::V1::LocalizationKeysController < Api::V1::BaseLitController
def index
@localization_keys = fetch_localization_keys
render json: @localization_keys.as_json(
root: false, only: %i[id localization_key is_deleted]
).t... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/api/v1/localizations_controller.rb | Ruby | mit | 300 | master | 919 | module Lit
class Api::V1::LocalizationsController < Api::V1::BaseLitController
def index
@localizations = fetch_localizations
render json:
@localizations.as_json(
root: false,
only: %i[id localization_key_id locale_id],
methods: %i[valu... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/api/v1/base_lit_controller.rb | Ruby | mit | 300 | master | 369 | module Lit
module Api
module V1
class BaseLitController < ActionController::Base
layout nil
before_action :authenticate_requests!
private
def authenticate_requests!
authenticate_or_request_with_http_token do |token, _options|
Lit.api_key == token
... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/api/v1/locales_controller.rb | Ruby | mit | 300 | master | 322 | require_dependency 'lit/api/v1/base_lit_controller'
module Lit
module Api
module V1
class LocalesController < Api::V1::BaseLitController
def index
@locales = Locale.all
render json: @locales.as_json(root: false, only: %i[id locale]).to_json
end
end
end
end
en... |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/concerns/request_keys_store.rb | Ruby | mit | 300 | master | 200 | module Lit::Concerns::RequestKeysStore
extend ActiveSupport::Concern
included do
Rails.logger.info 'DEPRECATED: Use include Lit::RequestKeysStore'
include Lit::RequestKeysStore
end
end |
github | prograils/lit | https://github.com/prograils/lit | app/controllers/lit/concerns/request_info_store.rb | Ruby | mit | 300 | master | 200 | module Lit::Concerns::RequestInfoStore
extend ActiveSupport::Concern
included do
Rails.logger.info 'DEPRECATED: Use include Lit::RequestInfoStore'
include Lit::RequestInfoStore
end
end |
github | prograils/lit | https://github.com/prograils/lit | test/test_helper.rb | Ruby | mit | 300 | master | 3,501 | # Configure Rails Environment
ENV['RAILS_ENV'] = 'test'
# We get a whole bunch of method redefinition warnings, mostly coming
# from Devise - e.g. when routes are reloaded in controller tests.
# That's not ideal but we don't need those. (Funny enough, default `$VERBOSE`
# when using `rails test` instead of `rake` is `... |
github | prograils/lit | https://github.com/prograils/lit | test/lib/raw_import_task_test.rb | Ruby | mit | 300 | master | 1,936 | require 'test_helper'
require 'rake'
class RawImportTaskTest < ActiveSupport::TestCase
def setup
path = Lit::Engine.root.join('test', 'fixtures', 'lit', 'files', 'import.yml.raw')
@locales = Rails.root.join('config', 'locales', 'import.yml')
FileUtils.cp path, @locales
Rake::Task.clear
Lit::Engin... |
github | prograils/lit | https://github.com/prograils/lit | test/functional/welcome_controller_test.rb | Ruby | mit | 300 | master | 1,321 | require 'test_helper'
class WelcomeControllerTest < ActionController::TestCase
def setup
Lit::Localization.delete_all
Lit::LocalizationKey.delete_all
Lit::LocalizationVersion.delete_all
Lit.loader = nil
Lit.ignore_yaml_on_startup = false
Lit.init
end
def teardown
Lit.ignore_yaml_on_s... |
github | prograils/lit | https://github.com/prograils/lit | test/functional/lit/locales_controller_test.rb | Ruby | mit | 300 | master | 1,147 | require 'test_helper'
module Lit
class LocalesControllerTest < ActionController::TestCase
setup do
@routes = Lit::Engine.routes
Lit.authentication_function = nil
@locale = Locale.first_or_create(locale: 'en')
end
test 'should restore hits counter status to true' do
Lit.hits_coun... |
github | prograils/lit | https://github.com/prograils/lit | test/functional/lit/incomming_localizations_controller_test.rb | Ruby | mit | 300 | master | 740 | require 'test_helper'
module Lit
class IncommingLocalizationsControllerTest < ActionController::TestCase
fixtures 'lit/sources'
set_fixture_class lit_sources: Lit::Source
def setup
Lit.authentication_function = nil
@routes = Lit::Engine.routes
stub_request(:get, 'http://testhost.com/lit... |
github | prograils/lit | https://github.com/prograils/lit | test/functional/lit/sources_controller_test.rb | Ruby | mit | 300 | master | 2,250 | require 'test_helper'
module Lit
class SourcesControllerTest < ActionController::TestCase
fixtures 'lit/sources'
setup do
Lit.authentication_function = nil
@routes = Lit::Engine.routes
stub_request(:get, 'http://testhost.com/lit/api/v1/last_change.json').
to_return(body: { last_cha... |
github | prograils/lit | https://github.com/prograils/lit | test/functional/lit/localizations_controller_test.rb | Ruby | mit | 300 | master | 3,814 | require 'test_helper'
module Lit
class LocalizationsControllerTest < ActionController::TestCase
fixtures :all
setup do
Lit.loader = nil
Lit.authentication_function = nil
Lit.init
@routes = Lit::Engine.routes
@localization = lit_localizations(:array)
end
# GET /localiza... |
github | prograils/lit | https://github.com/prograils/lit | test/functional/lit/localization_keys_controller_test.rb | Ruby | mit | 300 | master | 3,763 | require 'test_helper'
module Lit
class LocalizationKeysControllerTest < ActionController::TestCase
fixtures :all
setup do
Lit.authentication_function = nil
I18n.locale = :en
@routes = Lit::Engine.routes
@localization_key = lit_localization_keys(:hello_world)
end
# GET /local... |
github | prograils/lit | https://github.com/prograils/lit | test/functional/lit/cloud_translations_controller_test.rb | Ruby | mit | 300 | master | 3,422 | # frozen_string_literal: true
require 'test_helper'
require 'minitest/mock'
module Lit
class CloudTranslationsControllerTest < ActionController::TestCase
fixtures 'lit/localizations', 'lit/locales', 'lit/localization_keys'
setup do
@routes = Lit::Engine.routes
Lit.stubs(:authentication_function... |
github | prograils/lit | https://github.com/prograils/lit | test/functional/lit/dashboard_controller_test.rb | Ruby | mit | 300 | master | 484 | require 'test_helper'
module Lit
class DashboardControllerTest < ActionController::TestCase
setup do
@routes = Lit::Engine.routes
end
test 'should require auth / should redirect' do
Lit.authentication_function = :authenticate_admin!
get :index
assert_response 302
end
tes... |
github | prograils/lit | https://github.com/prograils/lit | test/functional/lit/api/v1/localizations_controller_test.rb | Ruby | mit | 300 | master | 1,622 | require 'test_helper'
module Lit
class Api::V1::LocalizationsControllerTest < ActionController::TestCase
def setup
Lit::Localization.delete_all
Lit::LocalizationKey.delete_all
Lit::LocalizationVersion.delete_all
Lit.loader = nil
Lit.api_enabled = true
Lit.api_key = 'test'
... |
github | prograils/lit | https://github.com/prograils/lit | test/functional/lit/api/v1/locales_controller_test.rb | Ruby | mit | 300 | master | 1,441 | require 'test_helper'
module Lit
class Api::V1::LocalesControllerTest < ActionController::TestCase
def setup
Lit.api_enabled = true
Lit.api_key = 'test'
@routes = Lit::Engine.routes
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials('test')
... |
github | prograils/lit | https://github.com/prograils/lit | test/functional/lit/api/v1/localization_keys_controller_test.rb | Ruby | mit | 300 | master | 1,343 | require 'test_helper'
module Lit
class Api::V1::LocalizationKeysControllerTest < ActionController::TestCase
def setup
Lit::Localization.delete_all
Lit::LocalizationKey.delete_all
Lit::LocalizationVersion.delete_all
Lit.loader = nil
Lit.api_enabled = true
Lit.api_key = 'test'
... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/app/models/admin.rb | Ruby | mit | 300 | master | 500 | class Admin < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
unless defined?(::Action... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/app/controllers/projects_controller.rb | Ruby | mit | 300 | master | 2,096 | class ProjectsController < ApplicationController
# GET /projects
# GET /projects.json
def index
@projects = Project.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @projects }
end
end
# GET /projects/1
# GET /projects/1.json
def show
@projec... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/app/controllers/application_controller.rb | Ruby | mit | 300 | master | 308 | class ApplicationController < ActionController::Base
protect_from_forgery
unless respond_to?(:before_action)
alias_method :before_action, :before_filter
end
helper Lit::FrontendHelper
before_action :set_locale
def set_locale
I18n.locale = params[:locale] if params[:locale]
end
end |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/config/application.rb | Ruby | mit | 300 | master | 2,221 | require_relative 'boot'
require 'rails/all'
Bundler.require(*Rails.groups)
require 'lit'
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/config/routes.rb | Ruby | mit | 300 | master | 296 | Rails.application.routes.draw do
mount Lit::Engine => '/lit'
devise_for :admins
scope '(:locale)', locale: /en|pl|de/ do
resources :projects
get 'welcome' => 'welcome#index', :as => :welcome
get 'catan' => 'welcome#catan', :as => :catan
end
root to: 'welcome#index'
end |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/config/initializers/i18n.rb | Ruby | mit | 300 | master | 1,042 | if ::Rails::VERSION::MAJOR == 3 ||
(::Rails::VERSION::MAJOR == 4 && ::Rails::VERSION::MINOR == 0)
require 'i18n'
# Override exception handler to more carefully html-escape missing-key results.
class HtmlSafeI18nExceptionHandler
Missing = I18n.const_defined?(:MissingTranslation) ? I18n::MissingTranslation... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/config/initializers/devise.rb | Ruby | mit | 300 | master | 11,333 | # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use yo... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/config/initializers/secret_token.rb | Ruby | mit | 300 | master | 500 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/config/initializers/lit.rb | Ruby | mit | 300 | master | 360 | Lit.authentication_function = :authenticate_admin!
Lit.authentication_verification = :admin_signed_in?
Lit.key_value_engine = ENV['LIT_STORAGE'] || 'redis'
Lit.humanize_key = false
Lit.ignore_yaml_on_startup = true
Lit.api_enabled = true
Lit.api_key = 'ala'
Lit.all_translations_are_html_safe = true
Rails.application.co... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/config/initializers/postgres_10_pg_sequence_fix.rb | Ruby | mit | 300 | master | 1,630 | # In PostgreSQL 10 each sequence does not know `increment_by` or `min_value`
# This fix is already in Rails master, this is just monkey patch "to make it
# work" in Rails 4.2
# More details here: https://github.com/rails/rails/pull/28864
# Original issue: https://github.com/rails/rails/issues/28780
module ActiveRecord
... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/config/environments/test.rb | Ruby | mit | 300 | master | 1,871 | Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suit... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/config/environments/development.rb | Ruby | mit | 300 | master | 1,069 | Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/db/schema.rb | Ruby | mit | 300 | master | 4,534 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
#... |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/db/migrate/20121223141035_create_projects.rb | Ruby | mit | 300 | master | 262 | class CreateProjects < Rails::VERSION::MAJOR >= 5 ?
ActiveRecord::Migration[4.2] :
ActiveRecord::Migration
def change
create_table :projects do |t|
t.string :name
t.timestamps
end
end
end |
github | prograils/lit | https://github.com/prograils/lit | test/dummy/db/migrate/20121106204557_devise_create_admins.rb | Ruby | mit | 300 | master | 1,576 | class DeviseCreateAdmins < Rails::VERSION::MAJOR >= 5 ?
ActiveRecord::Migration[4.2] :
ActiveRecord::Migration
def change
create_table(:admins) do |t|
## Database authenticatable
t.string :email, null: false, default: ''
t.stri... |
github | prograils/lit | https://github.com/prograils/lit | test/services/lit/synchronize_source_service_test.rb | Ruby | mit | 300 | master | 1,780 | require 'test_helper'
# Applicable only in an ActiveJob-enabled environment (Rails 4.2+ or 4.0/4.1
# with additional gem)
if defined?(ActiveJob)
module Lit
class SynchronizeSourceServiceTest < ActiveSupport::TestCase
fixtures :all
def setup
after = 3.hours.ago
after_str = after.strft... |
github | prograils/lit | https://github.com/prograils/lit | test/integration/lit/locales_test.rb | Ruby | mit | 300 | master | 718 | # encoding: utf-8
require 'test_helper'
class LocalesTest < ActionDispatch::IntegrationTest
def setup
Lit.ignore_yaml_on_startup = false
Lit.init
end
def teardown
Lit.ignore_yaml_on_startup = nil
end
test 'should allow hiding locale' do
Lit.authentication_function = nil
# visit('/pl/wel... |
github | prograils/lit | https://github.com/prograils/lit | test/integration/lit/backend_test.rb | Ruby | mit | 300 | master | 705 | # encoding: utf-8
require 'test_helper'
class BackendTest < ActionDispatch::IntegrationTest
def setup
@old_locale = I18n.locale
I18n.locale = :pl
end
def teardown
I18n.locale = @old_locale
end
test 'when generating locale while listing localizations it should copy default_value' do
Lit.auth... |
github | prograils/lit | https://github.com/prograils/lit | test/integration/lit/welcome_test.rb | Ruby | mit | 300 | master | 3,717 | # encoding: utf-8
require 'test_helper'
class WelcomeTest < ActionDispatch::IntegrationTest
def setup
@old_humanize_key = Lit.humanize_key
@old_fallbacks = Rails.application.config.i18n.fallbacks
Lit.ignore_yaml_on_startup = false
Lit.init
end
def teardown
Lit.humanize_key = @old_humanize_ke... |
github | prograils/lit | https://github.com/prograils/lit | test/integration/lit/projects_test.rb | Ruby | mit | 300 | master | 1,595 | # encoding: utf-8
require 'test_helper'
class ProjectsTest < ActionDispatch::IntegrationTest
setup do
@old = Lit.humanize_key
end
teardown do
Lit.humanize_key = @old
end
test 'should display translated project name' do
Lit.humanize_key = true
visit('/en/projects/new')
locale = Lit::Local... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/export_test.rb | Ruby | mit | 300 | master | 3,330 | # frozen_string_literal: true
require 'test_helper'
class ExportTest < ActiveSupport::TestCase
fixtures :all
def setup
@old_hits_counter_enabled = Lit.init.cache.instance_variable_get(:@hits_counter)
Lit.hits_counter_enabled = true
I18n.backend.reset_available_locales_cache
Lit.init.cache.instanc... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/import_test.rb | Ruby | mit | 300 | master | 8,159 | # frozen_string_literal: true
require 'test_helper'
class ImportTest < ActiveSupport::TestCase
fixtures :all
def setup
I18n.backend.reset_available_locales_cache
end
# actually the formats we consider are CSV and YAML, but let's also ensure
# a tab-separated (TSV) file as opposed to comma-separated (C... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/i18n_backend_test.rb | Ruby | mit | 300 | master | 2,924 | require 'test_helper'
class I18nBackendTest < ActiveSupport::TestCase
fixtures 'lit/locales'
class Backend < Lit::I18nBackend
end
def setup
@old_backend = I18n.backend
@old_locale = I18n.locale
@old_humanize_key = Lit.humanize_key
@old_available_locales = ::Rails.configuration.i18n.available_l... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/lit_behaviour_test.rb | Ruby | mit | 300 | master | 10,977 | require 'test_helper'
class LitBehaviourTest < ActiveSupport::TestCase
class Backend < Lit::I18nBackend
end
def setup
Lit::Localization.delete_all
Lit::LocalizationKey.delete_all
Lit::LocalizationVersion.delete_all
@old_load_path = I18n.load_path
@old_humanize_key = Lit.humanize_key
@ol... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/pure_i18n_compatibility_test.rb | Ruby | mit | 300 | master | 1,159 | require 'test_helper'
class PureI18nCompatibilityTest < ActiveSupport::TestCase
class Backend < Lit::I18nBackend
include I18n::Backend::Pluralization
end
def setup
Lit::Localization.delete_all
Lit::LocalizationKey.delete_all
Lit::LocalizationVersion.delete_all
@old_load_path = I18n.load_pat... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/helpers/lit/sources_helper_test.rb | Ruby | mit | 300 | master | 471 | require 'test_helper'
class SourcesHelperTest < ActionView::TestCase
include Lit::SourcesHelper
def setup
@source = Lit::Source.new
end
test 'returns "loaded" when source sync is complete' do
@source.sync_complete = true
assert_equal source_loading_class(@source), 'loaded'
end
test 'return... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/lit/localization_key_test.rb | Ruby | mit | 300 | master | 2,353 | require 'test_helper'
module Lit
class LocalizationKeyTest < ActiveSupport::TestCase
fixtures 'lit/localization_keys'
setup do
@lk = Lit::LocalizationKey.create(localization_key: 'testing')
@locale_en = Lit::Locale.create(locale: :en)
@locale_pl = Lit::Locale.create(locale: :pl)
@loc... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/lit/incomming_localization_test.rb | Ruby | mit | 300 | master | 2,678 | require 'test_helper'
module Lit
class IncommingLocalizationTest < ActiveSupport::TestCase
def setup
DatabaseCleaner.clean_with :truncation
stub_request(:get, 'http://testhost.com/lit/api/v1/last_change.json').to_return(
body: { last_change: 1.hour.ago.to_fs(:db) }.to_json,
)
@sou... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/lit/locale_test.rb | Ruby | mit | 300 | master | 265 | require 'test_helper'
module Lit
class LocaleTest < ActiveSupport::TestCase
fixtures 'lit/locales'
test 'uniqueness checking' do
l = lit_locales(:pl)
locale = Lit::Locale.new(locale: l.locale)
assert (!locale.valid?)
end
end
end |
github | prograils/lit | https://github.com/prograils/lit | test/unit/lit/localization_test.rb | Ruby | mit | 300 | master | 2,178 | require 'test_helper'
module Lit
class LocalizationTest < ActiveSupport::TestCase
def setup
Lit::Localization.delete_all
Lit::LocalizationKey.delete_all
Lit::LocalizationVersion.delete_all
Lit.loader = nil
Lit.ignore_yaml_on_startup = false
Lit.init
I18n.locale = :en
... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/lit/source_test.rb | Ruby | mit | 300 | master | 1,666 | require 'test_helper'
module Lit
class SourceTest < ActiveSupport::TestCase
fixtures 'lit/sources'
def setup
stub_request(:get, 'http://testhost.com/lit/api/v1/last_change.json').
to_return(body: { last_change: 1.hour.ago.to_fs(:db) }.to_json)
stub_request(:get, 'http://testhost.nope/li... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/lit/services/localization_keys_to_hash_service_test.rb | Ruby | mit | 300 | master | 657 | require 'test_helper'
module Lit
module Services
class LocalizationKeysToHashServiceTest < ActiveSupport::TestCase
test 'accepts flat hash of keys/translations and forms a tree' do
flat_hash = { 'en.js.layouts.back' => 'Back', 'en.js.layouts.home' => 'Home', 'en.js.common.new' => 'New' }
re... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/lit/cloud_translation/providers/google_test.rb | Ruby | mit | 300 | master | 3,072 | # frozen_string_literal: true
require 'test_helper'
require 'lit/cloud_translation/providers/google'
require 'minitest/mock'
require_relative 'examples'
describe Lit::CloudTranslation::Providers::Google, vcr: { record: :none } do
before do
# comment this stubbing block out, provide a .json keyfile and point to... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/lit/cloud_translation/providers/examples.rb | Ruby | mit | 300 | master | 1,851 | # frozen_string_literal: true
def cloud_provider_examples(described_klass)
let(:text) { 'The quick brown fox jumps over the lazy dog.' }
let(:from) { 'en' }
let(:to) { 'pl' }
describe 'when only :to language is given' do
subject do
described_klass.translate(text: text, to: to)
end
describe ... |
github | prograils/lit | https://github.com/prograils/lit | test/unit/lit/cloud_translation/providers/yandex_test.rb | Ruby | mit | 300 | master | 976 | # frozen_string_literal: true
require 'test_helper'
require 'lit/cloud_translation/providers/yandex'
require 'minitest/mock'
require_relative 'examples'
describe Lit::CloudTranslation::Providers::Yandex,
vcr: {
match_requests_on: [:method,
VCR.request_matchers.uri_w... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit.rb | Ruby | mit | 300 | master | 2,994 | require 'lit/engine'
require 'lit/loader'
require 'lit/adapters'
module Lit
mattr_accessor :authentication_function
mattr_accessor :authentication_verification
mattr_accessor :key_value_engine
mattr_accessor :redis_url
mattr_accessor :storage_options
mattr_accessor :humanize_key
mattr_accessor :humanize_... |
github | prograils/lit | https://github.com/prograils/lit | lib/generators/lit/install_generator.rb | Ruby | mit | 300 | master | 1,860 | require 'rails/generators'
module Lit
module Generators
class InstallGenerator < ::Rails::Generators::Base
class_option 'key-value-engine', type: :string
class_option 'authentication-function', type: :string
class_option 'no-migrate', type: :boolean
source_root File.expand_path('../instal... |
github | prograils/lit | https://github.com/prograils/lit | lib/tasks/lit_tasks.rake | Ruby | mit | 300 | master | 3,447 | namespace :lit do
desc 'Exports translated strings from lit to config/locales/lit.yml file.'
task export: :environment do
locale_keys = ENV['LOCALES'].to_s.split(',') || []
export_format = ENV['FORMAT'].presence&.downcase&.to_sym || :yaml
include_hits_count = ENV['INCLUDE_HITS_COUNT'].present?
path ... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/loader.rb | Ruby | mit | 300 | master | 442 | require 'logger'
require 'lit/i18n_backend'
require 'lit/cache'
require 'lit/export'
require 'lit/import'
require 'lit/cloud_translation'
module Lit
class Loader
attr_accessor :cache
attr_accessor :logger
def initialize
self.logger ||= Logger.new($stdout)
self.logger.info 'initializing Lit' u... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/railtie.rb | Ruby | mit | 300 | master | 303 | module Lit
class Railtie < ::Rails::Railtie
initializer :lit_middleware do |app|
app.config.middleware.insert_after ActionDispatch::RequestId, Lit::Middleware
ActiveSupport::Reloader.to_complete do
Thread.current[:localization_cache_valid] = false
end
end
end
end |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/cache.rb | Ruby | mit | 300 | master | 13,643 | module I18n
class << self
@@cache_store = nil
def cache_store
@@cache_store || I18n.backend.cache
end
def cache_store=(store)
@@cache_store = store
end
def perform_caching?
!cache_store.nil?
end
end
end
module Lit
class Cache
@@last_update = nil
@@localiza... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/rails.rb | Ruby | mit | 300 | master | 261 | require 'logger'
require 'lit/i18n_backend'
require 'lit/cache'
module Lit
module Rails
def self.initialize
Lit.init
end
end
end
if defined?(Rails::Railtie)
require 'lit/middleware'
require 'lit/railtie'
else
Lit::Rails.initialize
end |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/version.rb | Ruby | mit | 300 | master | 240 | # frozen_string_literal: true
module Lit
module_function
def version
Gem::Version.new Version::STRING
end
module Version
MAJOR = 1
MINOR = 1
TINY = 6
STRING = [MAJOR, MINOR, TINY].compact.join('.')
end
end |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/engine.rb | Ruby | mit | 300 | master | 951 | module Lit
class Engine < ::Rails::Engine
require 'jquery-rails'
config.autoload_paths += %W[#{Lit::Engine.root}/app/controllers/lit/concerns]
paths.add 'lib'
isolate_namespace Lit
initializer 'lit.assets.precompile' do |app|
app.config.assets.precompile += %w[lit/application.css lit/app... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/i18n_backend.rb | Ruby | mit | 300 | master | 8,586 | require 'i18n'
require 'lit/services/humanize_service'
module Lit
class I18nBackend
include I18n::Backend::Simple::Implementation
include I18n::Backend::Pluralization
attr_reader :cache
def initialize(cache)
@cache = cache
@available_locales_cache = nil
@translations = {}
re... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/import.rb | Ruby | mit | 300 | master | 6,195 | require 'csv'
module Lit
class Import
class << self
def call(**kwargs)
new(**kwargs).perform
end
end
attr_reader :input, :locale_keys, :format, :skip_nil
def initialize(input:, format:, locale_keys: [], skip_nil: true, dry_run: false, raw: false)
raise ArgumentError, 'form... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/middleware.rb | Ruby | mit | 300 | master | 715 | require 'rack/body_proxy'
# A middleware that ensures the lit thread value is cleared after
# the last part of the body is rendered. This is useful when
# using streaming.j
#
# Uses Rack::BodyProxy, adapted from Rack::Lock's usage of the
# same pattern.
#
module Lit
class Middleware
def initialize(app)
@a... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/export.rb | Ruby | mit | 300 | master | 2,779 | require 'csv'
require 'lit/services/localization_keys_to_hash_service'
module Lit
class Export
def self.call(locale_keys:, format:, include_hits_count: false)
raise ArgumentError, 'format must be yaml or csv' if %i[yaml csv].exclude?(format)
Lit.loader.cache.load_all_translations
localizations_... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/cloud_translation.rb | Ruby | mit | 300 | master | 1,853 | # frozen_string_literal: true
module Lit
module CloudTranslation
class TranslationError < StandardError; end
module_function
# Sets the provider for cloud translations.
# @param [Class] provider Selected translation provider,
# descending from Lit::CloudTranslation::Providers::Base
def pr... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/services/localization_keys_to_hash_service.rb | Ruby | mit | 300 | master | 786 | # frozen_string_literal: true
module Lit
module Services
# Converts flat hash with localization_keys as keys and translations as values to nested hash
# by nesting on '.' localization key dots
class LocalizationKeysToHashService
# http://subtech.g.hatena.ne.jp/cho45/20061122
def self.call(db_... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/services/humanize_service.rb | Ruby | mit | 300 | master | 799 | # frozen_string_literal: true
module Lit
module Services
# Checks if should humanize based on config and blacklist.
# Performs humanize if required
# Caches the value of humanization
class HumanizeService
def self.should_humanize?(key)
Lit.humanize_key && Lit.humanize_key_ignored.match(... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/adapters/redis_storage.rb | Ruby | mit | 300 | master | 3,369 | require 'redis'
require 'lit/services/localization_keys_to_hash_service'
module Lit
extend self
def redis
$redis ||= nil
$redis = Redis.new(url: determine_redis_provider, ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }) unless $redis
$redis
end
def determine_redis_provider
Lit.redis_url... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/adapters/hash_storage.rb | Ruby | mit | 300 | master | 1,178 | module Lit::Adapters
class HashStorage < Hash
def incr(key)
self[key] ||= 0
if self[key].is_a?(Integer)
self[key] += 1
else
subtree_keys(key).each { |k| self[k] += 1 }
end
end
def prefix
nil
end
def [](key)
super || subtree_of_key(key)
end
... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/cloud_translation/providers/yandex.rb | Ruby | mit | 300 | master | 2,441 | # frozen_string_literal: true
require_relative 'base'
require 'net/http'
module Lit::CloudTranslation::Providers
# Yandex Translate API provider for Lit translation suggestions.
#
# Configuration:
#
# require 'lit/cloud_translation/providers/yandex'
#
# Lit::CloudTranslation.provider = Lit::CloudTra... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/cloud_translation/providers/deepl_translator.rb | Ruby | mit | 300 | master | 1,636 | # frozen_string_literal: true
require_relative 'base'
require 'deepl'
module Lit::CloudTranslation::Providers
# DeepL Translate API provider for Lit translation suggestions.
#
# Configuration:
#
# require 'lit/cloud_translation/providers/deepl_translator'
#
# Lit::CloudTranslation.provider = Lit::Cl... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/cloud_translation/providers/base.rb | Ruby | mit | 300 | master | 2,168 | # frozen_string_literal: true
module Lit::CloudTranslation::Providers
# Abstract base class for cloud translation providers, providing a skeleton
# for the provider's functionality (mainly the #translate method) as well as
# a configuration management mechanism.
class Base
attr_reader :config
def init... |
github | prograils/lit | https://github.com/prograils/lit | lib/lit/cloud_translation/providers/google.rb | Ruby | mit | 300 | master | 4,699 | # frozen_string_literal: true
require_relative 'base'
begin
require 'google/cloud/translate'
rescue LoadError
raise StandardError, 'You need to add "gem \'google-cloud-translate\'" to your Gemfile to support Google Cloud Translation'
end
module Lit::CloudTranslation::Providers
# Google Cloud Translation API pro... |
github | awilliams/RTanque | https://github.com/awilliams/RTanque | rtanque.gemspec | Ruby | mit | 300 | master | 1,751 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rtanque/version'
Gem::Specification.new do |gem|
gem.name = "rtanque"
gem.version = RTanque::VERSION
gem.authors = ["Adam Williams"]
gem.email = ["p... |
github | awilliams/RTanque | https://github.com/awilliams/RTanque | spec/spec_helper.rb | Ruby | mit | 300 | master | 1,471 | # This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
requir... |
github | awilliams/RTanque | https://github.com/awilliams/RTanque | spec/rtanque_spec.rb | Ruby | mit | 300 | master | 1,199 | require "spec_helper"
describe RTanque do
context 'face-off' do
before(:each) {
@winner = brain_bot { self.command.fire(RTanque::Bot::MAX_GUN_ENERGY) }
@looser = brain_bot { }
@winner.position = RTanque::Point.new(0, 0, @arena)
@winner.turret.heading = RTanque::Heading.new(RTanque::Headi... |
github | awilliams/RTanque | https://github.com/awilliams/RTanque | spec/rtanque/bot_spec.rb | Ruby | mit | 300 | master | 6,935 | require "spec_helper"
describe RTanque::Bot do
before(:each) { @brain_tick_lambda = lambda { } }
let(:bot){ brain_bot(&@brain_tick_lambda) }
context '#dead?' do
it 'should not initially be dead' do
expect(bot.dead?).to be_falsey
end
it 'should be true if health is below min' do
bot.heal... |
github | awilliams/RTanque | https://github.com/awilliams/RTanque | spec/rtanque/shell_spec.rb | Ruby | mit | 300 | master | 1,109 | require "spec_helper"
describe RTanque::Shell do
let(:bot) { mockbot(10, 10, 'shooter') }
let(:shell) { described_class.new(bot, RTanque::Point.new(10, 10, @arena), RTanque::Heading.new(0), 1) }
context '#hits' do
it 'should yield no bots' do
bots = []
expect{ |p| shell.hits(bots, &p) }.not_to y... |
github | awilliams/RTanque | https://github.com/awilliams/RTanque | spec/rtanque/point_spec.rb | Ruby | mit | 300 | master | 6,172 | require "spec_helper"
describe RTanque::Point do
context '.distance' do
it 'gives 0 when points are equal' do
a = described_class.new(0, 0, @arena)
b = described_class.new(0, 0, @arena)
expect(described_class.distance(a,b)).to eq 0
end
it 'always returns positive number' do
a = d... |
github | awilliams/RTanque | https://github.com/awilliams/RTanque | spec/rtanque/normalized_attr_spec.rb | Ruby | mit | 300 | master | 2,401 | require "spec_helper"
INFINITY = 1.0 / 0.0
describe RTanque::NormalizedAttr do
context 'integer range, no max delta' do
let(:instance) do
described_class::AttrContainer.new(1..5)
end
let(:attached_instance) do
double('some_object')
end
it 'has -infinity as max_delta' do
expect... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.