csv_pirate 4.0.11 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/README.rdoc +5 -3
- data/VERSION.yml +2 -2
- data/csv_pirate.gemspec +4 -4
- data/lib/csv_pirate.rb +7 -2
- data/lib/ninth_bit/pirate_ship.rb +0 -2
- data/rails/init.rb +17 -3
- data/spec/csv_pirate_spec.rb +7 -6
- data/spec/pirate_ship_spec.rb +4 -4
- data/spec/spec_helper.rb +1 -1
- metadata +7 -4
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Easily create CSVs of any data that can be derived from your models.
|
4
4
|
|
5
5
|
CsvPirate is the easy way to create a CSV of essentially anything in Ruby, in full pirate regalia.
|
6
|
-
It works better if you are wearing a tricorne!
|
6
|
+
It works better if you are wearing a tricorne! Now compatible with Ruby 1.8.7 & 1.9.2
|
7
7
|
|
8
8
|
Everything in the source that depended on Rails extensions of Ruby classes has been refactored to work in pure Ruby!
|
9
9
|
|
@@ -423,7 +423,9 @@ The tests are run with rspec. The test suite is expanding. Currently there is
|
|
423
423
|
|
424
424
|
You will need these gems to run specs:
|
425
425
|
|
426
|
-
gem install jeweler cucumber test-unit rspec
|
426
|
+
gem install jeweler cucumber test-unit rspec
|
427
|
+
|
428
|
+
If on a Ruby prior to Ruby 1.9 you will also need the fastercsv gem
|
427
429
|
|
428
430
|
To run tests cd to where ever you have csv_pirate installed, and do:
|
429
431
|
|
@@ -448,4 +450,4 @@ TimePerks LLC (http://www.timeperks.com) - Many useful enhancements were request
|
|
448
450
|
|
449
451
|
----------------------------------------------------------------------------------
|
450
452
|
Author: Peter Boling, peter.boling at gmail dot com
|
451
|
-
Copyright (c) 2009 Peter H. Boling of 9thBit LLC, released under the MIT license. See LICENSE for details.
|
453
|
+
Copyright (c) 2009-2010 Peter H. Boling of 9thBit LLC, released under the MIT license. See LICENSE for details.
|
data/VERSION.yml
CHANGED
data/csv_pirate.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{csv_pirate}
|
8
|
-
s.version = "4.0
|
8
|
+
s.version = "4.1.0"
|
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{2010-
|
12
|
+
s.date = %q{2010-09-26}
|
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}
|
@@ -39,7 +39,7 @@ It works better if you are wearing a tricorne!}
|
|
39
39
|
s.homepage = %q{http://github.com/pboling/csv_pirate}
|
40
40
|
s.rdoc_options = ["--charset=UTF-8"]
|
41
41
|
s.require_paths = ["lib"]
|
42
|
-
s.rubygems_version = %q{1.3.
|
42
|
+
s.rubygems_version = %q{1.3.7}
|
43
43
|
s.summary = %q{Easily create CSVs of any data that can be derived from instance methods on your classes.}
|
44
44
|
s.test_files = [
|
45
45
|
"spec/csv_pirate_spec.rb",
|
@@ -53,7 +53,7 @@ It works better if you are wearing a tricorne!}
|
|
53
53
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
54
54
|
s.specification_version = 3
|
55
55
|
|
56
|
-
if Gem::Version.new(Gem::
|
56
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
57
57
|
s.add_runtime_dependency(%q<fastercsv>, [">= 0"])
|
58
58
|
else
|
59
59
|
s.add_dependency(%q<fastercsv>, [">= 0"])
|
data/lib/csv_pirate.rb
CHANGED
@@ -7,12 +7,17 @@
|
|
7
7
|
#Version: 1.0
|
8
8
|
#Project owners:
|
9
9
|
# peter.boling (The Cap'n)
|
10
|
+
if RUBY_VERSION.to_f >= 1.9
|
11
|
+
else
|
12
|
+
require 'faster_csv'
|
13
|
+
end
|
10
14
|
|
11
15
|
class CsvPirate
|
12
16
|
|
13
17
|
BOOKIE = [:counter, :timestamp, :none]
|
14
18
|
MOP_HEADS = [:clean, :dirty]
|
15
19
|
BRIGANTINE = [:first, :last]
|
20
|
+
CSV_CLASS = (defined?(CSV) ? CSV : FasterCSV)
|
16
21
|
|
17
22
|
attr_accessor :waggoner # First part of filename
|
18
23
|
attr_accessor :chart # directory, default is (['log','csv'])
|
@@ -235,7 +240,7 @@ class CsvPirate
|
|
235
240
|
end
|
236
241
|
|
237
242
|
def dead_mans_chest
|
238
|
-
self.maroon =
|
243
|
+
self.maroon = CSV_CLASS.generate(:col_sep => self.shrouds) do |csv|
|
239
244
|
self.sounding(csv)
|
240
245
|
end
|
241
246
|
self.scrivener(self.maroon)
|
@@ -589,7 +594,7 @@ class CsvPirate
|
|
589
594
|
# Sink other ships! Or run a block of code on each row of a CSV
|
590
595
|
def self.broadside(galley, &block)
|
591
596
|
return false unless block_given?
|
592
|
-
|
597
|
+
CSV_CLASS.foreach(galley, {:headers => :first_row, :return_headers => false}) do |gun|
|
593
598
|
yield gun
|
594
599
|
end
|
595
600
|
end
|
data/rails/init.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
#We might have rails...
|
2
2
|
if defined?(Rails) && !defined?(Rake) && defined?(config) && config.respond_to?(:gems)
|
3
3
|
|
4
|
-
|
4
|
+
if RUBY_VERSION.to_f >= 1.9
|
5
|
+
require 'csv'
|
6
|
+
else
|
7
|
+
puts "- When you upgrade to Ruby 1.9 fastercsv gem will not be a dependecy anymore"
|
8
|
+
config.gem 'fastercsv', :lib => 'faster_csv', :version => '>=1.4.0'
|
9
|
+
end
|
5
10
|
|
6
11
|
require 'csv_pirate'
|
7
12
|
require 'ninth_bit/pirate_ship'
|
@@ -23,13 +28,22 @@ else
|
|
23
28
|
begin
|
24
29
|
|
25
30
|
require 'rubygems'
|
26
|
-
|
31
|
+
if RUBY_VERSION.to_f >= 1.9
|
32
|
+
require 'csv'
|
33
|
+
else
|
34
|
+
puts "* When you upgrade to Ruby 1.9 fastercsv gem will not be a dependecy anymore"
|
35
|
+
gem 'fastercsv', '>=1.4.0', :lib => 'faster_csv'
|
36
|
+
end
|
27
37
|
require 'csv_pirate'
|
28
38
|
require 'ninth_bit/pirate_ship'
|
29
39
|
ActiveRecord::Base.send(:extend, NinthBit::PirateShip::ActMethods) if defined?(ActiveRecord)
|
30
40
|
|
31
41
|
rescue Gem::LoadError
|
32
|
-
|
42
|
+
if RUBY_VERSION.to_f >= 1.9
|
43
|
+
raise
|
44
|
+
else
|
45
|
+
puts "Install the fastercsv gem to enable CsvPirate"
|
46
|
+
end
|
33
47
|
end
|
34
48
|
|
35
49
|
end
|
data/spec/csv_pirate_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper' #here in this same config/ dir
|
2
2
|
|
3
3
|
describe "CsvPirate" do
|
4
4
|
describe "#initialize" do
|
@@ -47,7 +47,8 @@ describe "CsvPirate" do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should store export in maroon instance variable" do
|
50
|
-
@csv_pirate.maroon.should ==
|
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"
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
@@ -72,13 +73,13 @@ describe "CsvPirate" do
|
|
72
73
|
end
|
73
74
|
|
74
75
|
it "should return the export as a string" do
|
75
|
-
@csv_pirate.hoist_mainstay.should == "Name,Distance,Spectral type,Name hash,Name next,Name upcase,Star vowels\nProxima Centauri,4.2 LY,M5.
|
76
|
+
@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"
|
76
77
|
end
|
77
78
|
|
78
79
|
it "should store export in maroon instance variable" do
|
79
80
|
@csv_pirate.maroon.should == ""
|
80
81
|
@csv_pirate.hoist_mainstay
|
81
|
-
@csv_pirate.maroon.should == "Name,Distance,Spectral type,Name hash,Name next,Name upcase,Star vowels\nProxima Centauri,4.2 LY,M5.
|
82
|
+
@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"
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
@@ -181,14 +182,14 @@ describe "CsvPirate" do
|
|
181
182
|
it "should be {humanize => '_'} by default" do
|
182
183
|
@csv_pirate.blackjack.should == {:humanize => '_'}
|
183
184
|
@csv_pirate.hoist_mainstay
|
184
|
-
@csv_pirate.maroon.should == "Name,Distance,Spectral type,Name hash,Name next,Name upcase,Star vowels\nProxima Centauri,4.2 LY,M5.
|
185
|
+
@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"
|
185
186
|
end
|
186
187
|
|
187
188
|
it "should work as {:join => '_'}" do
|
188
189
|
@csv_pirate.blackjack = {:join => '_'}
|
189
190
|
@csv_pirate.blackjack.should == {:join => '_'}
|
190
191
|
@csv_pirate.hoist_mainstay
|
191
|
-
@csv_pirate.maroon.should == "name,distance,spectral_type,name_hash,name_next,name_upcase,star_vowels\nProxima Centauri,4.2 LY,M5.
|
192
|
+
@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"
|
192
193
|
end
|
193
194
|
end
|
194
195
|
|
data/spec/pirate_ship_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper' #here in this same config/ dir
|
2
2
|
|
3
3
|
describe "PirateShip" do
|
4
4
|
describe "#walk_the_plank" do
|
@@ -54,9 +54,9 @@ describe "PirateShip" do
|
|
54
54
|
|
55
55
|
describe "#raise_anchor" do
|
56
56
|
before(:each) do
|
57
|
-
Star.weigh_anchor({:chronometer => Date.parse("
|
58
|
-
Star.weigh_anchor({:chronometer => Date.parse("
|
59
|
-
Star.weigh_anchor({:chronometer => Date.parse("12
|
57
|
+
Star.weigh_anchor({:chronometer => Date.parse("03.10.2002")})
|
58
|
+
Star.weigh_anchor({:chronometer => Date.parse("06.11.2004")})
|
59
|
+
Star.weigh_anchor({:chronometer => Date.parse("12.12.1962")})
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should return an array of 10 Stars built from data in CSV" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 4
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
|
9
|
-
version: 4.0.11
|
9
|
+
version: 4.1.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Peter Boling
|
@@ -14,13 +14,14 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-09-26 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: fastercsv
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
@@ -68,6 +69,7 @@ rdoc_options:
|
|
68
69
|
require_paths:
|
69
70
|
- lib
|
70
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
71
73
|
requirements:
|
72
74
|
- - ">="
|
73
75
|
- !ruby/object:Gem::Version
|
@@ -75,6 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
77
|
- 0
|
76
78
|
version: "0"
|
77
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
78
81
|
requirements:
|
79
82
|
- - ">="
|
80
83
|
- !ruby/object:Gem::Version
|
@@ -84,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
87
|
requirements: []
|
85
88
|
|
86
89
|
rubyforge_project:
|
87
|
-
rubygems_version: 1.3.
|
90
|
+
rubygems_version: 1.3.7
|
88
91
|
signing_key:
|
89
92
|
specification_version: 3
|
90
93
|
summary: Easily create CSVs of any data that can be derived from instance methods on your classes.
|