importer 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ script: "rake test"
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ branches:
6
+ only:
7
+ - master
@@ -1,9 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- importer (0.4.3)
4
+ importer (0.4.4)
5
5
  crack (>= 0.1.6)
6
- fastercsv (>= 1.5.0)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
@@ -20,9 +20,9 @@ Install the gem
20
20
 
21
21
  gem install importer
22
22
 
23
- Or the plugin
23
+ To use with Ruby < 1.9
24
24
 
25
- script/plugin install git://github.com/szajbus/importer.git
25
+ gem install importer -v "~> 0.4.0"
26
26
 
27
27
  Add to your model
28
28
 
@@ -16,7 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Importer::VERSION
17
17
 
18
18
  gem.add_runtime_dependency "crack", ">= 0.1.6"
19
- gem.add_runtime_dependency "fastercsv", ">= 1.5.0"
20
19
  gem.add_development_dependency "activerecord", "3.2.5"
21
20
  gem.add_development_dependency "mongo_mapper", "0.11.1"
22
21
  gem.add_development_dependency "datamapper", "1.2"
@@ -1,14 +1,13 @@
1
- require 'fastercsv'
1
+ require 'csv'
2
2
 
3
3
  module Importer
4
4
  module Parser
5
5
  # CSV parser
6
- # Uses fastercsv lib to parse the CSV files.
7
6
  class Csv < Base
8
7
  def run
9
8
  @data = []
10
9
 
11
- data = FasterCSV.read(@file, :skip_blanks => true)
10
+ data = CSV.read(@file, :skip_blanks => true)
12
11
 
13
12
  unless data.empty?
14
13
  attributes = data.shift
@@ -1,3 +1,3 @@
1
1
  module Importer
2
- VERSION = "0.4.4"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -24,7 +24,7 @@ DataMapper.setup(:default, config['test'])
24
24
  MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
25
25
  MongoMapper.database = 'importer-test'
26
26
 
27
- class Test::Unit::TestCase
27
+ class ActiveSupport::TestCase
28
28
  include RR::Adapters::TestUnit
29
29
 
30
30
  # return path to a fixture file from test/fixtures dir
@@ -1,7 +1,7 @@
1
1
  require 'helper'
2
2
 
3
- class Importer::Adapters::ActiveRecordAdapterTest < Test::Unit::TestCase
4
- def setup
3
+ class Importer::Adapters::ActiveRecordAdapterTest < ActiveSupport::TestCase
4
+ setup do
5
5
  ActiveRecord::Base.connection.create_table :products, { :force => true } do |t|
6
6
  t.string :customid
7
7
  t.string :name
@@ -20,7 +20,7 @@ class Importer::Adapters::ActiveRecordAdapterTest < Test::Unit::TestCase
20
20
  end
21
21
  end
22
22
 
23
- def teardown
23
+ teardown do
24
24
  undef_class("Product")
25
25
  end
26
26
 
@@ -103,7 +103,7 @@ class Importer::Adapters::ActiveRecordAdapterTest < Test::Unit::TestCase
103
103
  @count = InvalidProduct.count
104
104
  end
105
105
 
106
- def teardown
106
+ teardown do
107
107
  undef_class("InvalidProduct")
108
108
  end
109
109
 
@@ -1,7 +1,7 @@
1
1
  require 'helper'
2
2
 
3
- class Importer::Adapters::DataMapperAdapterTest < Test::Unit::TestCase
4
- def setup
3
+ class Importer::Adapters::DataMapperAdapterTest < ActiveSupport::TestCase
4
+ setup do
5
5
  def_class("Product") do
6
6
  include DataMapper::Resource
7
7
  include Importer
@@ -23,7 +23,7 @@ class Importer::Adapters::DataMapperAdapterTest < Test::Unit::TestCase
23
23
  DataMapper.auto_migrate!
24
24
  end
25
25
 
26
- def teardown
26
+ teardown do
27
27
  undef_class("Product")
28
28
  end
29
29
 
@@ -108,7 +108,7 @@ class Importer::Adapters::DataMapperAdapterTest < Test::Unit::TestCase
108
108
  @count = InvalidProduct.count
109
109
  end
110
110
 
111
- def teardown
111
+ teardown do
112
112
  undef_class("InvalidProduct")
113
113
  end
114
114
 
@@ -1,7 +1,7 @@
1
1
  require 'helper'
2
2
 
3
- class Importer::Adapters::MongoMapperAdapterTest < Test::Unit::TestCase
4
- def setup
3
+ class Importer::Adapters::MongoMapperAdapterTest < ActiveSupport::TestCase
4
+ setup do
5
5
  def_class("Product") do
6
6
  include MongoMapper::Document
7
7
  include Importer
@@ -19,7 +19,7 @@ class Importer::Adapters::MongoMapperAdapterTest < Test::Unit::TestCase
19
19
  end
20
20
  end
21
21
 
22
- def teardown
22
+ teardown do
23
23
  MongoMapper.database.drop_collection("products")
24
24
  undef_class("Product")
25
25
  end
@@ -104,7 +104,7 @@ class Importer::Adapters::MongoMapperAdapterTest < Test::Unit::TestCase
104
104
  end
105
105
  end
106
106
 
107
- def teardown
107
+ teardown do
108
108
  undef_class("InvalidProduct")
109
109
  end
110
110
 
@@ -116,7 +116,7 @@ class Importer::Adapters::MongoMapperAdapterTest < Test::Unit::TestCase
116
116
 
117
117
  context "passing import_options to #import method" do
118
118
  setup do
119
- stub(Importer::Parser::Xml).run("empty.xml") { [] }
119
+ stub(Importer::Parser::Xml).run(fixture_file("empty.xml")) { [] }
120
120
 
121
121
  @options = { :key => 'value' }
122
122
  @import = Product.import(fixture_file("empty.xml"), :import_options => @options)
@@ -1,7 +1,7 @@
1
1
  require 'helper'
2
2
 
3
- class Importer::ImportTest < Test::Unit::TestCase
4
- def setup
3
+ class Importer::ImportTest < ActiveSupport::TestCase
4
+ setup do
5
5
  @import = Importer::Import.new
6
6
  end
7
7
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Importer::ImportedObjectTest < Test::Unit::TestCase
3
+ class Importer::ImportedObjectTest < ActiveSupport::TestCase
4
4
  context "creating a new imported object" do
5
5
  setup do
6
6
  @data = { 'a' => 'b' }
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Importer::Parser::CsvTest < Test::Unit::TestCase
3
+ class Importer::Parser::CsvTest < ActiveSupport::TestCase
4
4
  context "parsing an CSV file with many objects defined" do
5
5
  setup { @data = Importer::Parser::Csv.run(fixture_file("products.csv")) }
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Importer::Parser::XmlTest < Test::Unit::TestCase
3
+ class Importer::Parser::XmlTest < ActiveSupport::TestCase
4
4
  context "parsing an XML file with many objects defined" do
5
5
  setup { @data = Importer::Parser::Xml.run(fixture_file("products.xml")) }
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Importer::ParserTest < Test::Unit::TestCase
3
+ class Importer::ParserTest < ActiveSupport::TestCase
4
4
  should "return Xml parser for file with .xml extension" do
5
5
  assert_equal Importer::Parser::Xml, Importer::Parser.get_klass("file.xml")
6
6
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: importer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.4
5
+ version: 0.5.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - "Micha\xC5\x82 Szajbe"
@@ -23,105 +23,94 @@ dependencies:
23
23
  version: 0.1.6
24
24
  type: :runtime
25
25
  version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: fastercsv
28
- prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 1.5.0
35
- type: :runtime
36
- version_requirements: *id002
37
26
  - !ruby/object:Gem::Dependency
38
27
  name: activerecord
39
28
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
29
+ requirement: &id002 !ruby/object:Gem::Requirement
41
30
  none: false
42
31
  requirements:
43
32
  - - "="
44
33
  - !ruby/object:Gem::Version
45
34
  version: 3.2.5
46
35
  type: :development
47
- version_requirements: *id003
36
+ version_requirements: *id002
48
37
  - !ruby/object:Gem::Dependency
49
38
  name: mongo_mapper
50
39
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
40
+ requirement: &id003 !ruby/object:Gem::Requirement
52
41
  none: false
53
42
  requirements:
54
43
  - - "="
55
44
  - !ruby/object:Gem::Version
56
45
  version: 0.11.1
57
46
  type: :development
58
- version_requirements: *id004
47
+ version_requirements: *id003
59
48
  - !ruby/object:Gem::Dependency
60
49
  name: datamapper
61
50
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
51
+ requirement: &id004 !ruby/object:Gem::Requirement
63
52
  none: false
64
53
  requirements:
65
54
  - - "="
66
55
  - !ruby/object:Gem::Version
67
56
  version: "1.2"
68
57
  type: :development
69
- version_requirements: *id005
58
+ version_requirements: *id004
70
59
  - !ruby/object:Gem::Dependency
71
60
  name: dm-sqlite-adapter
72
61
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
62
+ requirement: &id005 !ruby/object:Gem::Requirement
74
63
  none: false
75
64
  requirements:
76
65
  - - "="
77
66
  - !ruby/object:Gem::Version
78
67
  version: "1.2"
79
68
  type: :development
80
- version_requirements: *id006
69
+ version_requirements: *id005
81
70
  - !ruby/object:Gem::Dependency
82
71
  name: do_sqlite3
83
72
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
73
+ requirement: &id006 !ruby/object:Gem::Requirement
85
74
  none: false
86
75
  requirements:
87
76
  - - "="
88
77
  - !ruby/object:Gem::Version
89
78
  version: 0.10.8
90
79
  type: :development
91
- version_requirements: *id007
80
+ version_requirements: *id006
92
81
  - !ruby/object:Gem::Dependency
93
82
  name: thoughtbot-shoulda
94
83
  prerelease: false
95
- requirement: &id008 !ruby/object:Gem::Requirement
84
+ requirement: &id007 !ruby/object:Gem::Requirement
96
85
  none: false
97
86
  requirements:
98
87
  - - "="
99
88
  - !ruby/object:Gem::Version
100
89
  version: 2.11.1
101
90
  type: :development
102
- version_requirements: *id008
91
+ version_requirements: *id007
103
92
  - !ruby/object:Gem::Dependency
104
93
  name: sqlite3-ruby
105
94
  prerelease: false
106
- requirement: &id009 !ruby/object:Gem::Requirement
95
+ requirement: &id008 !ruby/object:Gem::Requirement
107
96
  none: false
108
97
  requirements:
109
98
  - - "="
110
99
  - !ruby/object:Gem::Version
111
100
  version: 1.3.3
112
101
  type: :development
113
- version_requirements: *id009
102
+ version_requirements: *id008
114
103
  - !ruby/object:Gem::Dependency
115
104
  name: rr
116
105
  prerelease: false
117
- requirement: &id010 !ruby/object:Gem::Requirement
106
+ requirement: &id009 !ruby/object:Gem::Requirement
118
107
  none: false
119
108
  requirements:
120
109
  - - "="
121
110
  - !ruby/object:Gem::Version
122
111
  version: 1.0.4
123
112
  type: :development
124
- version_requirements: *id010
113
+ version_requirements: *id009
125
114
  description: Define new objects or modifications of existing ones in external file (xml, csv, etc) and import them to your application. Importer will not only import all the objects but also will give you detailed summary of the import process.
126
115
  email:
127
116
  - michal.szajbe@gmail.com
@@ -134,12 +123,12 @@ extra_rdoc_files: []
134
123
  files:
135
124
  - .document
136
125
  - .gitignore
126
+ - .travis.yml
137
127
  - Gemfile
138
128
  - Gemfile.lock
139
129
  - LICENSE
140
130
  - README.rdoc
141
131
  - Rakefile
142
- - VERSION
143
132
  - importer.gemspec
144
133
  - lib/importer.rb
145
134
  - lib/importer/adapters/active_record_adapter.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.4.3