Permalink
Please sign in to comment.
Showing
with
141 additions
and 0 deletions.
- +3 −0 .rspec
- +10 −0 .travis.yml
- +7 −0 Gemfile
- +33 −0 Gemfile.lock
- +17 −0 Rakefile
- +45 −0 spec/locales_spec.rb
- +26 −0 spec/spec_helper.rb
@@ -0,0 +1,3 @@ | ||
--format Fuubar | ||
--color | ||
--require spec_helper.rb |
@@ -0,0 +1,10 @@ | ||
language: ruby | ||
rvm: | ||
- 1.9.3 | ||
notifications: | ||
email: | ||
recipients: | ||
- rintze.zelle@gmail.com | ||
- sylvester@keil.or.at | ||
on_success: change | ||
on_failure: always |
@@ -0,0 +1,7 @@ | ||
source :rubygems | ||
gem 'rake' | ||
gem 'rspec' | ||
gem 'fuubar' | ||
gem 'nokogiri' | ||
gem 'csl', '1.0.0.pre9' |
@@ -0,0 +1,33 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
csl (1.0.0.pre9) | ||
namae (~> 0.3) | ||
diff-lcs (1.1.3) | ||
fuubar (1.0.0) | ||
rspec (~> 2.0) | ||
rspec-instafail (~> 0.2.0) | ||
ruby-progressbar (~> 0.0.10) | ||
namae (0.3.0) | ||
nokogiri (1.5.5) | ||
rake (0.9.2.2) | ||
rspec (2.11.0) | ||
rspec-core (~> 2.11.0) | ||
rspec-expectations (~> 2.11.0) | ||
rspec-mocks (~> 2.11.0) | ||
rspec-core (2.11.1) | ||
rspec-expectations (2.11.3) | ||
diff-lcs (~> 1.1.3) | ||
rspec-instafail (0.2.4) | ||
rspec-mocks (2.11.2) | ||
ruby-progressbar (0.0.10) | ||
PLATFORMS | ||
ruby | ||
DEPENDENCIES | ||
csl (= 1.0.0.pre9) | ||
fuubar | ||
nokogiri | ||
rake | ||
rspec |
@@ -0,0 +1,17 @@ | ||
require 'bundler' | ||
begin | ||
Bundler.setup | ||
rescue Bundler::BundlerError => e | ||
$stderr.puts e.message | ||
$stderr.puts "Run `bundle install' to install missing gems" | ||
exit e.status_code | ||
end | ||
require 'rspec/core' | ||
require 'rspec/core/rake_task' | ||
RSpec::Core::RakeTask.new(:spec) do |spec| | ||
spec.rspec_opts = %w{ --require spec_helper.rb --format Fuubar --color } | ||
end | ||
task :default => [:spec] |
@@ -0,0 +1,45 @@ | ||
Locales.each_pair do |id, (filename, path, locale)| | ||
describe "#{id}" do | ||
it "is a valid CSL 1.0.1 locale" do | ||
CSL.validate(path).should == [] | ||
end | ||
it "has a conventional file name" do | ||
filename.should match(/^locales-[a-z]{2}-[A-Z]{2}\.xml$/) | ||
end | ||
it "was successfully parsed" do | ||
locale.should be_a(CSL::Locale) | ||
end | ||
unless locale.nil? | ||
it "has an info element" do | ||
locale.should have_info | ||
end | ||
it "has a language" do | ||
locale.language.should_not be_empty | ||
end | ||
it "has a region" do | ||
locale.region.should_not be_empty | ||
end | ||
it "its language and region match the filename" do | ||
locale.to_s.should == id[8,5] | ||
end | ||
it "has and info/rights element" do | ||
locale.info.should have_rights | ||
end | ||
it "is licensed under a CC BY-SA license" do | ||
locale.info.rights.to_s.strip.should =~ | ||
/^This work is licensed under a Creative Commons Attribution-ShareAlike 3\.0 License(: http:\/\/creativecommons\.org\/licenses\/by-sa\/3\.0\/)?$/ | ||
end | ||
end | ||
end | ||
end |
@@ -0,0 +1,26 @@ | ||
require 'csl' | ||
LOCALE_ROOT = File.expand_path('../..', __FILE__) | ||
def load_locale(path) | ||
filename = File.basename(path) | ||
id = filename[0..-5] | ||
begin | ||
locale = CSL::Locale.load(path) | ||
rescue | ||
# failed to parse the locale. we'll report the error later | ||
end | ||
[id, [filename, path, locale]] | ||
end | ||
print "\nLoading locales" | ||
Locales = Hash[Dir[File.join(LOCALE_ROOT, '*.xml')].each_with_index.map { |path, i| | ||
print '.' if i % 5 == 0 | ||
load_locale(path) | ||
}] | ||
puts |
0 comments on commit
89a7635