csv_pirate 3.3.1 → 3.3.2

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 3.3.2 2009-10-11
2
+ - You can now declare has_csv_pirate_ship in a model whose migration has not been run yet without making the app barf.
3
+ - Cleaned up Gem Dependency (faster_csv)
4
+
1
5
  Version 3.3.1 2009-10-06
2
6
  - Oops! Declaring has_csv_pirate_ship with no options was broken.
3
7
 
data/Rakefile CHANGED
@@ -10,6 +10,7 @@ It works better if you are wearing a tricorne!}
10
10
  gemspec.email = "peter.boling@gmail.com"
11
11
  gemspec.homepage = "http://github.com/pboling/csv_pirate"
12
12
  gemspec.authors = ["Peter Boling"]
13
+ gemspec.add_dependency 'faster_csv'
13
14
  gemspec.files = ["README.rdoc",
14
15
  "csv_pirate.gemspec",
15
16
  "init.rb",
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 1
2
+ :patch: 2
3
3
  :major: 3
4
4
  :minor: 3
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 = "3.3.1"
8
+ s.version = "3.3.2"
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{2009-10-06}
12
+ s.date = %q{2009-10-11}
13
13
  s.description = %q{CsvPirate is the easy way to create a CSV of essentially anything in Rails, in full pirate regalia.
14
14
  It works better if you are wearing a tricorne!}
15
15
  s.email = %q{peter.boling@gmail.com}
@@ -45,8 +45,11 @@ It works better if you are wearing a tricorne!}
45
45
  s.specification_version = 3
46
46
 
47
47
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ s.add_runtime_dependency(%q<faster_csv>, [">= 0"])
48
49
  else
50
+ s.add_dependency(%q<faster_csv>, [">= 0"])
49
51
  end
50
52
  else
53
+ s.add_dependency(%q<faster_csv>, [">= 0"])
51
54
  end
52
55
  end
data/lib/csv_pirate.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  #Version: 1.0
8
8
  #Project owners:
9
9
  # peter.boling (The Cap'n)
10
- require 'fastercsv'
10
+ require 'faster_csv' unless defined?(FasterCSV)
11
11
 
12
12
  class CsvPirate
13
13
 
@@ -1,9 +1,14 @@
1
+ require 'faster_csv' unless defined?(FasterCSV)
2
+
1
3
  module NinthBit
2
4
  module PirateShip
3
5
 
4
6
  module ActMethods
5
7
  #coding tyle is adopted from attachment_fu
6
8
  def has_csv_pirate_ship(options = {})
9
+ # If you aren't using ActiveRecord (you are outside rails) then you must declare your :booty
10
+ # If you are using ActiveRecord then you only want ot check for booty if the table exists so it won't fail pre-migration
11
+ check_booty = defined?(ActiveRecord) && self.is_a?(ActiveRecord::Base) ? ActiveRecord::Base.connection.tables.include?(self.table_name) : true
7
12
 
8
13
  options[:chart] ||= ['log','csv']
9
14
  options[:aft] ||= '.csv'
@@ -17,7 +22,8 @@ module NinthBit
17
22
  options[:shrouds] ||= ','
18
23
  options[:grub] ||= self if options[:swag].nil?
19
24
  options[:spyglasses] ||= [:all]
20
- options[:booty] ||= self.column_names
25
+ # Have to protect against model definitions pre-migration, since column names will fail if
26
+ options[:booty] ||= check_booty ? self.column_names : []
21
27
  options[:bury_treasure] ||= true
22
28
  options[:parlay] ||= 1
23
29
 
@@ -29,7 +35,7 @@ module NinthBit
29
35
  raise ArgumentError, ":mop is #{options[:mop].inspect}, but must be one of #{CsvPirate::MOP_HEADS.inspect}" unless CsvPirate::MOP_HEADS.include?(options[:mop])
30
36
  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?('.'))
31
37
  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
32
- raise ArgumentError, ":booty is #{options[:booty].inspect}, and must be an array of methods to call on a class for CSV data" if options[:booty].nil? || !options[:booty].is_a?(Array) || options[:booty].empty?
38
+ 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?)
33
39
  raise ArgumentError, ":chart is #{options[:chart].inspect}, and must be an array of directory names, which will become the filepath for the csv file" if options[:chart].nil? || !options[:chart].is_a?(Array) || options[:chart].empty?
34
40
  raise ArgumentError, ":shrouds is #{options[:shrouds].inspect}, and must be a string (e.g. ',' or '\t'), which will be used as the delimeter for the csv file" if options[:shrouds].nil? || !options[:shrouds].is_a?(String)
35
41
 
data/rails/init.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'faster_csv'
1
2
  require 'csv_pirate'
2
3
  require 'ninth_bit/pirate_ship'
3
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_pirate
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
@@ -9,10 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-06 00:00:00 -04:00
12
+ date: 2009-10-11 00:00:00 -04:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: faster_csv
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
16
25
  description: |-
17
26
  CsvPirate is the easy way to create a CSV of essentially anything in Rails, in full pirate regalia.
18
27
  It works better if you are wearing a tricorne!