i18n-spec-0.6.0/0000755000175000017500000000000013473263023012563 5ustar samyaksamyaki18n-spec-0.6.0/lib/0000755000175000017500000000000013473263023013331 5ustar samyaksamyaki18n-spec-0.6.0/lib/i18n-spec/0000755000175000017500000000000013473263023015040 5ustar samyaksamyaki18n-spec-0.6.0/lib/i18n-spec/models/0000755000175000017500000000000013473263023016323 5ustar samyaksamyaki18n-spec-0.6.0/lib/i18n-spec/models/locale_file.rb0000644000175000017500000000546713473263023021122 0ustar samyaksamyakmodule I18nSpec class LocaleFile PLURALIZATION_KEYS = %w{zero one two few many other} attr_accessor :filepath attr_reader :errors def initialize(filepath) @filepath = filepath @errors = {} end def content @content ||= IO.read(@filepath) end def translations @translations ||= yaml_load_content end def flattened_translations @flattened_translations ||= flatten_tree(translations.values.first) end def locale @locale ||= ISO::Tag.new(locale_code) end def locale_code translations.keys.first end def pluralizations result = flatten_tree(translations).select do |key, value| value.is_a?(Hash) end if result.is_a?(Array) Hash[result] else result end end def invalid_pluralization_keys invalid = [] pluralizations.each do |parent, pluralization| unless pluralization.keys.all? { |key| PLURALIZATION_KEYS.include?(key) } invalid << parent end end @errors[:invalid_pluralization_keys] = invalid unless invalid.empty? invalid end def missing_pluralization_keys return_data = {} rule_names = locale.language.plural_rule_names pluralizations.each do |parent, pluralization| missing_keys = rule_names - pluralization.keys return_data[parent] = missing_keys if missing_keys.any? end @errors[:missing_pluralization_keys] = return_data if return_data.any? return_data end def is_parseable? if RUBY_VERSION < "1.9.3" yaml_parse_exception = YAML::ParseError else yaml_parse_exception = YAML::SyntaxError end begin yaml_load_content true rescue yaml_parse_exception => e @errors[:unparseable] = e.to_s false rescue ArgumentError => e @errors[:unparseable] = e.to_s false end end def has_one_top_level_namespace? translations.keys.size == 1 end def is_named_like_top_level_namespace? locale_code == File.basename(@filepath, File.extname(@filepath)) end protected def flatten_tree(data, prefix = '', result = {}) data.each do |key, value| current_prefix = prefix.empty? ? key.to_s : "#{prefix}.#{key}" if !value.is_a?(Hash) || pluralization_data?(value) result[current_prefix] = value else flatten_tree(value, current_prefix, result) end end result end def pluralization_data?(data) keys = data.keys.map(&:to_s) keys.any? {|k| PLURALIZATION_KEYS.include?(k) } end def yaml_load_content if defined?(Psych) and defined?(Psych::VERSION) Psych.load(content) else YAML.load(content) end end end end i18n-spec-0.6.0/lib/i18n-spec/tasks.rb0000644000175000017500000000430213473263023016511 0ustar samyaksamyakrequire 'i18n-spec' I18nSpec::LOG_DETAIL_PREDICATE = " - " namespace :'i18n-spec' do desc "Checks the validity of a locale file" task :validate do if ARGV[1].nil? puts "You must specifiy a file path or a folder path" return elsif File.directory?(ARGV[1]) filepaths = Dir.glob("#{ARGV[1]}/*.yml") else filepaths = [ARGV[1]] end filepaths.each do |filepath| heading filepath fatals, errors, warnings = [0, 0, 0] locale_file = I18nSpec::LocaleFile.new(filepath) unless locale_file.is_parseable? log :fatal, 'could not be parsed', format_str(locale_file.errors[:unparseable]) fatals += 1 break end unless locale_file.invalid_pluralization_keys.empty? log :error, 'invalid pluralization keys', format_array(locale_file.errors[:invalid_pluralization_keys]) errors += 1 end log :ok if fatals + errors + warnings == 0 end end desc "Checks for missing translations between the default and the translated locale file" task :completeness do if ARGV[1].nil? || ARGV[2].nil? puts "You must specify a default locale file and translated file or a folder of translated files" elsif File.directory?(ARGV[2]) translated_filepaths = Dir.glob("#{ARGV[2]}/*.yml") else translated_filepaths = [ARGV[2]] end default_locale = I18nSpec::LocaleFile.new(ARGV[1]) translated_filepaths.each do |translated_filepath| heading translated_filepath locale_file = I18nSpec::LocaleFile.new(translated_filepath) misses = default_locale.flattened_translations.keys.reject do |key| locale_file.flattened_translations.keys.include?(key) end if misses.empty? log :complete else misses.each { |miss| log :missing, miss } end end end def log(level, msg='', detail=nil) puts "- *" << level.to_s.upcase << '* ' << msg puts detail if detail end def heading(str='') puts "\n### " << str << "\n\n" end def format_array(array) [I18nSpec::LOG_DETAIL_PREDICATE, array.join(I18nSpec::LOG_DETAIL_PREDICATE)].join end def format_str(str) [I18nSpec::LOG_DETAIL_PREDICATE, str].join end endi18n-spec-0.6.0/lib/i18n-spec/failure_message.rb0000644000175000017500000000114513473263023020521 0ustar samyaksamyakmodule I18nSpec module FailureMessage def failure_for_should(&block) if respond_to?(:failure_message) # Rspec 3 failure_message { |f| instance_exec(f, &block) } else # Rspec 2 failure_message_for_should { |f| instance_exec(f, &block) } end end def failure_for_should_not(&block) if respond_to?(:failure_message_when_negated) # Rspec 3 failure_message_when_negated { |f| instance_exec(f, &block) } else # Rspec 2 failure_message_for_should_not { |f| instance_exec(f, &block) } end end end end i18n-spec-0.6.0/lib/i18n-spec/matchers/0000755000175000017500000000000013473263023016646 5ustar samyaksamyaki18n-spec-0.6.0/lib/i18n-spec/matchers/have_missing_pluralization_keys_matcher.rb0000644000175000017500000000111213473263023027355 0ustar samyaksamyakRSpec::Matchers.define :have_missing_pluralization_keys do extend I18nSpec::FailureMessage match do |actual| @locale_file = I18nSpec::LocaleFile.new(actual) @locale_file.missing_pluralization_keys.any? end failure_for_should_not do |filepath| flattened_keys = [] @locale_file.errors[:missing_pluralization_keys].each do |parent, subkeys| subkeys.each do |subkey| flattened_keys << [parent, subkey].join('.') end end "expected #{filepath} to contain the following pluralization keys :\n- " << flattened_keys.join("\n- ") end end i18n-spec-0.6.0/lib/i18n-spec/matchers/be_named_like_top_level_namespace_matcher.rb0000644000175000017500000000030113473263023027513 0ustar samyaksamyakRSpec::Matchers.define :be_named_like_top_level_namespace do match do |actual| locale_file = I18nSpec::LocaleFile.new(actual) locale_file.is_named_like_top_level_namespace? end end i18n-spec-0.6.0/lib/i18n-spec/matchers/be_a_subset_of_matcher.rb0000644000175000017500000000076113473263023023641 0ustar samyaksamyakRSpec::Matchers.define :be_a_subset_of do |default_locale_filepath| extend I18nSpec::FailureMessage match do |filepath| locale_file = I18nSpec::LocaleFile.new(filepath) default_locale = I18nSpec::LocaleFile.new(default_locale_filepath) @superset = locale_file.flattened_translations.keys - default_locale.flattened_translations.keys @superset.empty? end failure_for_should do |filepath| "expected #{filepath} to not include :\n- " << @superset.join("\n- ") end end i18n-spec-0.6.0/lib/i18n-spec/matchers/be_parseable_matcher.rb0000644000175000017500000000050313473263023023300 0ustar samyaksamyakRSpec::Matchers.define :be_parseable do extend I18nSpec::FailureMessage match do |actual| @locale_file = I18nSpec::LocaleFile.new(actual) @locale_file.is_parseable? end failure_for_should do |filepath| "expected #{filepath} to be parseable but got :\n- #{@locale_file.errors[:unparseable]}" end end i18n-spec-0.6.0/lib/i18n-spec/matchers/be_a_complete_translation_of_matcher.rb0000644000175000017500000000076513473263023026566 0ustar samyaksamyakRSpec::Matchers.define :be_a_complete_translation_of do |default_locale_filepath| extend I18nSpec::FailureMessage match do |filepath| locale_file = I18nSpec::LocaleFile.new(filepath) default_locale = I18nSpec::LocaleFile.new(default_locale_filepath) @misses = default_locale.flattened_translations.keys - locale_file.flattened_translations.keys @misses.empty? end failure_for_should do |filepath| "expected #{filepath} to include :\n- " << @misses.join("\n- ") end end i18n-spec-0.6.0/lib/i18n-spec/matchers/have_valid_pluralization_keys_matcher.rb0000644000175000017500000000066313473263023027015 0ustar samyaksamyakRSpec::Matchers.define :have_valid_pluralization_keys do extend I18nSpec::FailureMessage match do |actual| @locale_file = I18nSpec::LocaleFile.new(actual) @locale_file.invalid_pluralization_keys.empty? end failure_for_should do |filepath| "expected #{filepath} to not contain invalid pluralization keys in the following namespaces :\n- " << @locale_file.errors[:invalid_pluralization_keys].join("\n- ") end end i18n-spec-0.6.0/lib/i18n-spec/matchers/have_legacy_interpolations.rb0000644000175000017500000000025713473263023024600 0ustar samyaksamyakRSpec::Matchers.define :have_legacy_interpolations do match do |actual| locale_file = I18nSpec::LocaleFile.new(actual) locale_file.content =~ /\{\{.+\}\}/ end end i18n-spec-0.6.0/lib/i18n-spec/matchers/have_one_top_level_namespace_matcher.rb0000644000175000017500000000026513473263023026552 0ustar samyaksamyakRSpec::Matchers.define :have_one_top_level_namespace do match do |actual| locale_file = I18nSpec::LocaleFile.new(actual) locale_file.has_one_top_level_namespace? end endi18n-spec-0.6.0/lib/i18n-spec/matchers/have_a_valid_locale_matcher.rb0000644000175000017500000000023613473263023024620 0ustar samyaksamyakRSpec::Matchers.define :have_a_valid_locale do match do |actual| locale_file = I18nSpec::LocaleFile.new(actual) locale_file.locale.valid? end end i18n-spec-0.6.0/lib/i18n-spec/shared_examples/0000755000175000017500000000000013473263023020204 5ustar samyaksamyaki18n-spec-0.6.0/lib/i18n-spec/shared_examples/valid_locale_file.rb0000644000175000017500000000073413473263023024152 0ustar samyaksamyakRSpec.shared_examples_for "a valid locale file" do |locale_file| describe locale_file do it { is_expected.to be_parseable } it { is_expected.to have_valid_pluralization_keys } it { is_expected.to_not have_missing_pluralization_keys } it { is_expected.to have_one_top_level_namespace } it { is_expected.to be_named_like_top_level_namespace } it { is_expected.to_not have_legacy_interpolations } it { is_expected.to have_a_valid_locale } end end i18n-spec-0.6.0/lib/i18n-spec.rb0000644000175000017500000000105213473263023015363 0ustar samyaksamyakif defined?(Psych) and defined?(Psych::VERSION) and !defined?(YAML::ParseError) YAML::ParseError = Psych::SyntaxError end require 'rspec/core' require 'iso' require 'yaml' require 'i18n-spec/failure_message' Dir[File.dirname(__FILE__) + '/i18n-spec/models/*.rb'].each {|file| require file } Dir[File.dirname(__FILE__) + '/i18n-spec/models/*.rb'].each {|file| require file } Dir[File.dirname(__FILE__) + '/i18n-spec/matchers/*.rb'].each {|file| require file } Dir[File.dirname(__FILE__) + '/i18n-spec/shared_examples/*.rb'].each {|file| require file } i18n-spec-0.6.0/.travis.yml0000644000175000017500000000015013473263023014670 0ustar samyaksamyakrvm: - 1.9.3 - 2.0.0 - 2.1 gemfile: - gemfiles/rspec_2.99.gemfile - gemfiles/rspec_3.gemfile i18n-spec-0.6.0/VERSION0000644000175000017500000000000513473263023013626 0ustar samyaksamyak0.6.0i18n-spec-0.6.0/spec/0000755000175000017500000000000013473263023013515 5ustar samyaksamyaki18n-spec-0.6.0/spec/lib/0000755000175000017500000000000013473263023014263 5ustar samyaksamyaki18n-spec-0.6.0/spec/lib/i18n-spec/0000755000175000017500000000000013473263023015772 5ustar samyaksamyaki18n-spec-0.6.0/spec/lib/i18n-spec/models/0000755000175000017500000000000013473263023017255 5ustar samyaksamyaki18n-spec-0.6.0/spec/lib/i18n-spec/models/locale_file_spec.rb0000644000175000017500000001230213473263023023050 0ustar samyaksamyakrequire 'spec_helper' module LocaleFileHelper def locale_file_with_content(content) locale_file = I18nSpec::LocaleFile.new('test.yml') expect(locale_file).to receive(:content).and_return(content) locale_file end end describe I18nSpec::LocaleFile do include LocaleFileHelper describe "#locale_code" do it "returns the first key of the file" do locale_file = locale_file_with_content("pt-BR:\n hello: world") expect(locale_file.locale_code).to eq('pt-BR') end end describe "#locale" do it "returns an ISO::Tag based on the locale_code" do locale_file = locale_file_with_content("pt-BR:\n hello: world") expect(locale_file.locale).to be_a(ISO::Tag) expect(locale_file.locale.language.code).to eq('pt') expect(locale_file.locale.region.code).to eq('BR') end end describe "#is_parseable?" do context "when YAML is parseable" do let(:locale_file) { locale_file_with_content("en:\n hello: world") } it "returns true" do expect(locale_file.is_parseable?).to eq(true) end end context "when YAML is NOT parseable" do let(:locale_file) { locale_file_with_content(": foo: bar:") } it "returns false" do expect(locale_file.is_parseable?).to eq(false) end it "adds an :unparseable error" do locale_file.is_parseable? expect(locale_file.errors[:unparseable]).not_to be_nil end end end describe "#pluralizations" do let(:content) { "en: cats: one: one two: two three: three dogs: one: one some: some birds: penguins: penguins doves: doves"} it "returns the leaf where one of the keys is a pluralization key" do locale_file = locale_file_with_content(content) expect(locale_file.pluralizations).to eq({ 'en.cats' => {'one' => 'one', 'two' => 'two', 'three' => 'three'}, 'en.dogs' => {'one' => 'one', 'some' => 'some'}, }) end end describe "#invalid_pluralization_keys" do let(:content) { "en: cats: one: one two: two tommy: tommy tabby: tabby dogs: one: one some: some birds: zero: zero other: other"} let(:locale_file) { locale_file_with_content(content) } it "returns the parent that contains invalid pluralizations" do expect(locale_file.invalid_pluralization_keys.size).to eq(2) expect(locale_file.invalid_pluralization_keys).to be_include 'en.cats' expect(locale_file.invalid_pluralization_keys).to be_include 'en.dogs' expect(locale_file.invalid_pluralization_keys).not_to be_include 'en.birds' end it "adds a :invalid_pluralization_keys error with each invalid key" do locale_file.invalid_pluralization_keys expect(locale_file.invalid_pluralization_keys.size).to eq(2) expect(locale_file.invalid_pluralization_keys).to be_include 'en.cats' expect(locale_file.invalid_pluralization_keys).to be_include 'en.dogs' expect(locale_file.invalid_pluralization_keys).not_to be_include 'en.birds' end end describe "#missing_pluralization_keys" do it "returns the parents that containts missing pluralizations in with the english rules" do content = "en: cats: one: one dogs: other: other birds: one: one other: other" locale_file = locale_file_with_content(content) expect(locale_file.missing_pluralization_keys).to eq({ 'en.cats' => %w(other), 'en.dogs' => %w(one) }) expect(locale_file.errors[:missing_pluralization_keys]).not_to be_nil end it "returns the parents that containts missing pluralizations in with the russian rules" do content = "ru: cats: one: one few: few many: many other: other dogs: one: one other: some birds: zero: zero one: one few: few other: other" locale_file = locale_file_with_content(content) expect(locale_file.missing_pluralization_keys).to eq({ 'ru.dogs' => %w(few many), 'ru.birds' => %w(many) }) expect(locale_file.errors[:missing_pluralization_keys]).not_to be_nil end it "returns the parents that containts missing pluralizations in with the japanese rules" do content = "ja: cats: one: one dogs: other: some birds: not really a pluralization" locale_file = locale_file_with_content(content) expect(locale_file.missing_pluralization_keys).to eq({ 'ja.cats' => %w(other) }) expect(locale_file.errors[:missing_pluralization_keys]).not_to be_nil end it "returns an empty hash when all pluralizations are complete" do content = "ja: cats: other: one dogs: other: some birds: not really a pluralization" locale_file = locale_file_with_content(content) expect(locale_file.missing_pluralization_keys).to eq({}) expect(locale_file.errors[:missing_pluralization_keys]).to be_nil end end end i18n-spec-0.6.0/spec/lib/i18n-spec/matchers_spec.rb0000644000175000017500000000240013473263023021133 0ustar samyaksamyakrequire 'spec_helper' describe "Valid file" do it_behaves_like "a valid locale file", 'spec/fixtures/en.yml' end describe "Invalid files" do it { expect('spec/fixtures/unparseable.yml').not_to be_parseable } it { expect('spec/fixtures/invalid_pluralization_keys.yml').not_to have_valid_pluralization_keys } it { expect('spec/fixtures/multiple_top_levels.yml').not_to have_one_top_level_namespace } it { expect('spec/fixtures/multiple_top_levels.yml').not_to be_named_like_top_level_namespace } it { expect('spec/fixtures/legacy_interpolations.yml').to have_legacy_interpolations } it { expect('spec/fixtures/invalid_locale.yml').not_to have_a_valid_locale } it { expect('spec/fixtures/not_subset.yml').not_to be_a_subset_of 'spec/fixtures/en.yml' } it { expect('spec/fixtures/missing_pluralization_keys.yml').to have_missing_pluralization_keys } end describe "Translated files" do describe 'spec/fixtures/fr.yml' do it { is_expected.to be_a_subset_of 'spec/fixtures/en.yml' } it { is_expected.to be_a_complete_translation_of 'spec/fixtures/en.yml' } end describe 'spec/fixtures/es.yml' do it { is_expected.to be_a_subset_of 'spec/fixtures/en.yml' } it { is_expected.not_to be_a_complete_translation_of 'spec/fixtures/en.yml'} end end i18n-spec-0.6.0/spec/fixtures/0000755000175000017500000000000013473263023015366 5ustar samyaksamyaki18n-spec-0.6.0/spec/fixtures/multiple_top_levels.yml0000644000175000017500000000004713473263023022201 0ustar samyaksamyaken: hello: world fr: bonjour: mondei18n-spec-0.6.0/spec/fixtures/legacy_interpolations.yml0000644000175000017500000000007513473263023022511 0ustar samyaksamyaken: cats: one: {{count}} cat other: {{count}} cats i18n-spec-0.6.0/spec/fixtures/invalid_locale.yml0000644000175000017500000000002013473263023021046 0ustar samyaksamyaklol: foo: bar i18n-spec-0.6.0/spec/fixtures/es.yml0000644000175000017500000000021513473263023016516 0ustar samyaksamyakes: cats: zero: 'no gatos' one: 'un gato' other: '%{count} gatos' itteh: bitteh: ceiling: kitteh: 'te mira'i18n-spec-0.6.0/spec/fixtures/fr.yml0000644000175000017500000000021413473263023016515 0ustar samyaksamyaken: hello: 'osalu' cats: one: 'un chat' other: '%{count} chats' itteh: bitteh: ceiling: kitteh: 'te regarde'i18n-spec-0.6.0/spec/fixtures/en.yml0000644000175000017500000000024113473263023016510 0ustar samyaksamyaken: hello: 'ohai' cats: zero: 'no cats' one: 'a cat' other: '%{count} cats' itteh: bitteh: ceiling: kitteh: 'is watching you'i18n-spec-0.6.0/spec/fixtures/invalid_pluralization_keys.yml0000644000175000017500000000020013473263023023537 0ustar samyaksamyaken: cats: zero: 'no cats' one: 'a cat' other: '%{count} cats' invalid: 'this is not a valid pluralization key'i18n-spec-0.6.0/spec/fixtures/missing_pluralization_keys.yml0000644000175000017500000000007013473263023023567 0ustar samyaksamyakru: cats: one: 'a cat' other: '%{count} cats' i18n-spec-0.6.0/spec/fixtures/unparseable.yml0000644000175000017500000000003413473263023020407 0ustar samyaksamyak: foo: bar:i18n-spec-0.6.0/spec/fixtures/not_subset.yml0000644000175000017500000000023113473263023020272 0ustar samyaksamyaken: dogs: zero: 'no dogs' one: 'one dog' other: '%{count} dogs' itteh: bitteh: ceiling: doggeh: 'is asking for trouble'i18n-spec-0.6.0/spec/spec_helper.rb0000644000175000017500000000054713473263023016341 0ustar samyaksamyak$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' require 'i18n-spec' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} RSpec.configure do |config| end i18n-spec-0.6.0/.document0000644000175000017500000000006713473263023014405 0ustar samyaksamyaklib/**/*.rb bin/* - features/**/*.feature LICENSE.txt i18n-spec-0.6.0/.rspec0000644000175000017500000000001013473263023013667 0ustar samyaksamyak--color i18n-spec-0.6.0/LICENSE.txt0000644000175000017500000000204413473263023014406 0ustar samyaksamyakCopyright (c) 2011 Christopher Dell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. i18n-spec-0.6.0/Gemfile0000644000175000017500000000026413473263023014060 0ustar samyaksamyaksource 'https://rubygems.org' gem "iso" group :development do gem "rspec", ">= 3" gem "bundler" gem "jeweler" gem "rdoc" gem "rcov", ">= 0" if RUBY_VERSION < '1.9' end i18n-spec-0.6.0/README.md0000644000175000017500000000420413473263023014042 0ustar samyaksamyak# i18n-spec [![Build Status](https://secure.travis-ci.org/tigrish/i18n-spec.png)](http://travis-ci.org/tigrish/i18n-spec) i18n-spec provides RSpec matchers for testing your locale files and their translations. ## Testing the validity of your locale files There are a few matchers available; the subject of the spec is always a path to a locale file. describe "config/locales/en.yml" do it { is_expected.to be_parseable } it { is_expected.to have_valid_pluralization_keys } it { is_expected.to_not have_missing_pluralization_keys } it { is_expected.to have_one_top_level_namespace } it { is_expected.to be_named_like_top_level_namespace } it { is_expected.to_not have_legacy_interpolations } it { is_expected.to have_a_valid_locale } end All of these tests can be ran in one line with a shared example : describe "A locale file" do it_behaves_like 'a valid locale file', 'config/locales/en.yml' end Even better, you can run all of these tests for every file in a directory like so : Dir.glob('config/locales/*.yml') do |locale_file| describe "a locale file" do it_behaves_like 'a valid locale file', locale_file end end ## Testing the validity of your translation data To test that your locale file is a subset of the default locale file describe "config/locales/fr.yml" do it { is_expected.to be_a_subset_of 'config/locales/en.yml' } end If you need to test that all translations have been completed : describe "config/locales/fr.yml" do it { is_expected.to be_a_complete_translation_of 'config/locales/en.yml' } end ## Rake tasks Include the tasks in your Rakefile with : require 'i18n-spec/tasks' ### Validating locale files You can check a locale file with the following task : rake i18n-spec:validate FILEPATH or check a whole directory : rake i18n-spec:validate DIRECTORY ### Checking for translation completeness You can check a locale file with the following taks : rake i18n-spec:completeness SOURCE_FILEPATH TRANSLATED_FILEPATH or again, check a whole directory : rake i18n-spec:completeness SOURCE_FILEPATH DIRECTORY i18n-spec-0.6.0/Rakefile0000644000175000017500000000256513473263023014240 0ustar samyaksamyak# encoding: utf-8 require 'rubygems' require 'bundler' begin Bundler.setup(:default, :development) rescue Bundler::BundlerError => e $stderr.puts e.message $stderr.puts "Run `bundle install` to install missing gems" exit e.status_code end require 'rake' require 'jeweler' Jeweler::Tasks.new do |gem| # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options gem.name = "i18n-spec" gem.homepage = "http://github.com/tigrish/i18n-spec" gem.license = "MIT" gem.summary = %Q{Matchers for specing locale files} gem.description = %Q{Includes a number of rspec matchers to make specing your locale files easy peasy.} gem.email = "chris@tigrish.com" gem.authors = ["Christopher Dell"] # dependencies defined in Gemfile end Jeweler::RubygemsDotOrgTasks.new require 'rspec/core' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) do |spec| spec.pattern = FileList['spec/**/*_spec.rb'] end RSpec::Core::RakeTask.new(:rcov) do |spec| spec.pattern = 'spec/**/*_spec.rb' spec.rcov = true end task :default => :spec require 'rdoc/task' Rake::RDocTask.new do |rdoc| version = File.exist?('VERSION') ? File.read('VERSION') : "" rdoc.rdoc_dir = 'rdoc' rdoc.title = "i18n-spec #{version}" rdoc.rdoc_files.include('README*') rdoc.rdoc_files.include('lib/**/*.rb') end Dir['tasks/**/*.rb'].map { |file| require file } i18n-spec-0.6.0/i18n-spec.gemspec0000644000175000017500000000625613473263023015650 0ustar samyaksamyak# Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- # stub: i18n-spec 0.6.0 ruby lib Gem::Specification.new do |s| s.name = "i18n-spec" s.version = "0.6.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"] s.authors = ["Christopher Dell"] s.date = "2014-10-27" s.description = "Includes a number of rspec matchers to make specing your locale files easy peasy." s.email = "chris@tigrish.com" s.extra_rdoc_files = [ "LICENSE.txt", "README.md" ] s.files = [ ".document", ".rspec", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "VERSION", "gemfiles/rspec_2.99.gemfile", "gemfiles/rspec_3.gemfile", "i18n-spec.gemspec", "lib/i18n-spec.rb", "lib/i18n-spec/failure_message.rb", "lib/i18n-spec/matchers/be_a_complete_translation_of_matcher.rb", "lib/i18n-spec/matchers/be_a_subset_of_matcher.rb", "lib/i18n-spec/matchers/be_named_like_top_level_namespace_matcher.rb", "lib/i18n-spec/matchers/be_parseable_matcher.rb", "lib/i18n-spec/matchers/have_a_valid_locale_matcher.rb", "lib/i18n-spec/matchers/have_legacy_interpolations.rb", "lib/i18n-spec/matchers/have_missing_pluralization_keys_matcher.rb", "lib/i18n-spec/matchers/have_one_top_level_namespace_matcher.rb", "lib/i18n-spec/matchers/have_valid_pluralization_keys_matcher.rb", "lib/i18n-spec/models/locale_file.rb", "lib/i18n-spec/shared_examples/valid_locale_file.rb", "lib/i18n-spec/tasks.rb", "spec/fixtures/en.yml", "spec/fixtures/es.yml", "spec/fixtures/fr.yml", "spec/fixtures/invalid_locale.yml", "spec/fixtures/invalid_pluralization_keys.yml", "spec/fixtures/legacy_interpolations.yml", "spec/fixtures/missing_pluralization_keys.yml", "spec/fixtures/multiple_top_levels.yml", "spec/fixtures/not_subset.yml", "spec/fixtures/unparseable.yml", "spec/lib/i18n-spec/matchers_spec.rb", "spec/lib/i18n-spec/models/locale_file_spec.rb", "spec/spec_helper.rb" ] s.homepage = "http://github.com/tigrish/i18n-spec" s.licenses = ["MIT"] s.rubygems_version = "2.2.2" s.summary = "Matchers for specing locale files" if s.respond_to? :specification_version then s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q, [">= 0"]) s.add_development_dependency(%q, [">= 3"]) s.add_development_dependency(%q, [">= 0"]) s.add_development_dependency(%q, [">= 0"]) s.add_development_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 3"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 3"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end end i18n-spec-0.6.0/gemfiles/0000755000175000017500000000000013473263023014356 5ustar samyaksamyaki18n-spec-0.6.0/gemfiles/rspec_2.99.gemfile0000644000175000017500000000016213473263023017504 0ustar samyaksamyaksource 'https://rubygems.org' gem 'bundler' gem 'iso' gem 'jeweler' gem 'rake' gem 'rdoc' gem 'rspec', '~> 2.99' i18n-spec-0.6.0/gemfiles/rspec_3.gemfile0000644000175000017500000000016113473263023017244 0ustar samyaksamyaksource 'https://rubygems.org' gem 'bundler' gem 'iso' gem 'jeweler' gem 'rake' gem 'rdoc' gem 'rspec', '~> 3.0'