csv_pirate 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ Version 5.0.0 2011-06-14
2
+ - Added .txt extension to CHANGELOG and LINCENSE
3
+ - Improved dependency declarations in Gemfile (removed from Rakefile/gemspec)
4
+
1
5
  Version 5.0.0 2011-06-13
2
6
  - Ruby 1.9.2p136 compatible
3
7
  - Rails 3.0.x compatible
data/Gemfile CHANGED
@@ -1,12 +1,14 @@
1
1
  source :rubygems
2
2
 
3
- gemspec
4
-
5
3
  #FasterCSV became the built-in CSV library in Ruby 1.9, so is only required if using Ruby 1.8
6
4
  if RUBY_VERSION =~ /^1\.8\.\d{1}$/
7
5
  gem 'fastercsv', '~> 1.5'
8
6
  end
9
7
 
10
- group :test do
8
+ group :development do
11
9
  gem 'rspec', '~> 2.6'
10
+ gem "shoulda", ">= 0"
11
+ gem "bundler", "~> 1.0.0"
12
+ gem "jeweler", "~> 1.6.2"
13
+ gem "rcov", ">= 0"
12
14
  end
File without changes
data/README.rdoc CHANGED
@@ -45,15 +45,6 @@ Avast! Here be pirates! To brush up on pirate coding naming conventions:
45
45
 
46
46
  http://www.privateerdragons.com/pirate_dictionary.html
47
47
 
48
- == New for version 4.x... Importing to DB or Ruby objects in memory from CSV
49
-
50
- Importing abilities are now here! You can dump data to CSV, copy the CSV to wherever, and then import the data in the CSV. Works very well with ActiveRecord.
51
-
52
- See the weigh_anchor method, added to models with has_csv_pirate_ship defined, for dumping.
53
- See the raise_anchor method, added to models with has_csv_pirate_ship defined, for importing.
54
- See the to_memory method to convert the data in a csv or CsvPirate instance object back into Ruby class instances
55
- with as many attributes as possible set equal to the data from the CSV.
56
-
57
48
  == On The Web
58
49
 
59
50
  Source:
@@ -65,10 +56,6 @@ Release Announcement:
65
56
 
66
57
  == Install as a RubyGem
67
58
 
68
- Gemcutter is the hot new gem host, and you can use it like this (see http://gemcutter.org):
69
-
70
- [sudo] gem install gemcutter
71
- [sudo] gem tumble # makes gemcutter gem source first in line
72
59
  [sudo] gem install csv_pirate
73
60
 
74
61
  Gem Using Git building from source:
@@ -78,7 +65,7 @@ Gem Using Git building from source:
78
65
  git clone git://github.com/pboling/csv_pirate.git
79
66
  cd csv_pirate
80
67
  gem build csv_pirate.gemspec
81
- sudo gem install csv_pirate-3.4.4.gem # (Or whatever version gets built)
68
+ sudo gem install csv_pirate-5.0.1.gem # (Or whatever version gets built)
82
69
 
83
70
  Then in your environment.rb (if you are just going to use it from the console, you can require it as needed there, and skip the config.gem):
84
71
 
@@ -117,6 +104,15 @@ What's the simplest thing that will work?
117
104
  MyClass.walk_the_plank # creates the csv, and returns contents of the exported data (that was written into the csv) (as a string)
118
105
  MyClass.land_ho # Does Not create the csv, sets up the CsvPirate instance. You can manipulate it and then call .hoist_mainstay on it to create the csv
119
106
 
107
+ == Importing to DB or Ruby objects in memory from CSV
108
+
109
+ Importing abilities are now here! You can dump data to CSV, copy the CSV to wherever, and then import the data in the CSV. Works very well with ActiveRecord.
110
+
111
+ See the weigh_anchor method, added to models with has_csv_pirate_ship defined, for dumping.
112
+ See the raise_anchor method, added to models with has_csv_pirate_ship defined, for importing.
113
+ See the to_memory method to convert the data in a csv or CsvPirate instance object back into Ruby class instances
114
+ with as many attributes as possible set equal to the data from the CSV.
115
+
120
116
  == Usage without ActiveRecord
121
117
 
122
118
  [ See Spec Tests for more Examples! ]
@@ -444,12 +440,24 @@ if you need to export the id field.
444
440
  Micrsoft... I loathe you.
445
441
  http://www.bradino.com/misc/sylk-file-format-is-not-valid/
446
442
 
443
+ == Contributing to CsvPirate
444
+
445
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
446
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
447
+ * Fork the project
448
+ * Start a feature/bugfix branch
449
+ * Commit and push until you are happy with your contribution
450
+ * Make sure to add tests, rspec preferred, for it. This is important so I don't break it in a future version unintentionally.
451
+ * Please try not to mess with the Rakefile, version, or change log. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
452
+
453
+
447
454
  == Thanks
448
455
 
449
- Thanks go to
450
- 9thBit LLC (http://www.9thBit.net)
451
- Sagebit LLC (http://www.sagebit.com) - Sagebit has been very supportive of my open source efforts, thanks Ben!
452
- TimePerks LLC (http://www.timeperks.com) - Many useful enhancements were requested and paid for by TimePerks
456
+ Thanks go to:
457
+
458
+ * 9thBit LLC (http://www.9thBit.net) - Peter Boling, author of CsvPirate, runs the joint.
459
+ * Sagebit LLC (http://www.sagebit.com) - Sagebit has been very supportive of my open source efforts, thanks Ben!
460
+ * TimePerks LLC (http://www.timeperks.com) - Many useful enhancements were requested and paid for by TimePerks
453
461
 
454
462
  ----------------------------------------------------------------------------------
455
463
  Author: Peter Boling, peter.boling at gmail dot com
data/Rakefile CHANGED
@@ -1,6 +1,14 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
1
+ # encoding: utf-8
3
2
 
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
4
12
  require 'rake'
5
13
 
6
14
  begin
@@ -23,26 +31,28 @@ It works better if you are wearing a tricorne!}
23
31
  "lib/csv_pirate/version.rb",
24
32
  "spec/csv_pirate_spec.rb",
25
33
  "spec/pirate_ship_spec.rb",
34
+ "spec/the_capn_spec.rb",
26
35
  "spec/spec.opts",
27
36
  "spec/spec_helper.rb",
28
37
  "spec/spec_helpers/glowing_gas_ball.rb",
29
38
  "spec/spec_helpers/star.rb",
30
39
  "Rakefile",
31
40
  "Gemfile",
32
- "LICENSE",
33
- "CHANGELOG",
41
+ "LICENSE.txt",
42
+ "CHANGELOG.txt",
34
43
  "VERSION.yml"]
35
44
  end
36
- Jeweler::GemcutterTasks.new
45
+ Jeweler::RubygemsDotOrgTasks.new
37
46
  rescue LoadError
38
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
47
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
39
48
  end
40
49
 
41
50
  require 'rake/rdoctask'
42
51
  Rake::RDocTask.new do |rdoc|
52
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
53
+
43
54
  rdoc.rdoc_dir = 'rdoc'
44
- rdoc.title = 'csv_pirate'
45
- rdoc.options << '--line-numbers' << '--inline-source'
55
+ rdoc.title = "csv_pirate2 #{version}"
46
56
  rdoc.rdoc_files.include('README*')
47
57
  rdoc.rdoc_files.include('lib/**/*.rb')
48
58
  end
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 5
3
3
  :minor: 0
4
- :patch: 0
4
+ :patch: 1
5
5
  :build:
data/csv_pirate.gemspec CHANGED
@@ -5,22 +5,22 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{csv_pirate}
8
- s.version = "5.0.0"
8
+ s.version = "5.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Peter Boling"]
12
- s.date = %q{2011-06-14}
12
+ s.date = %q{2011-06-15}
13
13
  s.description = %q{CsvPirate is the easy way to create a CSV of essentially anything in Ruby, in full pirate regalia.
14
14
  It works better if you are wearing a tricorne!}
15
15
  s.email = %q{peter.boling@gmail.com}
16
16
  s.extra_rdoc_files = [
17
- "LICENSE",
17
+ "LICENSE.txt",
18
18
  "README.rdoc"
19
19
  ]
20
20
  s.files = [
21
- "CHANGELOG",
21
+ "CHANGELOG.txt",
22
22
  "Gemfile",
23
- "LICENSE",
23
+ "LICENSE.txt",
24
24
  "README.rdoc",
25
25
  "Rakefile",
26
26
  "VERSION.yml",
@@ -36,6 +36,7 @@ It works better if you are wearing a tricorne!}
36
36
  "spec/spec_helper.rb",
37
37
  "spec/spec_helpers/glowing_gas_ball.rb",
38
38
  "spec/spec_helpers/star.rb",
39
+ "spec/the_capn_spec.rb",
39
40
  "uninstall.rb"
40
41
  ]
41
42
  s.homepage = %q{http://github.com/pboling/csv_pirate}
@@ -47,12 +48,24 @@ It works better if you are wearing a tricorne!}
47
48
  s.specification_version = 3
48
49
 
49
50
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
- s.add_runtime_dependency(%q<csv_pirate>, [">= 0"])
51
+ s.add_development_dependency(%q<rspec>, ["~> 2.6"])
52
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
53
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
55
+ s.add_development_dependency(%q<rcov>, [">= 0"])
51
56
  else
52
- s.add_dependency(%q<csv_pirate>, [">= 0"])
57
+ s.add_dependency(%q<rspec>, ["~> 2.6"])
58
+ s.add_dependency(%q<shoulda>, [">= 0"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
61
+ s.add_dependency(%q<rcov>, [">= 0"])
53
62
  end
54
63
  else
55
- s.add_dependency(%q<csv_pirate>, [">= 0"])
64
+ s.add_dependency(%q<rspec>, ["~> 2.6"])
65
+ s.add_dependency(%q<shoulda>, [">= 0"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
+ s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
68
+ s.add_dependency(%q<rcov>, [">= 0"])
56
69
  end
57
70
  end
58
71
 
@@ -1,6 +1,6 @@
1
1
  module CsvPirate
2
2
 
3
- @@conf = YAML::load( File.read('VERSION.yml') )
3
+ @@conf = YAML::load( File.read( File.absolute_path('VERSION.yml') ) )
4
4
 
5
5
  MAJOR = @@conf[:major]
6
6
  MINOR = @@conf[:minor]
@@ -1,218 +1,32 @@
1
1
  require 'spec_helper' #here in this same config/ dir
2
2
 
3
- describe "CsvPirate" do
4
- describe "#initialize" do
5
- before(:each) do
6
- @csv_pirate = CsvPirate::TheCapn.new({
7
- :grub => GlowingGasBall,
8
- :spyglasses => [:get_stars],
9
- :chart => ["spec","csv","GlowingGasBall"],
10
- :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
11
- :chronometer => false,
12
- :gibbet => "",
13
- :aft => ".csv",
14
- :swab => :none,
15
- :mop => :clean,
16
- :waggoner => 'data'
17
- })
18
- end
19
-
20
- it "should return an instance of CsvPirate" do
21
- @csv_pirate.class.should == CsvPirate::TheCapn
22
- end
23
-
24
- it "should not export anything" do
25
- @csv_pirate.maroon.should == ""
26
- end
27
- end
28
-
29
- describe "#create" do
30
- before(:each) do
31
- @csv_pirate = CsvPirate::TheCapn.create({
32
- :grub => GlowingGasBall,
33
- :spyglasses => [:get_stars],
34
- :chart => ["spec","csv","GlowingGasBall"],
35
- :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
36
- :chronometer => false,
37
- :gibbet => "",
38
- :aft => ".csv",
39
- :swab => :none,
40
- :mop => :clean,
41
- :waggoner => 'data'
42
- })
43
- end
44
-
45
- it "should return an instance of CsvPirate" do
46
- @csv_pirate.class.should == CsvPirate::TheCapn
47
- end
48
-
49
- it "should store export in maroon instance variable" do
50
- @csv_pirate.maroon[0..100].should ==
51
- "Name,Distance,Spectral type,Name hash,Name next,Name upcase,Star vowels\nProxima Centauri,4.2 LY,M5.5V"
52
- end
53
- end
54
-
55
-
56
- describe "#create with function-arg booty" do
57
- before(:each) do
58
- @csv_pirate = CsvPirate::TheCapn.create({
59
- :grub => GlowingGasBall,
60
- :spyglasses => [:get_stars],
61
- :chart => ["spec","csv","GlowingGasBall"],
62
- :booty => [[:sub_name, 'a', 'Z'], :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
63
- :chronometer => false,
64
- :gibbet => "",
65
- :aft => ".csv",
66
- :swab => :none,
67
- :mop => :clean,
68
- :waggoner => 'data'
69
- })
70
- end
71
-
72
- it "should call instance functions with arguments an instance of CsvPirate" do
73
- @csv_pirate.maroon.should =~ /ProximZ CentZuri/
3
+ describe CsvPirate do
4
+ describe "VERSION" do
5
+ it "should be a string" do
6
+ CsvPirate::VERSION.class.should == String
74
7
  end
75
8
  end
76
-
77
-
78
- describe "#hoist_mainstay" do
79
- before(:each) do
80
- @csv_pirate = CsvPirate::TheCapn.new({
81
- :grub => GlowingGasBall,
82
- :spyglasses => [:get_stars],
83
- :chart => ["spec","csv","GlowingGasBall"],
84
- :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
85
- :chronometer => false,
86
- :gibbet => "",
87
- :aft => ".csv",
88
- :swab => :none,
89
- :mop => :clean,
90
- :waggoner => 'data'
91
- })
92
- end
93
-
94
- it "should return an instance of String" do
95
- @csv_pirate.hoist_mainstay.class.should == String
96
- end
97
-
98
- it "should return the export as a string" do
99
- @csv_pirate.hoist_mainstay[0..100].should == "Name,Distance,Spectral type,Name hash,Name next,Name upcase,Star vowels\nProxima Centauri,4.2 LY,M5.5V"
100
- end
101
-
102
- it "should store export in maroon instance variable" do
103
- @csv_pirate.maroon.should == ""
104
- @csv_pirate.hoist_mainstay
105
- @csv_pirate.maroon[0..100].should == "Name,Distance,Spectral type,Name hash,Name next,Name upcase,Star vowels\nProxima Centauri,4.2 LY,M5.5V"
9
+ describe "MAJOR" do
10
+ it "should be a string" do
11
+ CsvPirate::MAJOR.class.should == Fixnum
12
+ CsvPirate::MAJOR.should_not == ''
106
13
  end
107
14
  end
108
-
109
- describe "#old_csv_dump" do
110
-
111
- before(:each) do
112
- ["1/1/1998","2/2/2002","1/2/2003","3/2/2001","2/1/2007"].map {|x| Date.parse(x)}.each do |date|
113
- @csv_pirate = CsvPirate::TheCapn.new({
114
- :grub => GlowingGasBall,
115
- :spyglasses => [:get_stars],
116
- :chart => ["spec","csv","GlowingGasBall","dumps"],
117
- :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
118
- :chronometer => date,
119
- :swab => :none,
120
- :mop => :clean
121
- })
122
- @csv_pirate.hoist_mainstay
123
- end
124
- end
125
-
126
- it "should find first (oldest) dump" do
127
- @new_csv_pirate = CsvPirate::TheCapn.new({
128
- :grub => GlowingGasBall,
129
- :spyglasses => [:get_stars],
130
- :chart => ["spec","csv","GlowingGasBall","dumps"],
131
- :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
132
- :chronometer => false,
133
- :brigantine => :first,
134
- :swab => :none,
135
- :mop => :clean
136
- })
137
- @new_csv_pirate.brigantine.should == "spec/csv/GlowingGasBall/dumps/GlowingGasBall.19980101.export.csv"
138
- end
139
-
140
- it "should find last (newest) dump" do
141
- @new_csv_pirate = CsvPirate::TheCapn.new({
142
- :grub => GlowingGasBall,
143
- :spyglasses => [:get_stars],
144
- :chart => ["spec","csv","GlowingGasBall","dumps"],
145
- :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
146
- :chronometer => false,
147
- :brigantine => :last,
148
- :swab => :none,
149
- :mop => :clean
150
- })
151
- @new_csv_pirate.brigantine.should == "spec/csv/GlowingGasBall/dumps/GlowingGasBall.20070201.export.csv"
15
+ describe "MINOR" do
16
+ it "should be a string" do
17
+ CsvPirate::MINOR.class.should == Fixnum
18
+ CsvPirate::MINOR.should_not == ''
152
19
  end
153
20
  end
154
-
155
- describe "#to_memory" do
156
-
157
- before(:each) do
158
- ["1/1/1998","2/2/2002","1/2/2003","3/2/2001","2/1/2007"].map {|x| Date.parse(x)}.each do |date|
159
- @csv_pirate = CsvPirate::TheCapn.new({
160
- :grub => GlowingGasBall,
161
- :spyglasses => [:get_stars],
162
- :chart => ["spec","csv","GlowingGasBall","dumps"],
163
- :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
164
- :chronometer => date,
165
- :swab => :none,
166
- :mop => :clean
167
- })
168
- @csv_pirate.hoist_mainstay
169
- end
170
- end
171
-
172
- it "should return an array of 10 grubs built from data in CSV" do
173
- @new_csv_pirate = CsvPirate::TheCapn.new({
174
- :grub => GlowingGasBall,
175
- :spyglasses => [:get_stars],
176
- :chart => ["spec","csv","GlowingGasBall","dumps"],
177
- :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
178
- :chronometer => false,
179
- :brigantine => :last,
180
- :swab => :none,
181
- :mop => :clean
182
- })
183
- @new_csv_pirate.brigantine.should == "spec/csv/GlowingGasBall/dumps/GlowingGasBall.20070201.export.csv"
184
- @new_csv_pirate.to_memory.class.should == Array
185
- @new_csv_pirate.to_memory.length.should == 10
21
+ describe "PATCH" do
22
+ it "should be a string" do
23
+ CsvPirate::PATCH.class.should == Fixnum
24
+ CsvPirate::PATCH.should_not == ''
186
25
  end
187
26
  end
188
-
189
- describe ":blackjack option" do
190
- before(:each) do
191
- @csv_pirate = CsvPirate::TheCapn.new({
192
- :grub => GlowingGasBall,
193
- :spyglasses => [:get_stars],
194
- :chart => ["spec","csv","GlowingGasBall"],
195
- :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
196
- :chronometer => false,
197
- :gibbet => "",
198
- :aft => ".csv",
199
- :swab => :none,
200
- :mop => :clean,
201
- :waggoner => 'data'
202
- })
203
- end
204
-
205
- it "should be {humanize => '_'} by default" do
206
- @csv_pirate.blackjack.should == {:humanize => '_'}
207
- @csv_pirate.hoist_mainstay
208
- @csv_pirate.maroon[0..100].should == "Name,Distance,Spectral type,Name hash,Name next,Name upcase,Star vowels\nProxima Centauri,4.2 LY,M5.5V"
209
- end
210
-
211
- it "should work as {:join => '_'}" do
212
- @csv_pirate.blackjack = {:join => '_'}
213
- @csv_pirate.blackjack.should == {:join => '_'}
214
- @csv_pirate.hoist_mainstay
215
- @csv_pirate.maroon[0..100].should == "name,distance,spectral_type,name_hash,name_next,name_upcase,star_vowels\nProxima Centauri,4.2 LY,M5.5V"
27
+ describe "BUILD" do
28
+ it "should be a string" do
29
+ [String, NilClass].include?(CsvPirate::BUILD.class).should == true
216
30
  end
217
31
  end
218
32
 
@@ -0,0 +1,219 @@
1
+ require 'spec_helper' #here in this same config/ dir
2
+
3
+ describe CsvPirate::TheCapn do
4
+ describe "#initialize" do
5
+ before(:each) do
6
+ @csv_pirate = CsvPirate::TheCapn.new({
7
+ :grub => GlowingGasBall,
8
+ :spyglasses => [:get_stars],
9
+ :chart => ["spec","csv","GlowingGasBall"],
10
+ :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
11
+ :chronometer => false,
12
+ :gibbet => "",
13
+ :aft => ".csv",
14
+ :swab => :none,
15
+ :mop => :clean,
16
+ :waggoner => 'data'
17
+ })
18
+ end
19
+
20
+ it "should return an instance of CsvPirate" do
21
+ @csv_pirate.class.should == CsvPirate::TheCapn
22
+ end
23
+
24
+ it "should not export anything" do
25
+ @csv_pirate.maroon.should == ""
26
+ end
27
+ end
28
+
29
+ describe "#create" do
30
+ before(:each) do
31
+ @csv_pirate = CsvPirate::TheCapn.create({
32
+ :grub => GlowingGasBall,
33
+ :spyglasses => [:get_stars],
34
+ :chart => ["spec","csv","GlowingGasBall"],
35
+ :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
36
+ :chronometer => false,
37
+ :gibbet => "",
38
+ :aft => ".csv",
39
+ :swab => :none,
40
+ :mop => :clean,
41
+ :waggoner => 'data'
42
+ })
43
+ end
44
+
45
+ it "should return an instance of CsvPirate" do
46
+ @csv_pirate.class.should == CsvPirate::TheCapn
47
+ end
48
+
49
+ it "should store export in maroon instance variable" do
50
+ @csv_pirate.maroon[0..100].should ==
51
+ "Name,Distance,Spectral type,Name hash,Name next,Name upcase,Star vowels\nProxima Centauri,4.2 LY,M5.5V"
52
+ end
53
+ end
54
+
55
+
56
+ describe "#create with function-arg booty" do
57
+ before(:each) do
58
+ @csv_pirate = CsvPirate::TheCapn.create({
59
+ :grub => GlowingGasBall,
60
+ :spyglasses => [:get_stars],
61
+ :chart => ["spec","csv","GlowingGasBall"],
62
+ :booty => [[:sub_name, 'a', 'Z'], :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
63
+ :chronometer => false,
64
+ :gibbet => "",
65
+ :aft => ".csv",
66
+ :swab => :none,
67
+ :mop => :clean,
68
+ :waggoner => 'data'
69
+ })
70
+ end
71
+
72
+ it "should call instance functions with arguments an instance of CsvPirate" do
73
+ @csv_pirate.maroon.should =~ /ProximZ CentZuri/
74
+ end
75
+ end
76
+
77
+
78
+ describe "#hoist_mainstay" do
79
+ before(:each) do
80
+ @csv_pirate = CsvPirate::TheCapn.new({
81
+ :grub => GlowingGasBall,
82
+ :spyglasses => [:get_stars],
83
+ :chart => ["spec","csv","GlowingGasBall"],
84
+ :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
85
+ :chronometer => false,
86
+ :gibbet => "",
87
+ :aft => ".csv",
88
+ :swab => :none,
89
+ :mop => :clean,
90
+ :waggoner => 'data'
91
+ })
92
+ end
93
+
94
+ it "should return an instance of String" do
95
+ @csv_pirate.hoist_mainstay.class.should == String
96
+ end
97
+
98
+ it "should return the export as a string" do
99
+ @csv_pirate.hoist_mainstay[0..100].should == "Name,Distance,Spectral type,Name hash,Name next,Name upcase,Star vowels\nProxima Centauri,4.2 LY,M5.5V"
100
+ end
101
+
102
+ it "should store export in maroon instance variable" do
103
+ @csv_pirate.maroon.should == ""
104
+ @csv_pirate.hoist_mainstay
105
+ @csv_pirate.maroon[0..100].should == "Name,Distance,Spectral type,Name hash,Name next,Name upcase,Star vowels\nProxima Centauri,4.2 LY,M5.5V"
106
+ end
107
+ end
108
+
109
+ describe "#old_csv_dump" do
110
+
111
+ before(:each) do
112
+ ["1/1/1998","2/2/2002","1/2/2003","3/2/2001","2/1/2007"].map {|x| Date.parse(x)}.each do |date|
113
+ @csv_pirate = CsvPirate::TheCapn.new({
114
+ :grub => GlowingGasBall,
115
+ :spyglasses => [:get_stars],
116
+ :chart => ["spec","csv","GlowingGasBall","dumps"],
117
+ :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
118
+ :chronometer => date,
119
+ :swab => :none,
120
+ :mop => :clean
121
+ })
122
+ @csv_pirate.hoist_mainstay
123
+ end
124
+ end
125
+
126
+ it "should find first (oldest) dump" do
127
+ @new_csv_pirate = CsvPirate::TheCapn.new({
128
+ :grub => GlowingGasBall,
129
+ :spyglasses => [:get_stars],
130
+ :chart => ["spec","csv","GlowingGasBall","dumps"],
131
+ :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
132
+ :chronometer => false,
133
+ :brigantine => :first,
134
+ :swab => :none,
135
+ :mop => :clean
136
+ })
137
+ @new_csv_pirate.brigantine.should == "spec/csv/GlowingGasBall/dumps/GlowingGasBall.19980101.export.csv"
138
+ end
139
+
140
+ it "should find last (newest) dump" do
141
+ @new_csv_pirate = CsvPirate::TheCapn.new({
142
+ :grub => GlowingGasBall,
143
+ :spyglasses => [:get_stars],
144
+ :chart => ["spec","csv","GlowingGasBall","dumps"],
145
+ :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
146
+ :chronometer => false,
147
+ :brigantine => :last,
148
+ :swab => :none,
149
+ :mop => :clean
150
+ })
151
+ @new_csv_pirate.brigantine.should == "spec/csv/GlowingGasBall/dumps/GlowingGasBall.20070201.export.csv"
152
+ end
153
+ end
154
+
155
+ describe "#to_memory" do
156
+
157
+ before(:each) do
158
+ ["1/1/1998","2/2/2002","1/2/2003","3/2/2001","2/1/2007"].map {|x| Date.parse(x)}.each do |date|
159
+ @csv_pirate = CsvPirate::TheCapn.new({
160
+ :grub => GlowingGasBall,
161
+ :spyglasses => [:get_stars],
162
+ :chart => ["spec","csv","GlowingGasBall","dumps"],
163
+ :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
164
+ :chronometer => date,
165
+ :swab => :none,
166
+ :mop => :clean
167
+ })
168
+ @csv_pirate.hoist_mainstay
169
+ end
170
+ end
171
+
172
+ it "should return an array of 10 grubs built from data in CSV" do
173
+ @new_csv_pirate = CsvPirate::TheCapn.new({
174
+ :grub => GlowingGasBall,
175
+ :spyglasses => [:get_stars],
176
+ :chart => ["spec","csv","GlowingGasBall","dumps"],
177
+ :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
178
+ :chronometer => false,
179
+ :brigantine => :last,
180
+ :swab => :none,
181
+ :mop => :clean
182
+ })
183
+ @new_csv_pirate.brigantine.should == "spec/csv/GlowingGasBall/dumps/GlowingGasBall.20070201.export.csv"
184
+ @new_csv_pirate.to_memory.class.should == Array
185
+ @new_csv_pirate.to_memory.length.should == 10
186
+ end
187
+ end
188
+
189
+ describe ":blackjack option" do
190
+ before(:each) do
191
+ @csv_pirate = CsvPirate::TheCapn.new({
192
+ :grub => GlowingGasBall,
193
+ :spyglasses => [:get_stars],
194
+ :chart => ["spec","csv","GlowingGasBall"],
195
+ :booty => [:name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
196
+ :chronometer => false,
197
+ :gibbet => "",
198
+ :aft => ".csv",
199
+ :swab => :none,
200
+ :mop => :clean,
201
+ :waggoner => 'data'
202
+ })
203
+ end
204
+
205
+ it "should be {humanize => '_'} by default" do
206
+ @csv_pirate.blackjack.should == {:humanize => '_'}
207
+ @csv_pirate.hoist_mainstay
208
+ @csv_pirate.maroon[0..100].should == "Name,Distance,Spectral type,Name hash,Name next,Name upcase,Star vowels\nProxima Centauri,4.2 LY,M5.5V"
209
+ end
210
+
211
+ it "should work as {:join => '_'}" do
212
+ @csv_pirate.blackjack = {:join => '_'}
213
+ @csv_pirate.blackjack.should == {:join => '_'}
214
+ @csv_pirate.hoist_mainstay
215
+ @csv_pirate.maroon[0..100].should == "name,distance,spectral_type,name_hash,name_next,name_upcase,star_vowels\nProxima Centauri,4.2 LY,M5.5V"
216
+ end
217
+ end
218
+
219
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: csv_pirate
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 5.0.0
5
+ version: 5.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Peter Boling
@@ -10,19 +10,63 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-14 00:00:00 Z
13
+ date: 2011-06-15 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: csv_pirate
16
+ name: rspec
17
17
  requirement: &id001 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: "2.6"
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: shoulda
28
+ requirement: &id002 !ruby/object:Gem::Requirement
18
29
  none: false
19
30
  requirements:
20
31
  - - ">="
21
32
  - !ruby/object:Gem::Version
22
33
  version: "0"
23
- type: :runtime
34
+ type: :development
24
35
  prerelease: false
25
- version_requirements: *id001
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: bundler
39
+ requirement: &id003 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 1.0.0
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: jeweler
50
+ requirement: &id004 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 1.6.2
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: rcov
61
+ requirement: &id005 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *id005
26
70
  description: |-
27
71
  CsvPirate is the easy way to create a CSV of essentially anything in Ruby, in full pirate regalia.
28
72
  It works better if you are wearing a tricorne!
@@ -32,12 +76,12 @@ executables: []
32
76
  extensions: []
33
77
 
34
78
  extra_rdoc_files:
35
- - LICENSE
79
+ - LICENSE.txt
36
80
  - README.rdoc
37
81
  files:
38
- - CHANGELOG
82
+ - CHANGELOG.txt
39
83
  - Gemfile
40
- - LICENSE
84
+ - LICENSE.txt
41
85
  - README.rdoc
42
86
  - Rakefile
43
87
  - VERSION.yml
@@ -53,6 +97,7 @@ files:
53
97
  - spec/spec_helper.rb
54
98
  - spec/spec_helpers/glowing_gas_ball.rb
55
99
  - spec/spec_helpers/star.rb
100
+ - spec/the_capn_spec.rb
56
101
  - uninstall.rb
57
102
  homepage: http://github.com/pboling/csv_pirate
58
103
  licenses: []
@@ -67,6 +112,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
112
  requirements:
68
113
  - - ">="
69
114
  - !ruby/object:Gem::Version
115
+ hash: 2225901631909136480
116
+ segments:
117
+ - 0
70
118
  version: "0"
71
119
  required_rubygems_version: !ruby/object:Gem::Requirement
72
120
  none: false