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 CHANGED
@@ -1,3 +1,7 @@
1
+ Version 5.0.0 2011-06-13
2
+ - Ruby 1.9.2p136 compatible
3
+ - Rails 3.0.x compatible
4
+
1
5
  Version 4.1.0 2010-09-26
2
6
  - Ruby 1.9.2p0 compatible
3
7
 
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ #FasterCSV became the built-in CSV library in Ruby 1.9, so is only required if using Ruby 1.8
6
+ if RUBY_VERSION =~ /^1\.8\.\d{1}$/
7
+ gem 'fastercsv', '~> 1.5'
8
+ end
9
+
10
+ group :test do
11
+ gem 'rspec', '~> 2.6'
12
+ end
data/README.rdoc CHANGED
@@ -202,7 +202,7 @@ Assuming a Make (as in manufacturers of automobiles) model like this:
202
202
  :swag => nil # Array of objects: to use to create the CSV (i.e. you've already done the query and have the results you want a CSV of)
203
203
  :grub => Make # Class: on which to call the method chain in :spyglasses that will return the array of objects to be placed in :swag by CsvPirate (See description of swag above).
204
204
  :spyglasses => [:all] # Array of symbols/strings: Methods that will be chained together and called on :grub in order to get the :swag records which will become the rows of the CSV.
205
- :booty => Make.column_names # Array of symbols/strings or nested hashes of symbols/strings: Methods to call on each object in :swag. These become the columns of the CSV. The method names become the CSV column headings. Methods can be chained to dig deep (e.g. traverse several ActiveRecord associations) to get at a value for the CSV.
205
+ :booty => Make.column_names # Array of symbols/strings or nested hashes of symbols/strings: Methods to call on each object in :swag. These become the columns of the CSV. The method names become the CSV column headings. Methods can be chained to dig deep (e.g. traverse several ActiveRecord associations) to get at a value for the CSV. To call instance methods that include arguments, pass a booty element of an array such as [:method_name, arg1, arg2...].
206
206
 
207
207
  :swab => :counter # Symbol: What kind of file counter to use to avoid overwtiting the CSV file, :counter is Integer, :timestamp is HHMMSS, :none is no file counter, increasing the liklihood of duplicate filenames on successive csv exports.
208
208
  :mop => :clean # Symbol: If we DO end up writing to a preexisting file (by design or accident) should we overwrite (:clean) or append (:dirty)?
@@ -281,6 +281,9 @@ If you want to traverse Active Record Associations, or call a method on the retu
281
281
  Make.walk_the_plank({:booty => [:id, :name, :to_slug, {:to_slug => :hash}]}) #will call .hash on the result of make.to_slug
282
282
  Make.walk_the_plank({:booty => [:id, :name, :to_slug, {:to_slug => {:hash => :abs}}]}) #returns make.to_slug.hash.abs
283
283
 
284
+ If you want to build your booty using instance functions that require arguments, use an array:
285
+ Make.walk_the_plank({:booty => [:id, :name, [:value_on, Date.today]}) # will call make.value_on(Date.today)
286
+
284
287
  Add whatever methods you want to the :booty array. Write new methods, and add them! Make lots of glorious CSVs full of data to impress the pointy ones in the office.
285
288
 
286
289
  You can also use the raw CsvPirate class itself directly wherever you want.
data/Rakefile CHANGED
@@ -1,3 +1,6 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
1
4
  require 'rake'
2
5
 
3
6
  begin
@@ -10,14 +13,14 @@ It works better if you are wearing a tricorne!}
10
13
  gemspec.email = "peter.boling@gmail.com"
11
14
  gemspec.homepage = "http://github.com/pboling/csv_pirate"
12
15
  gemspec.authors = ["Peter Boling"]
13
- #gemspec.add_dependency 'fastercsv'
14
16
  gemspec.files = ["README.rdoc",
15
17
  "csv_pirate.gemspec",
16
- "init.rb",
17
- "rails/init.rb",
18
18
  "install.rb",
19
+ "uninstall.rb",
19
20
  "lib/csv_pirate.rb",
20
- "lib/ninth_bit/pirate_ship.rb",
21
+ "lib/csv_pirate/pirate_ship.rb",
22
+ "lib/csv_pirate/the_capn.rb",
23
+ "lib/csv_pirate/version.rb",
21
24
  "spec/csv_pirate_spec.rb",
22
25
  "spec/pirate_ship_spec.rb",
23
26
  "spec/spec.opts",
@@ -25,6 +28,7 @@ It works better if you are wearing a tricorne!}
25
28
  "spec/spec_helpers/glowing_gas_ball.rb",
26
29
  "spec/spec_helpers/star.rb",
27
30
  "Rakefile",
31
+ "Gemfile",
28
32
  "LICENSE",
29
33
  "CHANGELOG",
30
34
  "VERSION.yml"]
@@ -43,23 +47,23 @@ Rake::RDocTask.new do |rdoc|
43
47
  rdoc.rdoc_files.include('lib/**/*.rb')
44
48
  end
45
49
 
46
- require 'spec/rake/spectask'
47
- Spec::Rake::SpecTask.new(:spec) do |t|
48
- t.libs << 'lib' << 'spec'
49
- t.spec_files = FileList['spec/**/*_spec.rb']
50
- end
51
-
52
- Spec::Rake::SpecTask.new(:rcov) do |t|
53
- t.libs << 'lib' << 'spec'
54
- t.spec_files = FileList['spec/**/*_spec.rb']
55
- t.rcov = true
56
- end
57
-
58
- begin
59
- require 'cucumber/rake/task'
60
- Cucumber::Rake::Task.new(:features)
61
- rescue LoadError
62
- puts "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
63
- end
50
+ # require 'spec/rake/spectask'
51
+ # Spec::Rake::SpecTask.new(:spec) do |t|
52
+ # t.libs << 'lib' << 'spec'
53
+ # t.spec_files = FileList['spec/**/*_spec.rb']
54
+ # end
55
+ #
56
+ # Spec::Rake::SpecTask.new(:rcov) do |t|
57
+ # t.libs << 'lib' << 'spec'
58
+ # t.spec_files = FileList['spec/**/*_spec.rb']
59
+ # t.rcov = true
60
+ # end
61
+ #
62
+ #begin
63
+ # require 'cucumber/rake/task'
64
+ # Cucumber::Rake::Task.new(:features)
65
+ #rescue LoadError
66
+ # puts "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
67
+ #end
64
68
 
65
69
  task :default => :spec
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :major: 4
2
+ :major: 5
3
+ :minor: 0
4
+ :patch: 0
3
5
  :build:
4
- :minor: 1
5
- :patch: 4
data/csv_pirate.gemspec CHANGED
@@ -1,62 +1,58 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{csv_pirate}
8
- s.version = "4.1.4"
8
+ s.version = "5.0.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-09-30}
12
+ s.date = %q{2011-06-14}
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
17
  "LICENSE",
18
- "README.rdoc"
18
+ "README.rdoc"
19
19
  ]
20
20
  s.files = [
21
21
  "CHANGELOG",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION.yml",
26
- "csv_pirate.gemspec",
27
- "init.rb",
28
- "install.rb",
29
- "lib/csv_pirate.rb",
30
- "lib/ninth_bit/pirate_ship.rb",
31
- "rails/init.rb",
32
- "spec/csv_pirate_spec.rb",
33
- "spec/pirate_ship_spec.rb",
34
- "spec/spec.opts",
35
- "spec/spec_helper.rb",
36
- "spec/spec_helpers/glowing_gas_ball.rb",
37
- "spec/spec_helpers/star.rb"
22
+ "Gemfile",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION.yml",
27
+ "csv_pirate.gemspec",
28
+ "install.rb",
29
+ "lib/csv_pirate.rb",
30
+ "lib/csv_pirate/pirate_ship.rb",
31
+ "lib/csv_pirate/the_capn.rb",
32
+ "lib/csv_pirate/version.rb",
33
+ "spec/csv_pirate_spec.rb",
34
+ "spec/pirate_ship_spec.rb",
35
+ "spec/spec.opts",
36
+ "spec/spec_helper.rb",
37
+ "spec/spec_helpers/glowing_gas_ball.rb",
38
+ "spec/spec_helpers/star.rb",
39
+ "uninstall.rb"
38
40
  ]
39
41
  s.homepage = %q{http://github.com/pboling/csv_pirate}
40
- s.rdoc_options = ["--charset=UTF-8"]
41
42
  s.require_paths = ["lib"]
42
- s.rubygems_version = %q{1.3.7}
43
+ s.rubygems_version = %q{1.7.2}
43
44
  s.summary = %q{Easily create CSVs of any data that can be derived from instance methods on your classes.}
44
- s.test_files = [
45
- "spec/csv_pirate_spec.rb",
46
- "spec/pirate_ship_spec.rb",
47
- "spec/spec_helper.rb",
48
- "spec/spec_helpers/glowing_gas_ball.rb",
49
- "spec/spec_helpers/star.rb"
50
- ]
51
45
 
52
46
  if s.respond_to? :specification_version then
53
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
47
  s.specification_version = 3
55
48
 
56
49
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<csv_pirate>, [">= 0"])
57
51
  else
52
+ s.add_dependency(%q<csv_pirate>, [">= 0"])
58
53
  end
59
54
  else
55
+ s.add_dependency(%q<csv_pirate>, [">= 0"])
60
56
  end
61
57
  end
62
58
 
@@ -1,4 +1,4 @@
1
- module NinthBit
1
+ module CsvPirate
2
2
  module PirateShip
3
3
 
4
4
  module ActMethods
@@ -29,8 +29,8 @@ module NinthBit
29
29
  raise ArgumentError, "must provide either :swag or :grub, not both" if !options[:swag].nil? && !options[:grub].nil?
30
30
  # if they provide neither
31
31
  raise ArgumentError, "must provide either :swag or :grub" if options[:swag].nil? && options[:grub].nil?
32
- raise ArgumentError, ":swab is #{options[:swab].inspect}, but must be one of #{CsvPirate::BOOKIE.inspect}" unless CsvPirate::BOOKIE.include?(options[:swab])
33
- raise ArgumentError, ":mop is #{options[:mop].inspect}, but must be one of #{CsvPirate::MOP_HEADS.inspect}" unless CsvPirate::MOP_HEADS.include?(options[:mop])
32
+ raise ArgumentError, ":swab is #{options[:swab].inspect}, but must be one of #{TheCapn::BOOKIE.inspect}" unless TheCapn::BOOKIE.include?(options[:swab])
33
+ raise ArgumentError, ":mop is #{options[:mop].inspect}, but must be one of #{TheCapn::MOP_HEADS.inspect}" unless TheCapn::MOP_HEADS.include?(options[:mop])
34
34
  raise ArgumentError, ":gibbet is #{options[:gibbet].inspect}, and does not contain a '.' character, which is required when using iterative filenames (set :swab => :none to turn off iterative filenames)" if options[:swab] != :none && (options[:gibbet].nil? || !options[:gibbet].include?('.'))
35
35
  raise ArgumentError, ":waggoner is #{options[:waggoner].inspect}, and must be a string at least one character long" if options[:waggoner].nil? || options[:waggoner].length < 1
36
36
  raise ArgumentError, ":booty is #{options[:booty].inspect}, and must be an array of methods to call on a class for CSV data" if check_booty && (options[:booty].nil? || !options[:booty].is_a?(Array) || options[:booty].empty?)
@@ -96,7 +96,7 @@ module NinthBit
96
96
  # :type => 'text/csv; charset=iso-8859-1; header=present',
97
97
  # :disposition => "attachment; filename=#{csv_pirate.nocturnal}"
98
98
  def blindfold(args = {})
99
- CsvPirate.create(self.piratey_args(args))
99
+ TheCapn.create(self.piratey_args(args))
100
100
  end
101
101
 
102
102
  # returns the csv_pirate object so you have access to everything
@@ -106,7 +106,7 @@ module NinthBit
106
106
  # csv_pirate.booty -= [:id, :name]
107
107
  # csv_pirate.hoist_mainstay()
108
108
  def land_ho(args = {})
109
- CsvPirate.new(self.piratey_args(args))
109
+ TheCapn.new(self.piratey_args(args))
110
110
  end
111
111
 
112
112
  def weigh_anchor(args = {})
@@ -115,7 +115,7 @@ module NinthBit
115
115
  :gibbet => '.dump',
116
116
  :chart => pargs[:chart] + ["dumps"],
117
117
  })
118
- CsvPirate.create(pargs)
118
+ TheCapn.create(pargs)
119
119
  end
120
120
 
121
121
  def raise_anchor(permanence = {:new => :new}, args = {})
@@ -124,7 +124,7 @@ module NinthBit
124
124
  :chart => pargs[:chart] + ["dumps"],
125
125
  :brigantine => :last
126
126
  })
127
- csv_pirate = CsvPirate.new(pargs)
127
+ csv_pirate = TheCapn.new(pargs)
128
128
 
129
129
  csv_pirate.to_memory(permanence)
130
130
  end
@@ -132,7 +132,7 @@ module NinthBit
132
132
  protected
133
133
 
134
134
  def piratey_args(args = {})
135
- CsvPirate.parlay ||= args[:parlay] || self.piratey_options[:parlay]
135
+ TheCapn.parlay ||= args[:parlay] || self.piratey_options[:parlay]
136
136
  return { :chart => args[:chart] || self.piratey_options[:chart],
137
137
  :aft => args[:aft] || self.piratey_options[:aft],
138
138
  :gibbet => args[:gibbet] || self.piratey_options[:gibbet],