Permalink
Browse files

adding tests and translations

  • Loading branch information...
1 parent 09cdb9c commit bbd4341b1a9fcd79cbdf2adc983a712ee438bae5 @onomojo committed Mar 25, 2012
Showing with 708 additions and 829 deletions.
  1. +0 −13 Gemfile
  2. +19 −6 Gemfile.lock
  3. +27 −1 README.rdoc
  4. +20 −24 Rakefile
  5. +9 −8 i18n-country-translations.gemspec
  6. +1 −2 lib/i18n-country-translations.rb
  7. +1 −0 lib/i18n_country_translations.rb
  8. +25 −0 lib/i18n_country_translations/railtie.rb
  9. 0 lib/{i18n-country-translations → i18n_country_translations}/version.rb
  10. +284 −0 rails/locale/en.yml
  11. +272 −0 rails/locale/es.yml
  12. +12 −0 spec/spec_helper.rb
  13. +28 −0 spec/support/fake_app.rb
  14. +10 −0 spec/unit/translations_spec.rb
  15. +0 −261 test/dummy/README.rdoc
  16. +0 −7 test/dummy/Rakefile
  17. +0 −15 test/dummy/app/assets/javascripts/application.js
  18. +0 −13 test/dummy/app/assets/stylesheets/application.css
  19. +0 −3 test/dummy/app/controllers/application_controller.rb
  20. +0 −2 test/dummy/app/helpers/application_helper.rb
  21. 0 test/dummy/app/mailers/.gitkeep
  22. 0 test/dummy/app/models/.gitkeep
  23. +0 −14 test/dummy/app/views/layouts/application.html.erb
  24. +0 −4 test/dummy/config.ru
  25. +0 −56 test/dummy/config/application.rb
  26. +0 −10 test/dummy/config/boot.rb
  27. +0 −25 test/dummy/config/database.yml
  28. +0 −5 test/dummy/config/environment.rb
  29. +0 −37 test/dummy/config/environments/development.rb
  30. +0 −67 test/dummy/config/environments/production.rb
  31. +0 −37 test/dummy/config/environments/test.rb
  32. +0 −7 test/dummy/config/initializers/backtrace_silencers.rb
  33. +0 −15 test/dummy/config/initializers/inflections.rb
  34. +0 −5 test/dummy/config/initializers/mime_types.rb
  35. +0 −7 test/dummy/config/initializers/secret_token.rb
  36. +0 −8 test/dummy/config/initializers/session_store.rb
  37. +0 −14 test/dummy/config/initializers/wrap_parameters.rb
  38. +0 −5 test/dummy/config/locales/en.yml
  39. +0 −58 test/dummy/config/routes.rb
  40. 0 test/dummy/lib/assets/.gitkeep
  41. +0 −26 test/dummy/public/404.html
  42. +0 −26 test/dummy/public/422.html
  43. +0 −25 test/dummy/public/500.html
  44. 0 test/dummy/public/favicon.ico
  45. +0 −6 test/dummy/script/rails
  46. +0 −7 test/i18n-country-translations_test.rb
  47. +0 −10 test/test_helper.rb
View
13 Gemfile
@@ -1,17 +1,4 @@
source "http://rubygems.org"
-# Declare your gem's dependencies in i18n-country-translations.gemspec.
-# Bundler will treat runtime dependencies like base dependencies, and
-# development dependencies will be added by default to the :development group.
gemspec
-# jquery-rails is used by the dummy application
-gem "jquery-rails"
-
-# Declare any dependencies that are still in development here instead of in
-# your gemspec. These might include edge Rails or gems from your path or
-# Git. Remember to move these dependencies to your gemspec before releasing
-# your gem to rubygems.org.
-
-# To use debugger
-# gem 'ruby-debug19', :require => 'ruby-debug'
View
@@ -36,13 +36,12 @@ GEM
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
+ diff-lcs (1.1.3)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
+ i18n-spec (0.1.2)
journey (1.0.3)
- jquery-rails (2.0.1)
- railties (>= 3.2.0, < 5.0)
- thor (~> 0.14)
json (1.6.5)
mail (2.4.4)
i18n (>= 0.4.0)
@@ -76,11 +75,24 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
+ rspec (2.9.0)
+ rspec-core (~> 2.9.0)
+ rspec-expectations (~> 2.9.0)
+ rspec-mocks (~> 2.9.0)
+ rspec-core (2.9.0)
+ rspec-expectations (2.9.0)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.9.0)
+ rspec-rails (2.9.0)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.9.0)
+ spork (1.0.0rc2)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -93,5 +105,6 @@ PLATFORMS
DEPENDENCIES
i18n-country-translations!
- jquery-rails
- sqlite3
+ i18n-spec (>= 0.1.1)
+ rspec-rails (>= 2.7.0)
+ spork (~> 1.0rc)
View
@@ -1,3 +1,29 @@
= I18nCountryTranslations
-This project rocks and uses MIT-LICENSE.
+I18n Country Translations - The purpose of this gem is to simply provide country translations. The gem is intended to be easy to combine with other gems that require i18n country translations so we can have common i18n country translation gem.
+
+If you're doing anything with country names and translations, there's no need to reinvent the wheel and add your own translations. Just use this gem's country translations and skip the hassle of having to add and manage each country translation for each locale.
+
+== Installation
+
+Add to your Gemfile:
+
+ gem 'i18n-country-translations', :git => 'git@github.com:onomojo/i18n-country-translations.git'
+
+
+
+You can easily start adding country translations to the locales with help from this script: https://gist.github.com/2128684
+It will generate a new yml file that contains the country translations for the locale specified. Take the contents of this file and move it into the correct locale file.
+So far only en-US.yml and es.yml have them added.
+
+
+
+
+== Contributors
+Brian McQuay - http://www.onomojo.com
+
+== License
+MIT or GPL
+
+== Special thanks
+https://github.com/svenfuchs/rails-i18n
View
@@ -4,35 +4,31 @@ begin
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
-begin
- require 'rdoc/task'
-rescue LoadError
- require 'rdoc/rdoc'
- require 'rake/rdoctask'
- RDoc::Task = Rake::RDocTask
-end
-
-RDoc::Task.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'I18nCountryTranslations'
- rdoc.options << '--line-numbers'
- rdoc.rdoc_files.include('README.rdoc')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
-
+require 'rake'
+require 'rake/testtask'
+require 'rbconfig'
+task :test => 'test:all'
+require 'rspec/core'
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = FileList['spec/**/*_spec.rb']
+end
-Bundler::GemHelper.install_tasks
+RSpec::Core::RakeTask.new("spec:unit") do |spec|
+ spec.pattern = 'spec/unit/**/*_spec.rb'
+end
-require 'rake/testtask'
+RSpec::Core::RakeTask.new("spec:integration") do |spec|
+ spec.pattern = 'spec/integration/**/*_spec.rb'
+end
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = false
+RSpec::Core::RakeTask.new(:rcov) do |spec|
+ spec.pattern = 'spec/**/*_spec.rb'
+ spec.rcov = true
end
+#require 'i18n-spec/tasks' # needs to be loaded after rspec
-task :default => :test
+task :default => :spec
@@ -1,22 +1,23 @@
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
-require "i18n-country-translations/version"
+require "i18n_country_translations/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "i18n-country-translations"
s.version = I18nCountryTranslations::VERSION
- s.authors = ["TODO: Your name"]
- s.email = ["TODO: Your email"]
- s.homepage = "TODO"
- s.summary = "TODO: Summary of I18nCountryTranslations."
- s.description = "TODO: Description of I18nCountryTranslations."
+ s.authors = ["Brian McQuay"]
+ s.email = ["brian@onomojo.com"]
+ s.homepage = "https://github.com/onomojo/i18n-country-translations"
+ s.summary = "I18n Country Translations"
+ s.description = "The purpose of this gem is to simply provide country translations. The gem is intended to be easy to combine with other gems that require i18n country translations so we can have common i18n country translation gem."
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
s.add_dependency "rails", "~> 3.2.2"
-
- s.add_development_dependency "sqlite3"
+ s.add_development_dependency "rspec-rails", ">= 2.7.0"
+ s.add_development_dependency "i18n-spec", ">= 0.1.1"
+ s.add_development_dependency "spork", "~> 1.0rc"
end
@@ -1,2 +1 @@
-module I18nCountryTranslations
-end
+require 'i18n_country_translations'
@@ -0,0 +1 @@
+require 'i18n_country_translations/railtie'
@@ -0,0 +1,25 @@
+require 'rails'
+
+module I18nCountryTranslations
+ class Railtie < ::Rails::Railtie #:nodoc:
+ initializer 'i18n-country-translations' do |app|
+ I18nCountryTranslations::Railtie.instance_eval do
+ pattern = pattern_from app.config.i18n.available_locales
+
+ add("rails/locale/#{pattern}.yml")
+ end
+ end
+
+ protected
+
+ def self.add(pattern)
+ files = Dir[File.join(File.dirname(__FILE__), '../..', pattern)]
+ I18n.load_path.concat(files)
+ end
+
+ def self.pattern_from(args)
+ array = Array(args || [])
+ array.blank? ? '*' : "{#{array.join ','}}"
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit bbd4341

Please sign in to comment.