Skip to content

Commit

Permalink
adding tests and translations
Browse files Browse the repository at this point in the history
  • Loading branch information
onomojo committed Mar 25, 2012
1 parent 09cdb9c commit bbd4341
Show file tree
Hide file tree
Showing 47 changed files with 708 additions and 829 deletions.
13 changes: 0 additions & 13 deletions 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'
25 changes: 19 additions & 6 deletions Gemfile.lock
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
28 changes: 27 additions & 1 deletion README.rdoc
@@ -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
44 changes: 20 additions & 24 deletions Rakefile
Expand Up @@ -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
17 changes: 9 additions & 8 deletions i18n-country-translations.gemspec
@@ -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
3 changes: 1 addition & 2 deletions lib/i18n-country-translations.rb
@@ -1,2 +1 @@
module I18nCountryTranslations
end
require 'i18n_country_translations'
1 change: 1 addition & 0 deletions lib/i18n_country_translations.rb
@@ -0,0 +1 @@
require 'i18n_country_translations/railtie'
25 changes: 25 additions & 0 deletions lib/i18n_country_translations/railtie.rb
@@ -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
File renamed without changes.

0 comments on commit bbd4341

Please sign in to comment.