csv_pirate 4.1.4 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Gemfile +12 -0
- data/README.rdoc +4 -1
- data/Rakefile +26 -22
- data/VERSION.yml +3 -3
- data/csv_pirate.gemspec +26 -30
- data/lib/{ninth_bit → csv_pirate}/pirate_ship.rb +8 -8
- data/lib/csv_pirate/the_capn.rb +689 -0
- data/lib/csv_pirate/version.rb +11 -0
- data/lib/csv_pirate.rb +6 -674
- data/spec/csv_pirate_spec.rb +34 -11
- data/spec/pirate_ship_spec.rb +8 -8
- data/spec/spec_helper.rb +4 -4
- data/spec/spec_helpers/glowing_gas_ball.rb +4 -0
- data/spec/spec_helpers/star.rb +1 -1
- data/uninstall.rb +1 -0
- metadata +25 -30
- data/init.rb +0 -1
- data/rails/init.rb +0 -50
data/spec/csv_pirate_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper' #here in this same config/ dir
|
|
3
3
|
describe "CsvPirate" do
|
4
4
|
describe "#initialize" do
|
5
5
|
before(:each) do
|
6
|
-
@csv_pirate = CsvPirate.new({
|
6
|
+
@csv_pirate = CsvPirate::TheCapn.new({
|
7
7
|
:grub => GlowingGasBall,
|
8
8
|
:spyglasses => [:get_stars],
|
9
9
|
:chart => ["spec","csv","GlowingGasBall"],
|
@@ -18,7 +18,7 @@ describe "CsvPirate" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should return an instance of CsvPirate" do
|
21
|
-
@csv_pirate.class.should == CsvPirate
|
21
|
+
@csv_pirate.class.should == CsvPirate::TheCapn
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should not export anything" do
|
@@ -28,7 +28,7 @@ describe "CsvPirate" do
|
|
28
28
|
|
29
29
|
describe "#create" do
|
30
30
|
before(:each) do
|
31
|
-
@csv_pirate = CsvPirate.create({
|
31
|
+
@csv_pirate = CsvPirate::TheCapn.create({
|
32
32
|
:grub => GlowingGasBall,
|
33
33
|
:spyglasses => [:get_stars],
|
34
34
|
:chart => ["spec","csv","GlowingGasBall"],
|
@@ -43,7 +43,7 @@ describe "CsvPirate" do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should return an instance of CsvPirate" do
|
46
|
-
@csv_pirate.class.should == CsvPirate
|
46
|
+
@csv_pirate.class.should == CsvPirate::TheCapn
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should store export in maroon instance variable" do
|
@@ -52,9 +52,32 @@ describe "CsvPirate" do
|
|
52
52
|
end
|
53
53
|
end
|
54
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
|
+
|
55
78
|
describe "#hoist_mainstay" do
|
56
79
|
before(:each) do
|
57
|
-
@csv_pirate = CsvPirate.new({
|
80
|
+
@csv_pirate = CsvPirate::TheCapn.new({
|
58
81
|
:grub => GlowingGasBall,
|
59
82
|
:spyglasses => [:get_stars],
|
60
83
|
:chart => ["spec","csv","GlowingGasBall"],
|
@@ -87,7 +110,7 @@ describe "CsvPirate" do
|
|
87
110
|
|
88
111
|
before(:each) do
|
89
112
|
["1/1/1998","2/2/2002","1/2/2003","3/2/2001","2/1/2007"].map {|x| Date.parse(x)}.each do |date|
|
90
|
-
@csv_pirate = CsvPirate.new({
|
113
|
+
@csv_pirate = CsvPirate::TheCapn.new({
|
91
114
|
:grub => GlowingGasBall,
|
92
115
|
:spyglasses => [:get_stars],
|
93
116
|
:chart => ["spec","csv","GlowingGasBall","dumps"],
|
@@ -101,7 +124,7 @@ describe "CsvPirate" do
|
|
101
124
|
end
|
102
125
|
|
103
126
|
it "should find first (oldest) dump" do
|
104
|
-
@new_csv_pirate = CsvPirate.new({
|
127
|
+
@new_csv_pirate = CsvPirate::TheCapn.new({
|
105
128
|
:grub => GlowingGasBall,
|
106
129
|
:spyglasses => [:get_stars],
|
107
130
|
:chart => ["spec","csv","GlowingGasBall","dumps"],
|
@@ -115,7 +138,7 @@ describe "CsvPirate" do
|
|
115
138
|
end
|
116
139
|
|
117
140
|
it "should find last (newest) dump" do
|
118
|
-
@new_csv_pirate = CsvPirate.new({
|
141
|
+
@new_csv_pirate = CsvPirate::TheCapn.new({
|
119
142
|
:grub => GlowingGasBall,
|
120
143
|
:spyglasses => [:get_stars],
|
121
144
|
:chart => ["spec","csv","GlowingGasBall","dumps"],
|
@@ -133,7 +156,7 @@ describe "CsvPirate" do
|
|
133
156
|
|
134
157
|
before(:each) do
|
135
158
|
["1/1/1998","2/2/2002","1/2/2003","3/2/2001","2/1/2007"].map {|x| Date.parse(x)}.each do |date|
|
136
|
-
@csv_pirate = CsvPirate.new({
|
159
|
+
@csv_pirate = CsvPirate::TheCapn.new({
|
137
160
|
:grub => GlowingGasBall,
|
138
161
|
:spyglasses => [:get_stars],
|
139
162
|
:chart => ["spec","csv","GlowingGasBall","dumps"],
|
@@ -147,7 +170,7 @@ describe "CsvPirate" do
|
|
147
170
|
end
|
148
171
|
|
149
172
|
it "should return an array of 10 grubs built from data in CSV" do
|
150
|
-
@new_csv_pirate = CsvPirate.new({
|
173
|
+
@new_csv_pirate = CsvPirate::TheCapn.new({
|
151
174
|
:grub => GlowingGasBall,
|
152
175
|
:spyglasses => [:get_stars],
|
153
176
|
:chart => ["spec","csv","GlowingGasBall","dumps"],
|
@@ -165,7 +188,7 @@ describe "CsvPirate" do
|
|
165
188
|
|
166
189
|
describe ":blackjack option" do
|
167
190
|
before(:each) do
|
168
|
-
@csv_pirate = CsvPirate.new({
|
191
|
+
@csv_pirate = CsvPirate::TheCapn.new({
|
169
192
|
:grub => GlowingGasBall,
|
170
193
|
:spyglasses => [:get_stars],
|
171
194
|
:chart => ["spec","csv","GlowingGasBall"],
|
data/spec/pirate_ship_spec.rb
CHANGED
@@ -16,8 +16,8 @@ describe "PirateShip" do
|
|
16
16
|
@csv_pirate = Star.blindfold
|
17
17
|
end
|
18
18
|
|
19
|
-
it "should return an instance of CsvPirate" do
|
20
|
-
@csv_pirate.class.should == CsvPirate
|
19
|
+
it "should return an instance of CsvPirate::TheCapn" do
|
20
|
+
@csv_pirate.class.should == CsvPirate::TheCapn
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -26,8 +26,8 @@ describe "PirateShip" do
|
|
26
26
|
@csv_pirate = Star.land_ho
|
27
27
|
end
|
28
28
|
|
29
|
-
it "should return an instance of CsvPirate" do
|
30
|
-
@csv_pirate.class.should == CsvPirate
|
29
|
+
it "should return an instance of CsvPirate::TheCapn" do
|
30
|
+
@csv_pirate.class.should == CsvPirate::TheCapn
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -36,8 +36,8 @@ describe "PirateShip" do
|
|
36
36
|
@csv_pirate = Star.land_ho
|
37
37
|
end
|
38
38
|
|
39
|
-
it "should return an instance of CsvPirate" do
|
40
|
-
@csv_pirate.class.should == CsvPirate
|
39
|
+
it "should return an instance of CsvPirate::TheCapn" do
|
40
|
+
@csv_pirate.class.should == CsvPirate::TheCapn
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -46,8 +46,8 @@ describe "PirateShip" do
|
|
46
46
|
@csv_pirate = Star.weigh_anchor({:chronometer => Date.parse("2/1/2007")})
|
47
47
|
end
|
48
48
|
|
49
|
-
it "should return an instance of CsvPirate" do
|
50
|
-
@csv_pirate.class.should == CsvPirate
|
49
|
+
it "should return an instance of CsvPirate::TheCapn" do
|
50
|
+
@csv_pirate.class.should == CsvPirate::TheCapn
|
51
51
|
@csv_pirate.chart.should == ["spec","csv","Star","dumps"]
|
52
52
|
end
|
53
53
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'spec'
|
1
|
+
#require 'spec'
|
2
|
+
require 'rspec/core'
|
3
|
+
require 'csv_pirate'
|
2
4
|
|
3
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
Spec::Runner.configure do |config|
|
7
|
+
RSpec.configure do |config|
|
8
8
|
|
9
9
|
end
|
10
10
|
|
@@ -12,6 +12,10 @@ class GlowingGasBall
|
|
12
12
|
self.name.tr('aeiou', '*')
|
13
13
|
end
|
14
14
|
|
15
|
+
def sub_name(old_letter, new_letter)
|
16
|
+
name.gsub(old_letter, new_letter)
|
17
|
+
end
|
18
|
+
|
15
19
|
def self.get_stars
|
16
20
|
[
|
17
21
|
GlowingGasBall.new(:name => "Proxima Centauri", :distance => "4.2 LY", :spectral_type => "M5.5Vc"),
|
data/spec/spec_helpers/star.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Star < GlowingGasBall
|
2
2
|
|
3
|
-
extend
|
3
|
+
extend CsvPirate::PirateShip::ActMethods
|
4
4
|
has_csv_pirate_ship :booty => [ :name, :distance, :spectral_type, {:name => :hash}, {:name => :next}, {:name => :upcase}, :star_vowels ],
|
5
5
|
:spyglasses => [:get_stars],
|
6
6
|
:chart => ["spec","csv","Star"],
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_pirate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 4
|
8
|
-
- 1
|
9
|
-
- 4
|
10
|
-
version: 4.1.4
|
4
|
+
prerelease:
|
5
|
+
version: 5.0.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Peter Boling
|
@@ -15,10 +10,19 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
date: 2011-06-14 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: csv_pirate
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *id001
|
22
26
|
description: |-
|
23
27
|
CsvPirate is the easy way to create a CSV of essentially anything in Ruby, in full pirate regalia.
|
24
28
|
It works better if you are wearing a tricorne!
|
@@ -32,29 +36,30 @@ extra_rdoc_files:
|
|
32
36
|
- README.rdoc
|
33
37
|
files:
|
34
38
|
- CHANGELOG
|
39
|
+
- Gemfile
|
35
40
|
- LICENSE
|
36
41
|
- README.rdoc
|
37
42
|
- Rakefile
|
38
43
|
- VERSION.yml
|
39
44
|
- csv_pirate.gemspec
|
40
|
-
- init.rb
|
41
45
|
- install.rb
|
42
46
|
- lib/csv_pirate.rb
|
43
|
-
- lib/
|
44
|
-
-
|
47
|
+
- lib/csv_pirate/pirate_ship.rb
|
48
|
+
- lib/csv_pirate/the_capn.rb
|
49
|
+
- lib/csv_pirate/version.rb
|
45
50
|
- spec/csv_pirate_spec.rb
|
46
51
|
- spec/pirate_ship_spec.rb
|
47
52
|
- spec/spec.opts
|
48
53
|
- spec/spec_helper.rb
|
49
54
|
- spec/spec_helpers/glowing_gas_ball.rb
|
50
55
|
- spec/spec_helpers/star.rb
|
51
|
-
|
56
|
+
- uninstall.rb
|
52
57
|
homepage: http://github.com/pboling/csv_pirate
|
53
58
|
licenses: []
|
54
59
|
|
55
60
|
post_install_message:
|
56
|
-
rdoc_options:
|
57
|
-
|
61
|
+
rdoc_options: []
|
62
|
+
|
58
63
|
require_paths:
|
59
64
|
- lib
|
60
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -62,29 +67,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
67
|
requirements:
|
63
68
|
- - ">="
|
64
69
|
- !ruby/object:Gem::Version
|
65
|
-
hash: 3
|
66
|
-
segments:
|
67
|
-
- 0
|
68
70
|
version: "0"
|
69
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
72
|
none: false
|
71
73
|
requirements:
|
72
74
|
- - ">="
|
73
75
|
- !ruby/object:Gem::Version
|
74
|
-
hash: 3
|
75
|
-
segments:
|
76
|
-
- 0
|
77
76
|
version: "0"
|
78
77
|
requirements: []
|
79
78
|
|
80
79
|
rubyforge_project:
|
81
|
-
rubygems_version: 1.
|
80
|
+
rubygems_version: 1.7.2
|
82
81
|
signing_key:
|
83
82
|
specification_version: 3
|
84
83
|
summary: Easily create CSVs of any data that can be derived from instance methods on your classes.
|
85
|
-
test_files:
|
86
|
-
|
87
|
-
- spec/pirate_ship_spec.rb
|
88
|
-
- spec/spec_helper.rb
|
89
|
-
- spec/spec_helpers/glowing_gas_ball.rb
|
90
|
-
- spec/spec_helpers/star.rb
|
84
|
+
test_files: []
|
85
|
+
|
data/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/rails/init.rb"
|
data/rails/init.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
#We might have rails...
|
2
|
-
if defined?(Rails) && !defined?(Rake) && defined?(config) && config.respond_to?(:gems)
|
3
|
-
|
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
|
10
|
-
|
11
|
-
require 'csv_pirate'
|
12
|
-
require 'ninth_bit/pirate_ship'
|
13
|
-
|
14
|
-
config.to_prepare do
|
15
|
-
# If you are using this on a vanilla Ruby class (no rails or active record) then extend your class like this:
|
16
|
-
# MyClass.send(:extend, NinthBit::PirateShip::ActMethods) if defined?(MyClass)
|
17
|
-
# Alternatively you can do this inside your class definition:
|
18
|
-
# class MyClass
|
19
|
-
# extend NinthBit::PirateShip::ActMethods
|
20
|
-
# end
|
21
|
-
# If you are using ActiveRecord then it is done for you :)
|
22
|
-
ActiveRecord::Base.send(:extend, NinthBit::PirateShip::ActMethods) if defined?(ActiveRecord)
|
23
|
-
end
|
24
|
-
|
25
|
-
#And we might not... (rake needs to come hear to load the gems properly)
|
26
|
-
else
|
27
|
-
|
28
|
-
begin
|
29
|
-
|
30
|
-
require 'rubygems'
|
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
|
37
|
-
require 'csv_pirate'
|
38
|
-
require 'ninth_bit/pirate_ship'
|
39
|
-
ActiveRecord::Base.send(:extend, NinthBit::PirateShip::ActMethods) if defined?(ActiveRecord)
|
40
|
-
|
41
|
-
rescue Gem::LoadError
|
42
|
-
if RUBY_VERSION.to_f >= 1.9
|
43
|
-
raise
|
44
|
-
else
|
45
|
-
puts "Install the fastercsv gem to enable CsvPirate"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|