csv_magic 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +2 -1
- data/Gemfile +6 -6
- data/README.md +5 -1
- data/csv_magic.gemspec +1 -1
- data/lib/csv_magic.rb +1 -0
- data/lib/csv_magic/controller_actions.rb +1 -1
- data/lib/csv_magic/csv_handler.rb +8 -0
- data/lib/csv_magic/importer.rb +1 -1
- data/lib/csv_magic/reader.rb +3 -3
- data/lib/csv_magic/version.rb +1 -1
- metadata +5 -4
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -3,11 +3,11 @@ source "http://rubygems.org"
|
|
3
3
|
# Specify your gem's dependencies in csv_magic.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
+
gem 'faster_csv', :github => 'glennfu/faster_csv', :platform => :ruby_18
|
7
|
+
|
6
8
|
group :development do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
gem 'ruby-debug', :platform => :ruby_18
|
12
|
-
end
|
9
|
+
if !ENV["CI"]
|
10
|
+
gem 'debugger', :platform => :ruby_19
|
11
|
+
gem 'ruby-debug', :platform => :ruby_18
|
12
|
+
end
|
13
13
|
end
|
data/README.md
CHANGED
@@ -11,7 +11,9 @@ It includes the complete workflow:
|
|
11
11
|
|
12
12
|
## Requirements
|
13
13
|
|
14
|
-
Rails >= 3.2.6 and Ruby >= 1.
|
14
|
+
Rails >= 3.2.6 and Ruby >= 1.8.7*
|
15
|
+
|
16
|
+
*) If you want to use CSV magic with Ruby 1.8.7 you have to add `gem 'faster_csv'` to your `Gemfile`
|
15
17
|
|
16
18
|
## Installation
|
17
19
|
|
@@ -22,6 +24,8 @@ Install as gem:
|
|
22
24
|
Or in your apps `Gemfile`:
|
23
25
|
|
24
26
|
gem 'csv_magic', :git => 'git://github.com/magiclabs/csv_magic.git'
|
27
|
+
# Uncomment next line if you want to use csv_magic with Ruby 1.8
|
28
|
+
# gem 'faster_csv', :github => 'glennfu/faster_csv', :platform => :ruby_18
|
25
29
|
|
26
30
|
## Usage
|
27
31
|
|
data/csv_magic.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = %q{Adds some CSV magic into your app.}
|
12
12
|
s.description = %q{Provides controller actions, views and field mapping for data from a csv file.}
|
13
13
|
s.rubyforge_project = "csv_magic"
|
14
|
-
s.required_ruby_version = '>= 1.
|
14
|
+
s.required_ruby_version = '>= 1.8.7'
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
data/lib/csv_magic.rb
CHANGED
@@ -72,7 +72,7 @@ module CSVMagic
|
|
72
72
|
rescue MissingFileContentsError
|
73
73
|
flash[:warning] = csv_magic_t(:please_upload_a_csv_file)
|
74
74
|
render_csv_import_form
|
75
|
-
rescue ::
|
75
|
+
rescue CSV_HANDLER::MalformedCSVError => e
|
76
76
|
flash[:warning] = csv_magic_t(:csv_file_has_wrong_format) % {:error => e.message}
|
77
77
|
render_csv_import_form
|
78
78
|
rescue ::Errno::ENOENT
|
data/lib/csv_magic/importer.rb
CHANGED
data/lib/csv_magic/reader.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module CSVMagic
|
2
2
|
class Reader
|
3
|
-
|
3
|
+
|
4
4
|
def initialize(params)
|
5
5
|
@file_handler = FileHandler.new
|
6
6
|
@file_handler.load_file(params[:filename])
|
@@ -14,10 +14,10 @@ module CSVMagic
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def each
|
19
19
|
row_number = 1
|
20
|
-
|
20
|
+
CSV_HANDLER.foreach(@file_path, CSVMagic.options) do |csv_row|
|
21
21
|
unless row_number == 1 && @ignore_first_row
|
22
22
|
row = {}
|
23
23
|
@mapping.each do |k, v|
|
data/lib/csv_magic/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_magic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-09-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- csv_magic.gemspec
|
83
83
|
- lib/csv_magic.rb
|
84
84
|
- lib/csv_magic/controller_actions.rb
|
85
|
+
- lib/csv_magic/csv_handler.rb
|
85
86
|
- lib/csv_magic/engine.rb
|
86
87
|
- lib/csv_magic/file_handler.rb
|
87
88
|
- lib/csv_magic/i18n_helpers.rb
|
@@ -145,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
146
|
requirements:
|
146
147
|
- - ! '>='
|
147
148
|
- !ruby/object:Gem::Version
|
148
|
-
version: 1.
|
149
|
+
version: 1.8.7
|
149
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
151
|
none: false
|
151
152
|
requirements:
|
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
155
|
version: '0'
|
155
156
|
segments:
|
156
157
|
- 0
|
157
|
-
hash: -
|
158
|
+
hash: -3430066953355410162
|
158
159
|
requirements: []
|
159
160
|
rubyforge_project: csv_magic
|
160
161
|
rubygems_version: 1.8.24
|