tabularasa 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -3,4 +3,8 @@ README.rdoc
3
3
  Rakefile
4
4
  init.rb
5
5
  lib/tabularasa.rb
6
+ test/active_record.rb
7
+ test/array.rb
8
+ test/hash.rb
9
+ test/test_helper.rb
6
10
  Manifest
data/README.rdoc CHANGED
@@ -44,7 +44,7 @@ This simple gem gives you the ability to convert an array of activerecord and/or
44
44
 
45
45
  == Contributors
46
46
 
47
- * Chris Roasario
47
+ * Chris Rosario
48
48
 
49
49
 
50
50
  Copyright (c) 2011 Chris Rosario, released under the MIT license
data/Rakefile CHANGED
@@ -1,14 +1,15 @@
1
1
  require 'rubygems'
2
2
  require 'echoe'
3
3
 
4
- Echoe.new('tabularasa', '0.2.0') do |p|
4
+ Echoe.new('tabularasa', '0.2.1') do |p|
5
5
  p.summary = "Gives the ability to convert homogeneous activerecord and/or hash objects into csv"
6
6
  p.description = "This Rails gem gives you the ability to call to_csv to a collection of homogenous activerecords and/or hashes"
7
7
  p.url = "https://github.com/callenrosario/tabularasa"
8
8
  p.author = "Chris Rosario"
9
9
  p.email = "callenrosario@gmail.com"
10
10
  p.ignore_pattern = ["tmp/*", "script/*"]
11
- p.runtime_dependencies = []
11
+ p.runtime_dependencies = ['activerecord']
12
+ p.runtime_dependencies << 'fastercsv' if RUBY_VERSION < '1.9'
12
13
  p.development_dependencies = []
13
14
  end
14
15
 
data/lib/tabularasa.rb CHANGED
@@ -1,14 +1,17 @@
1
- require 'csv'
1
+ require 'active_record'
2
+ require RUBY_VERSION >= '1.9' ? 'csv' : 'fastercsv'
2
3
 
3
4
  class Tabularasa
4
5
  def initialize(rows, options = {}, &block)
6
+ @generator = RUBY_VERSION >= '1.9' ? CSV : FasterCSV
7
+ @delimiter = options[:delimiter] || ','
5
8
  @rows = rows
6
9
  @keys = (options[:only] || get_keys) - (options[:exclude] || [])
7
10
  @headers = options[:headers] || options[:only] || get_headers
8
11
  end
9
12
 
10
13
  def to_csv
11
- csv_data = CSV.generate do |csv|
14
+ csv_data = @generator.generate(:col_sep => @delimiter) do |csv|
12
15
  csv << @headers
13
16
  @rows.each do |row|
14
17
  csv << collect(row)
data/tabularasa.gemspec CHANGED
@@ -1,29 +1,36 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |s|
4
- s.name = "tabularasa"
5
- s.version = "0.2.0"
4
+ s.name = %q{tabularasa}
5
+ s.version = "0.2.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Chris Rosario"]
9
- s.date = "2011-11-29"
10
- s.description = "This Rails gem gives you the ability to call to_csv to a collection of homogenous activerecords and/or hashes"
11
- s.email = "callenrosario@gmail.com"
12
- s.extra_rdoc_files = ["README.rdoc", "lib/tabularasa.rb"]
13
- s.files = ["MIT-LICENSE", "README.rdoc", "Rakefile", "init.rb", "lib/tabularasa.rb", "Manifest", "tabularasa.gemspec"]
14
- s.homepage = "https://github.com/callenrosario/tabularasa"
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Tabularasa", "--main", "README.rdoc"]
16
- s.require_paths = ["lib"]
17
- s.rubyforge_project = "tabularasa"
18
- s.rubygems_version = "1.8.11"
19
- s.summary = "Gives the ability to convert homogeneous activerecord and/or hash objects into csv"
8
+ s.authors = [%q{Chris Rosario}]
9
+ s.date = %q{2011-11-29}
10
+ s.description = %q{This Rails gem gives you the ability to call to_csv to a collection of homogenous activerecords and/or hashes}
11
+ s.email = %q{callenrosario@gmail.com}
12
+ s.extra_rdoc_files = [%q{README.rdoc}, %q{lib/tabularasa.rb}]
13
+ s.files = [%q{MIT-LICENSE}, %q{README.rdoc}, %q{Rakefile}, %q{init.rb}, %q{lib/tabularasa.rb}, %q{test/active_record.rb}, %q{test/array.rb}, %q{test/hash.rb}, %q{test/test_helper.rb}, %q{Manifest}, %q{tabularasa.gemspec}]
14
+ s.homepage = %q{https://github.com/callenrosario/tabularasa}
15
+ s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Tabularasa}, %q{--main}, %q{README.rdoc}]
16
+ s.require_paths = [%q{lib}]
17
+ s.rubyforge_project = %q{tabularasa}
18
+ s.rubygems_version = %q{1.8.6}
19
+ s.summary = %q{Gives the ability to convert homogeneous activerecord and/or hash objects into csv}
20
+ s.test_files = [%q{test/test_helper.rb}]
20
21
 
21
22
  if s.respond_to? :specification_version then
22
23
  s.specification_version = 3
23
24
 
24
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<activerecord>, [">= 0"])
27
+ s.add_runtime_dependency(%q<fastercsv>, [">= 0"])
25
28
  else
29
+ s.add_dependency(%q<activerecord>, [">= 0"])
30
+ s.add_dependency(%q<fastercsv>, [">= 0"])
26
31
  end
27
32
  else
33
+ s.add_dependency(%q<activerecord>, [">= 0"])
34
+ s.add_dependency(%q<fastercsv>, [">= 0"])
28
35
  end
29
36
  end
File without changes
data/test/array.rb ADDED
File without changes
data/test/hash.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'tabularasa'
3
+
4
+ rows = [
5
+ { :a => 2,
6
+ :b => 10,
7
+ :c => 11,
8
+ :d => 12
9
+ },
10
+ { "1" => "b",
11
+ "4" => "q",
12
+ "7" => "b",
13
+ "6" => "o"
14
+ }
15
+ ]
16
+
17
+ p rows.to_csv
@@ -0,0 +1,8 @@
1
+ require 'tabularasa'
2
+ require 'active_support'
3
+
4
+ class User
5
+ end
6
+
7
+ a = User.new
8
+ p a.class.baseclass
metadata CHANGED
@@ -1,61 +1,109 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tabularasa
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 1
10
+ version: 0.2.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Chris Rosario
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-11-29 00:00:00.000000000Z
13
- dependencies: []
14
- description: This Rails gem gives you the ability to call to_csv to a collection of
15
- homogenous activerecords and/or hashes
17
+
18
+ date: 2011-11-29 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activerecord
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: fastercsv
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ description: This Rails gem gives you the ability to call to_csv to a collection of homogenous activerecords and/or hashes
16
49
  email: callenrosario@gmail.com
17
50
  executables: []
51
+
18
52
  extensions: []
19
- extra_rdoc_files:
53
+
54
+ extra_rdoc_files:
20
55
  - README.rdoc
21
56
  - lib/tabularasa.rb
22
- files:
57
+ files:
23
58
  - MIT-LICENSE
24
59
  - README.rdoc
25
60
  - Rakefile
26
61
  - init.rb
27
62
  - lib/tabularasa.rb
63
+ - test/active_record.rb
64
+ - test/array.rb
65
+ - test/hash.rb
66
+ - test/test_helper.rb
28
67
  - Manifest
29
68
  - tabularasa.gemspec
30
69
  homepage: https://github.com/callenrosario/tabularasa
31
70
  licenses: []
71
+
32
72
  post_install_message:
33
- rdoc_options:
73
+ rdoc_options:
34
74
  - --line-numbers
35
75
  - --inline-source
36
76
  - --title
37
77
  - Tabularasa
38
78
  - --main
39
79
  - README.rdoc
40
- require_paths:
80
+ require_paths:
41
81
  - lib
42
- required_ruby_version: !ruby/object:Gem::Requirement
82
+ required_ruby_version: !ruby/object:Gem::Requirement
43
83
  none: false
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
92
  none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '1.2'
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 11
97
+ segments:
98
+ - 1
99
+ - 2
100
+ version: "1.2"
54
101
  requirements: []
102
+
55
103
  rubyforge_project: tabularasa
56
- rubygems_version: 1.8.11
104
+ rubygems_version: 1.8.6
57
105
  signing_key:
58
106
  specification_version: 3
59
- summary: Gives the ability to convert homogeneous activerecord and/or hash objects
60
- into csv
61
- test_files: []
107
+ summary: Gives the ability to convert homogeneous activerecord and/or hash objects into csv
108
+ test_files:
109
+ - test/test_helper.rb