babel_train 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +1 -15
  3. data/Rakefile +8 -2
  4. data/app/assets/javascripts/{bable_train → babel_train}/application.js +0 -0
  5. data/app/assets/stylesheets/{bable_train → babel_train}/application.css +0 -0
  6. data/app/controllers/{bable_train → babel_train}/application_controller.rb +0 -0
  7. data/app/helpers/{bable_train → babel_train}/application_helper.rb +0 -0
  8. data/app/views/layouts/{bable_train → babel_train}/application.html.erb +0 -0
  9. data/lib/babel_train/engine.rb +8 -0
  10. data/lib/babel_train/i18n.rb +49 -0
  11. data/lib/babel_train/version.rb +1 -1
  12. data/lib/tasks/{bable_train_tasks.rake → babel_train_tasks.rake} +0 -0
  13. data/spec/features/translations_spec.rb +9 -0
  14. data/spec/rails_helper.rb +53 -0
  15. data/spec/spec_helper.rb +90 -0
  16. data/spec/test-app/README.rdoc +28 -0
  17. data/spec/test-app/Rakefile +6 -0
  18. data/spec/test-app/app/assets/javascripts/application.js +13 -0
  19. data/spec/test-app/app/assets/stylesheets/application.css +15 -0
  20. data/spec/test-app/app/controllers/application_controller.rb +5 -0
  21. data/spec/test-app/app/controllers/pages_controller.rb +2 -0
  22. data/spec/test-app/app/helpers/application_helper.rb +2 -0
  23. data/spec/test-app/app/helpers/pages_helper.rb +2 -0
  24. data/spec/test-app/app/views/layouts/application.html.erb +14 -0
  25. data/spec/test-app/app/views/pages/page_1.html.erb +1 -0
  26. data/spec/test-app/app/views/pages/page_2.html.erb +1 -0
  27. data/spec/test-app/bin/bundle +3 -0
  28. data/spec/test-app/bin/rails +4 -0
  29. data/spec/test-app/bin/rake +4 -0
  30. data/spec/test-app/bin/setup +29 -0
  31. data/spec/test-app/config.ru +4 -0
  32. data/spec/test-app/config/application.rb +32 -0
  33. data/spec/test-app/config/boot.rb +5 -0
  34. data/spec/test-app/config/database.yml +25 -0
  35. data/spec/test-app/config/environment.rb +5 -0
  36. data/spec/test-app/config/environments/development.rb +42 -0
  37. data/spec/test-app/config/environments/production.rb +79 -0
  38. data/spec/test-app/config/environments/test.rb +43 -0
  39. data/spec/test-app/config/initializers/assets.rb +11 -0
  40. data/spec/test-app/config/initializers/backtrace_silencers.rb +7 -0
  41. data/spec/test-app/config/initializers/cookies_serializer.rb +3 -0
  42. data/spec/test-app/config/initializers/filter_parameter_logging.rb +4 -0
  43. data/spec/test-app/config/initializers/i18n.rb +3 -0
  44. data/spec/test-app/config/initializers/inflections.rb +16 -0
  45. data/spec/test-app/config/initializers/mime_types.rb +4 -0
  46. data/spec/test-app/config/initializers/session_store.rb +3 -0
  47. data/spec/test-app/config/initializers/wrap_parameters.rb +14 -0
  48. data/spec/test-app/config/locales/en.yml +1 -0
  49. data/spec/test-app/config/locales/pages/page_1.en.yml +3 -0
  50. data/spec/test-app/config/locales/pages/page_2/en.yml +1 -0
  51. data/spec/test-app/config/routes.rb +4 -0
  52. data/spec/test-app/config/secrets.yml +22 -0
  53. data/spec/test-app/log/development.log +0 -0
  54. data/spec/test-app/log/test.log +44 -0
  55. data/spec/test-app/public/404.html +67 -0
  56. data/spec/test-app/public/422.html +67 -0
  57. data/spec/test-app/public/500.html +66 -0
  58. data/spec/test-app/public/favicon.ico +0 -0
  59. metadata +132 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd392e9d45ca98aaf8873a81048152ed4a003b2f
4
- data.tar.gz: ea5df2f17471b46c227a58cb2efaec060df3b91e
3
+ metadata.gz: 2518d922378fd2f554d1eeb4b36c3cb2782987a4
4
+ data.tar.gz: c2ebf9ec08c38fc3af846fe954ce54aeaa11d245
5
5
  SHA512:
6
- metadata.gz: 8c760acd5af255be11e7718007b9ba9356494410bb4163aa33c4c2cfb6a90267fd2296752320324bf88551e4a45a37a00aa661c9b7ff078306a131566aaf0362
7
- data.tar.gz: 646c096ad5a7b56c489cf7454484524a756091223340da541f3b99ac3c02d792df7338e0f4d9a00ed0520c17547274c5e4ce5fa5c6c6f65faddb5512b322a191
6
+ metadata.gz: 67c85de5a8d2456859deaa83f0f1dfc65010455abbc51b435111e3db1b9e66126d4564a3cc5119bf943827a7303b69fa440ee6726a4fe08398eebf1122e43cdf
7
+ data.tar.gz: db0ae1e83e55b6bff0a34074a4728a7ebeb45573869436b25cf642678012dadbd83e1f4d759150bdc4cc80148e5814d041cb0653bfc0e2ff09c6541cc12c8f62
@@ -1,17 +1,3 @@
1
1
  = BabelTrain
2
2
 
3
- A backend for i18n that automatically scopes by folder and file name. To automatically recreate this key fully with little
4
- reproduction of data in the YAML files, use this naming scheme:
5
-
6
- `en.controllers.my_controller => controllers/my_controller.en.yml`
7
-
8
- Alternately you can create one more folder and name the files with the language selector:
9
-
10
- `en.controllers.my_controller => controllers/my_controller/en.yml`
11
-
12
- == TODO
13
-
14
- Pretty much everything at this point. However, in the future these are features that will be added:
15
-
16
- * Functioning Rails engine to assist in editing files with a GUI.
17
- * Integration of automatic translators
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile CHANGED
@@ -16,11 +16,17 @@ end
16
16
 
17
17
  APP_RAKEFILE = File.expand_path("../spec/test-app/Rakefile", __FILE__)
18
18
  load 'rails/tasks/engine.rake'
19
+ load 'rails/tasks/statistics.rake'
19
20
 
21
+ Bundler::GemHelper.install_tasks
20
22
 
21
- load 'rails/tasks/statistics.rake'
23
+ Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
22
24
 
25
+ require 'rspec/core'
26
+ require 'rspec/core/rake_task'
23
27
 
28
+ desc "Run all specs in spec directory (excluding plugin specs)"
29
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
24
30
 
25
- Bundler::GemHelper.install_tasks
31
+ task :default => :spec
26
32
 
@@ -1,5 +1,13 @@
1
1
  module BabelTrain
2
2
  class Engine < ::Rails::Engine
3
+
3
4
  isolate_namespace BabelTrain
5
+
6
+ config.generators do |g|
7
+ g.test_framework :rspec, :fixture => false
8
+ g.assets false
9
+ g.helper false
10
+ end
11
+
4
12
  end
5
13
  end
@@ -0,0 +1,49 @@
1
+ module BabelTrain
2
+ class I18n
3
+
4
+ include ::I18n::Backend::Base
5
+
6
+ def initialize
7
+ @translations = {}
8
+ super
9
+ end
10
+
11
+ def available_locales
12
+ @translations.keys
13
+ end
14
+
15
+ def reload!
16
+ base = Rails.root.join('config/locales')
17
+ base_str = "#{base.to_s}/"
18
+ Dir[base.join('**/*.yml')].each do |file_path|
19
+ yaml_hash = YAML.load(File.read(file_path))
20
+ path_parts = file_path.gsub(base_str, '').split('/')
21
+ file_parts = path_parts.pop.split('.')
22
+ file_parts.pop # Don't need the YML part, thank you
23
+ language = file_parts.pop.to_sym
24
+ value_base = (path_parts + file_parts).join('.')
25
+ @translations[language] ||= {}
26
+ @translations[language].merge! process_hash(yaml_hash, value_base)
27
+ end
28
+ end
29
+
30
+ protected
31
+
32
+ def lookup(locale, key, scope = [], options = {})
33
+ raise scope.inspect if scope && scope.size > 0 # Temporary testing stuff
34
+ raise options.inspect if options && options.size > 0 # Temporary testing stuff
35
+ @translations[locale.to_sym][key]
36
+ end
37
+
38
+ def process_hash(hash, base)
39
+ base_empty = base.nil? || base == ''
40
+ ret = {}
41
+ hash.each do |key, value|
42
+ full_key = base_empty ? key : "#{base}.#{key}"
43
+ value.is_a?(Hash) ? ret.merge!(process_hash(value, full_key)) : ret[full_key] = value
44
+ end
45
+ ret
46
+ end
47
+
48
+ end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module BabelTrain
2
- VERSION = '0.0.0'
2
+ VERSION = '0.0.1'
3
3
  end
@@ -0,0 +1,9 @@
1
+ describe 'translation data' do
2
+
3
+ it 'loads properly' do
4
+ # errors will be raised if translation data is missing
5
+ visit '/page_1'
6
+ visit '/page_2'
7
+ end
8
+
9
+ end
@@ -0,0 +1,53 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ require 'spec_helper'
4
+ require File.expand_path("../test-app/config/environment.rb", __FILE__)
5
+ require 'rspec/rails'
6
+ require 'capybara/rails'
7
+
8
+ # Add additional requires below this line. Rails is not loaded until this point!
9
+
10
+ # Requires supporting ruby files with custom matchers and macros, etc, in
11
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
12
+ # run as spec files by default. This means that files in spec/support that end
13
+ # in _spec.rb will both be required and run as specs, causing the specs to be
14
+ # run twice. It is recommended that you do not name files matching this glob to
15
+ # end with _spec.rb. You can configure this pattern with the --pattern
16
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
17
+ #
18
+ # The following line is provided for convenience purposes. It has the downside
19
+ # of increasing the boot-up time by auto-requiring all files in the support
20
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
21
+ # require only the support files necessary.
22
+ #
23
+ # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
24
+
25
+ # Checks for pending migrations before tests are run.
26
+ # If you are not using ActiveRecord, you can remove this line.
27
+ # ActiveRecord::Migration.maintain_test_schema!
28
+
29
+ RSpec.configure do |config|
30
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
31
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
32
+
33
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
34
+ # examples within a transaction, remove the following line or assign false
35
+ # instead of true.
36
+ config.use_transactional_fixtures = false
37
+
38
+ # RSpec Rails can automatically mix in different behaviours to your tests
39
+ # based on their file location, for example enabling you to call `get` and
40
+ # `post` in specs under `spec/controllers`.
41
+ #
42
+ # You can disable this behaviour by removing the line below, and instead
43
+ # explicitly tag your specs with their type, e.g.:
44
+ #
45
+ # RSpec.describe UsersController, :type => :controller do
46
+ # # ...
47
+ # end
48
+ #
49
+ # The different available types are documented in the features, such as in
50
+ # https://relishapp.com/rspec/rspec-rails/docs
51
+ config.infer_spec_type_from_file_location!
52
+
53
+ end
@@ -0,0 +1,90 @@
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+
20
+ require 'capybara/rspec'
21
+
22
+ RSpec.configure do |config|
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # The settings below are suggested to provide a good initial experience
47
+ # with RSpec, but feel free to customize to your heart's content.
48
+ =begin
49
+ # These two settings work together to allow you to limit a spec run
50
+ # to individual examples or groups you care about by tagging them with
51
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
52
+ # get run.
53
+ config.filter_run :focus
54
+ config.run_all_when_everything_filtered = true
55
+
56
+ # Limits the available syntax to the non-monkey patched syntax that is
57
+ # recommended. For more details, see:
58
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
59
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
60
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
61
+ config.disable_monkey_patching!
62
+
63
+ # Many RSpec users commonly either run the entire suite or an individual
64
+ # file, and it's useful to allow more verbose output when running an
65
+ # individual spec file.
66
+ if config.files_to_run.one?
67
+ # Use the documentation formatter for detailed output,
68
+ # unless a formatter has already been configured
69
+ # (e.g. via a command-line flag).
70
+ config.default_formatter = 'doc'
71
+ end
72
+
73
+ # Print the 10 slowest examples and example groups at the
74
+ # end of the spec run, to help surface which specs are running
75
+ # particularly slow.
76
+ config.profile_examples = 10
77
+
78
+ # Run specs in random order to surface order dependencies. If you find an
79
+ # order dependency and want to debug it, you can fix the order by providing
80
+ # the seed, which is printed after each run.
81
+ # --seed 1234
82
+ config.order = :random
83
+
84
+ # Seed global randomization in this process using the `--seed` CLI option.
85
+ # Setting this allows you to use `--seed` to deterministically reproduce
86
+ # test failures related to randomization by passing the same `--seed` value
87
+ # as the one that triggered the failure.
88
+ Kernel.srand config.seed
89
+ =end
90
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ class PagesController < ApplicationController
2
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module PagesHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>TestApp</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1 @@
1
+ <%= t('.title') %>
@@ -0,0 +1 @@
1
+ <%= t('.title') %>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end