Skip to content

Commit 4585363

Browse files
committedDec 21, 2010
modernise packaging
* use bundler to manage the load path during development * upgrade to rspec 2.x
1 parent 9536503 commit 4585363

32 files changed

+170
-195
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pkg
2+
Gemfile.lock

‎Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source :gemcutter
2+
3+
gemspec

‎Rakefile

+10-61
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
begin
2-
require 'spec'
3-
rescue LoadError
4-
require 'rubygems'
5-
require 'spec'
6-
end
1+
require "rubygems"
2+
require "bundler"
3+
Bundler.setup
74

5+
require 'rake'
86
require 'rake/rdoctask'
9-
require 'spec/rake/spectask'
10-
require 'rake/gempackagetask'
11-
12-
# allow require of spec/spec_helper
13-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/lib'
7+
require 'rspec/core/rake_task'
148

15-
require 'onix'
169

1710
desc "Default Task"
1811
task :default => [ :spec ]
1912

13+
# run all rspecs
14+
desc "Run all rspec files"
15+
RSpec::Core::RakeTask.new("spec") do |t|
16+
t.rspec_opts = ["--color", "--format progress"]
17+
end
2018
desc 'Generate documentation'
2119
Rake::RDocTask.new(:rdoc) do |rdoc|
2220
rdoc.rdoc_dir = 'rdoc'
@@ -27,52 +25,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
2725
rdoc.rdoc_files.include('CHANGELOG')
2826
rdoc.rdoc_files.include('lib/**/*.rb')
2927
end
30-
31-
desc "Run the specs under spec"
32-
Spec::Rake::SpecTask.new do |t|
33-
t.spec_files = FileList['spec/**/*_spec.rb']
34-
end
35-
36-
desc "Generate RCov reports"
37-
Spec::Rake::SpecTask.new(:rcov) do |t|
38-
t.libs << 'lib'
39-
t.spec_files = FileList['spec/**/*_spec.rb']
40-
t.spec_opts = ['-c']
41-
t.rcov = true
42-
t.rcov_opts = ['--exclude', 'spec', '--exclude', 'gems', '--exclude', 'riddle']
43-
end
44-
45-
spec = Gem::Specification.new do |s|
46-
s.name = "onix"
47-
s.version = ONIX::Version::String
48-
s.summary = "A convient mapping between ruby objects and the ONIX XML specification"
49-
s.description = "A convient mapping between ruby objects and the ONIX XML specification"
50-
s.author = "James Healy"
51-
s.email = "jimmy@deefa.com"
52-
s.has_rdoc = true
53-
s.rubyforge_project = "rbook"
54-
s.homepage = "http://github.com/yob/onix/tree/master"
55-
s.rdoc_options << "--title" << "ONIX - Working with the ONIX XML spec" <<
56-
"--line-numbers"
57-
s.test_files = FileList["spec/**/*.rb"]
58-
s.files = FileList[
59-
"lib/**/*.rb",
60-
"README.markdown",
61-
"TODO",
62-
"CHANGELOG",
63-
"tasks/**/*.rb",
64-
"tasks/**/*.rake",
65-
"dtd/**/*.*",
66-
"support/**/*.*",
67-
"spec/**/*.*"
68-
]
69-
s.add_dependency('roxml', '>=3.1.6')
70-
s.add_dependency('andand')
71-
s.add_dependency('nokogiri', '>=1.4')
72-
end
73-
74-
Rake::GemPackageTask.new(spec) do |p|
75-
p.gem_spec = spec
76-
p.need_tar = true
77-
p.need_zip = true
78-
end

‎onix.gemspec

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Gem::Specification.new do |s|
2+
s.name = "onix"
3+
s.version = "0.8.4"
4+
s.summary = "A convient mapping between ruby objects and the ONIX XML specification"
5+
s.description = "A convient mapping between ruby objects and the ONIX XML specification"
6+
s.authors = ["James Healy"]
7+
s.email = ["jimmy@deefa.com"]
8+
s.has_rdoc = true
9+
s.homepage = "http://github.com/yob/onix"
10+
s.rdoc_options << "--title" << "ONIX - Working with the ONIX XML spec" <<
11+
"--line-numbers"
12+
s.test_files = Dir.glob("spec/**/*.rb")
13+
s.files = Dir.glob("{lib/support/dtd}/**/*") + ["README.markdown", "TODO", "CHANGELOG"]
14+
15+
s.add_dependency('yob-roxml', '>=3.1.6')
16+
s.add_dependency('activesupport', '< 3.0')
17+
s.add_dependency('andand')
18+
s.add_dependency('nokogiri', '>=1.4')
19+
20+
s.add_development_dependency("rake")
21+
s.add_development_dependency("rspec", "~>2.1")
22+
end
23+

‎spec/apa_product_spec.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require File.dirname(__FILE__) + '/spec_helper.rb'
44
require 'date'
55

6-
context "ONIX::APAProduct" do
6+
describe "ONIX::APAProduct" do
77

88
before(:each) do
99
@data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -12,7 +12,7 @@
1212
@product_node = @doc.root
1313
end
1414

15-
specify "should provide read access to attributes" do
15+
it "should provide read access to attributes" do
1616
@product = ONIX::Product.from_xml(@product_node.to_s)
1717
@apa = ONIX::APAProduct.new(@product)
1818

@@ -26,7 +26,7 @@
2626
@apa.pack_quantity.should eql(12)
2727
end
2828

29-
specify "should provide write access to attributes" do
29+
it "should provide write access to attributes" do
3030
apa = ONIX::APAProduct.new
3131

3232
apa.notification_type = 3
@@ -56,8 +56,8 @@
5656

5757
end
5858

59-
context ONIX::APAProduct, "series method" do
60-
specify "should set the nested series value on the underlying product class" do
59+
describe ONIX::APAProduct, "series method" do
60+
it "should set the nested series value on the underlying product class" do
6161
apa = ONIX::APAProduct.new
6262

6363
apa.series = "Harry Potter"
@@ -66,31 +66,31 @@
6666
end
6767
end
6868

69-
context ONIX::APAProduct, "price method" do
69+
describe ONIX::APAProduct, "price method" do
7070
before(:each) do
7171
@data_path = File.join(File.dirname(__FILE__),"..","data")
7272
file1 = File.join(@data_path, "usd.xml")
7373
@doc = Nokogiri::XML::Document.parse(File.read(file1))
7474
@product_node = @doc.root
7575
end
7676

77-
specify "should return the first price in the file, regardless of type" do
77+
it "should return the first price in the file, regardless of type" do
7878
@product = ONIX::Product.from_xml(@product_node.to_s)
7979
@apa = ONIX::APAProduct.new(@product)
8080

8181
@apa.price.should eql(BigDecimal.new("99.95"))
8282
end
8383
end
8484

85-
context ONIX::APAProduct, "rrp_exc_sales_tax method" do
85+
describe ONIX::APAProduct, "rrp_exc_sales_tax method" do
8686
before(:each) do
8787
@data_path = File.join(File.dirname(__FILE__),"..","data")
8888
file1 = File.join(@data_path, "usd.xml")
8989
@doc = Nokogiri::XML::Document.parse(File.read(file1))
9090
@product_node = @doc.root
9191
end
9292

93-
specify "should return the first price in the file of type 1" do
93+
it "should return the first price in the file of type 1" do
9494
@product = ONIX::Product.from_xml(@product_node.to_s)
9595
@apa = ONIX::APAProduct.new(@product)
9696

‎spec/audience_range_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require File.dirname(__FILE__) + '/spec_helper.rb'
44

5-
context "ONIX::AudienceRange" do
5+
describe ONIX::AudienceRange do
66

77
before(:each) do
88
data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@
1111
@root = @doc.root
1212
end
1313

14-
specify "should correctly convert to a string" do
14+
it "should correctly convert to a string" do
1515
aud = ONIX::AudienceRange.from_xml(@root.to_s)
1616
aud.to_xml.to_s[0,15].should eql("<AudienceRange>")
1717
end
1818

19-
specify "should provide read access to first level attributes" do
19+
it "should provide read access to first level attributes" do
2020
aud = ONIX::AudienceRange.from_xml(@root.to_s)
2121

2222
aud.audience_range_qualifier.should eql(11)
@@ -28,7 +28,7 @@
2828
aud.audience_range_values[1].should eql(5)
2929
end
3030

31-
specify "should provide write access to first level attributes" do
31+
it "should provide write access to first level attributes" do
3232
aud = ONIX::AudienceRange.new
3333

3434
aud.audience_range_qualifier = 12

‎spec/contributor_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require File.dirname(__FILE__) + '/spec_helper.rb'
44

5-
context "ONIX::Contributor" do
5+
describe ONIX::Contributor do
66

77
before(:each) do
88
data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,20 +11,20 @@
1111
@root = @doc.root
1212
end
1313

14-
specify "should correctly convert to a string" do
14+
it "should correctly convert to a string" do
1515
header = ONIX::Contributor.from_xml(@root.to_s)
1616
header.to_xml.to_s[0,13].should eql("<Contributor>")
1717
end
1818

19-
specify "should provide read access to first level attributes" do
19+
it "should provide read access to first level attributes" do
2020
contrib = ONIX::Contributor.from_xml(@root.to_s)
2121

2222
contrib.contributor_role.should eql("A01")
2323
contrib.person_name_inverted.should eql("SHAPIRO")
2424
contrib.sequence_number.should eql(1)
2525
end
2626

27-
specify "should provide write access to first level attributes" do
27+
it "should provide write access to first level attributes" do
2828
contrib = ONIX::Contributor.new
2929

3030
contrib.contributor_role = "A02"

‎spec/header_spec.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require File.dirname(__FILE__) + '/spec_helper.rb'
44

5-
context "ONIX::Header" do
5+
describe ONIX::Header do
66

77
before(:each) do
88
data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@
1111
@header_node = @doc.root
1212
end
1313

14-
specify "should correctly convert to a string" do
14+
it "should correctly convert to a string" do
1515
header = ONIX::Header.from_xml(@header_node.to_s)
1616
header.to_xml.to_s[0,8].should eql("<Header>")
1717
end
1818

19-
specify "should provide read access to first level attributes" do
19+
it "should provide read access to first level attributes" do
2020
header = ONIX::Header.from_xml(@header_node.to_s)
2121

2222
header.from_ean_number.should eql("1111111111111")
@@ -42,7 +42,7 @@
4242
header.default_class_of_trade.should eql("f")
4343
end
4444

45-
specify "should provide write access to first level attributes" do
45+
it "should provide write access to first level attributes" do
4646
header = ONIX::Header.new
4747

4848
header.from_ean_number = "1111111111111"
@@ -95,7 +95,7 @@
9595
header.to_xml.to_s.include?("<DefaultClassOfTrade>f</DefaultClassOfTrade>").should be_true
9696
end
9797

98-
specify "should correctly handle text with & < and >" do
98+
it "should correctly handle text with & < and >" do
9999
header = ONIX::Header.new
100100

101101
header.from_company = "James & Healy"
@@ -109,9 +109,9 @@
109109
end
110110
end
111111

112-
context "ONIX::Header" do
112+
describe ONIX::Header do
113113

114-
specify "should correctly handle headers with an invalid sent date" do
114+
it "should correctly handle headers with an invalid sent date" do
115115
data_path = File.join(File.dirname(__FILE__),"..","data")
116116
file = File.join(data_path, "header_invalid_sentdate.xml")
117117
header = ONIX::Header.from_xml(File.read(file))

‎spec/imprint_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require File.dirname(__FILE__) + '/spec_helper.rb'
44

5-
context "ONIX::Imprint" do
5+
describe ONIX::Imprint do
66

77
before(:each) do
88
data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,18 +11,18 @@
1111
@root = @doc.root
1212
end
1313

14-
specify "should correctly convert to a string" do
14+
it "should correctly convert to a string" do
1515
imp = ONIX::Imprint.from_xml(@root.to_s)
1616
imp.to_xml.to_s[0,9].should eql("<Imprint>")
1717
end
1818

19-
specify "should provide read access to first level attributes" do
19+
it "should provide read access to first level attributes" do
2020
imp = ONIX::Imprint.from_xml(@root.to_s)
2121

2222
imp.imprint_name.should eql("Oxford University Press UK")
2323
end
2424

25-
specify "should provide write access to first level attributes" do
25+
it "should provide write access to first level attributes" do
2626
imp = ONIX::Imprint.new
2727

2828
imp.imprint_name = "Paulist Press"

‎spec/language_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require File.dirname(__FILE__) + '/spec_helper.rb'
44

5-
context "ONIX::Language" do
5+
describe ONIX::Language do
66

77
before(:each) do
88
data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,20 +11,20 @@
1111
@root = @doc.root
1212
end
1313

14-
specify "should correctly convert to a string" do
14+
it "should correctly convert to a string" do
1515
lan = ONIX::Language.from_xml(@root.to_s)
1616
lan.to_xml.to_s[0,10].should eql("<Language>")
1717
end
1818

19-
specify "should provide read access to first level attributes" do
19+
it "should provide read access to first level attributes" do
2020
lan = ONIX::Language.from_xml(@root.to_s)
2121

2222
lan.language_role.should eql(1)
2323
lan.language_code.should eql("eng")
2424
lan.country_code.should eql("US")
2525
end
2626

27-
specify "should provide write access to first level attributes" do
27+
it "should provide write access to first level attributes" do
2828
lan = ONIX::Language.new
2929

3030
lan.language_role = 2

0 commit comments

Comments
 (0)
Please sign in to comment.