Skip to content

Commit

Permalink
update to csl-ruby stable release
Browse files Browse the repository at this point in the history
add citation-format style-class tests

to run the tests please run 'bundle install' first
  • Loading branch information
inukshuk committed Apr 27, 2013
1 parent 95a2900 commit f49fce9
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ gem 'rake'
gem 'rspec'
gem 'fuubar'
gem 'nokogiri'
gem 'csl', '1.0.0.pre11'
gem 'csl', '~>1.0'
36 changes: 18 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
GEM
remote: https://rubygems.org/
specs:
csl (1.0.0.pre11)
namae (~> 0.3)
diff-lcs (1.1.3)
fuubar (1.0.0)
csl (1.0.0)
namae (~> 0.7)
diff-lcs (1.2.4)
fuubar (1.1.0)
rspec (~> 2.0)
rspec-instafail (~> 0.2.0)
ruby-progressbar (~> 0.0.10)
ruby-progressbar (~> 1.0.0)
namae (0.7.1)
nokogiri (1.5.5)
nokogiri (1.5.5-x86-mingw32)
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)
nokogiri (1.5.9)
nokogiri (1.5.9-x86-mingw32)
rake (10.0.4)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-instafail (0.2.4)
rspec-mocks (2.11.3)
ruby-progressbar (0.0.10)
rspec-mocks (2.13.1)
ruby-progressbar (1.0.2)

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
csl (= 1.0.0.pre11)
csl (~> 1.0)
fuubar
nokogiri
rake
Expand Down
2 changes: 1 addition & 1 deletion spec/dependent_styles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
end

it "is licensed under a CC BY-SA license" do
(style.info.rights.text == 'This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License' && style.info.rights[:license].should == 'http://creativecommons.org/licenses/by-sa/3.0/').should be_true
style.should be_default_license
end

it "its independent-parent link points to an existing style" do
Expand Down
20 changes: 16 additions & 4 deletions spec/independent_styles_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Independents.each_pair do |id, (filename, path, style)|

describe "independent style #{id}" do

it "is a valid CSL 1.0 style" do
CSL.validate(path).should == []
end
Expand Down Expand Up @@ -44,7 +44,7 @@
end

it "is licensed under a CC BY-SA license" do
(style.info.rights.text == 'This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License' && style.info.rights[:license].should == 'http://creativecommons.org/licenses/by-sa/3.0/').should be_true
style.should be_default_license
end

it "its template-link (if present) points to an existing independent style" do
Expand All @@ -56,7 +56,7 @@
end
end

unless %w{ all bibtex blank national-archives-of-australia }.include?(id)
unless CITATION_FORMAT_FILTER.include?(id)
it "has at least one info/category" do
style.info.should have_categories
end
Expand All @@ -68,6 +68,18 @@
it "its citation-format is valid" do
style.citation_format.to_s.should match(/^author(-date)?|numeric|label|note/)
end

it "has a valid class attribute" do
style[:class].to_s.should match(/^(note|in-text)$/)
end

it "its class attribute corresponds to the citation-format" do
if style.citation_format == :note
style[:class].should == 'note'
else
style[:class].should == 'in-text'
end
end
end

it "defines all macros that are referenced by text or key nodes" do
Expand All @@ -76,7 +88,7 @@
style.macros.should have_key(node[:macro])
end
end
end
end
end

end
Expand Down
2 changes: 1 addition & 1 deletion spec/repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
it "contains no duplicate style titles" do
TITLES.select { |_, styles| styles.length > 1 }.should == {}
end

it "contains no extra files" do
EXTRA_FILES.should == []
end
Expand Down
16 changes: 13 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,27 @@
# 'example title 2'
]

# These styles are ignored when checking for valid citation-formats
CITATION_FORMAT_FILTER = %w{
all bibtex blank national-archives-of-australia
}

# These files are ignored when checking for extra files
EXTRA_FILES_FILTER = [
'CONTRIBUTING.md', 'Gemfile', 'Gemfile.lock', 'README.md',
'dependent', 'Rakefile', 'spec', 'spec_helper.rb', /_spec\.rb$/, 'renamed-styles.json'
'dependent', 'Rakefile', 'spec', 'spec_helper.rb', /_spec\.rb$/,
'renamed-styles.json'
]

EXTRA_FILES = Dir[File.join(STYLE_ROOT, '**', '*')].reject do |file|
name = File.basename(file)
name = File.basename(file)
File.extname(file) == '.csl' || EXTRA_FILES_FILTER.any? { |f| f === name }
end

CSL::Schema.default_license = 'http://creativecommons.org/licenses/by-sa/3.0/'
CSL::Schema.default_rights_string =
'This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License'

def load_style(path)
filename = File.basename(path)
id = filename[0..-5]
Expand All @@ -53,7 +63,7 @@ def load_style(path)
end

if style.has_title?
title = style.title.to_s.downcase
title = style.title.to_s.downcase
TITLES[title] << id unless TITLES_FILTER.include?(title)
end
rescue
Expand Down

0 comments on commit f49fce9

Please sign in to comment.