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 CHANGED
@@ -1,10 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.8.7
3
4
  - 1.9.2
4
5
  - 1.9.3
5
6
  branches:
6
7
  only:
7
- - master
8
+ - ruby1.8
8
9
  before_script:
9
10
  - "sh -c 'cd spec/dummy && RAILS_ENV=test bundle exec rake db:migrate'"
10
11
  script: "bundle exec rspec spec"
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
- if !ENV["CI"]
8
- gem 'ruby-debug-base19', '~> 0.11.26', :platform => :ruby_19
9
- gem 'linecache19', '~> 0.5.13', :platform => :ruby_19
10
- gem 'ruby-debug19', '~> 0.11.6', :require => 'ruby-debug', :platform => :ruby_19
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.9.x
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.9.2'
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
@@ -1,5 +1,6 @@
1
1
  require 'csv'
2
2
  require "csv_magic/version"
3
+ require "csv_magic/csv_handler"
3
4
  require 'csv_magic/i18n_helpers'
4
5
  require 'csv_magic/controller_actions'
5
6
  require 'csv_magic/engine'
@@ -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 ::CSV::MalformedCSVError => e
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
@@ -0,0 +1,8 @@
1
+ module CSVMagic
2
+ if RUBY_VERSION =~ /^1\.8/
3
+ require 'faster_csv'
4
+ CSV_HANDLER = ::FCSV
5
+ else
6
+ CSV_HANDLER = ::CSV
7
+ end
8
+ end
@@ -13,7 +13,7 @@ module CSVMagic
13
13
  end
14
14
 
15
15
  def raw_data
16
- ::CSV.read(@file_handler.file_path, CSVMagic.options)
16
+ CSV_HANDLER.read(@file_handler.file_path, CSVMagic.options)
17
17
  end
18
18
 
19
19
  private
@@ -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
- ::CSV.foreach(@file_path, CSVMagic.options) do |csv_row|
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|
@@ -1,3 +1,3 @@
1
1
  module CSVMagic
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.2"
3
3
  end
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.0
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-06-15 00:00:00.000000000 Z
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.9.2
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: -2326911074991617375
158
+ hash: -3430066953355410162
158
159
  requirements: []
159
160
  rubyforge_project: csv_magic
160
161
  rubygems_version: 1.8.24