activerecord-import 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +20 -0
- data/Gemfile +4 -5
- data/lib/activerecord-import/import.rb +2 -2
- data/lib/activerecord-import/version.rb +1 -1
- data/test/import_test.rb +16 -7
- data/test/travis/build.sh +19 -0
- data/test/travis/database.yml +57 -0
- metadata +15 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d56f03f91020cf45a7991e8dcfcc3501865bc76
|
4
|
+
data.tar.gz: ad90843270868863373e130fe3031eca04212c9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39d17dc94eec248309b4acf6b0a6d0b83aaa350eea90b1177176d0c4b032b5f3be49d23c3c03db6dba706c2d30e28f3bc543e5a44d132431ea8a74f12d14fe5c
|
7
|
+
data.tar.gz: 1370ba68b46d19f12d032a8f4eacefaddb9dbd7850ce1661504ffa7c95baabba32c1f0d363a281f2c1dfeba07d932076035403e37241e2acd86f3dbffd666226
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
rvm:
|
4
|
+
- 2.0.0
|
5
|
+
|
6
|
+
gemfile:
|
7
|
+
- Gemfile
|
8
|
+
|
9
|
+
bundler_args: -j2
|
10
|
+
|
11
|
+
before_script:
|
12
|
+
- mysql -e 'create database activerecord_import_test;'
|
13
|
+
- psql -c 'create database activerecord_import_test;' -U postgres
|
14
|
+
- psql -U postgres -c "create extension postgis"
|
15
|
+
- cp test/travis/database.yml test/database.yml
|
16
|
+
# https://github.com/discourse/discourse/blob/master/.travis.yml
|
17
|
+
- export RUBY_GC_MALLOC_LIMIT=50000000
|
18
|
+
|
19
|
+
script:
|
20
|
+
- test/travis/build.sh
|
data/Gemfile
CHANGED
@@ -23,13 +23,12 @@ gem "factory_girl", "~> 4.2.0"
|
|
23
23
|
gem "delorean", "~> 0.2.0"
|
24
24
|
|
25
25
|
# Debugging
|
26
|
-
platforms :mri_18 do
|
27
|
-
gem "ruby-debug", "= 0.10.4"
|
28
|
-
end
|
29
|
-
|
30
26
|
platforms :jruby do
|
31
27
|
gem "ruby-debug-base", "= 0.10.4"
|
32
|
-
|
28
|
+
end
|
29
|
+
|
30
|
+
platforms :jruby, :mri_18 do
|
31
|
+
gem "ruby-debug", "= 0.10.4"
|
33
32
|
end
|
34
33
|
|
35
34
|
platforms :mri_19 do
|
@@ -348,8 +348,8 @@ class ActiveRecord::Base
|
|
348
348
|
if self.column_names.include?(key)
|
349
349
|
value = blk.call
|
350
350
|
if index=column_names.index(key)
|
351
|
-
|
352
|
-
|
351
|
+
# replace every instance of the array of attributes with our value
|
352
|
+
array_of_attributes.each{ |arr| arr[index] = value if arr[index].nil? }
|
353
353
|
else
|
354
354
|
column_names << key
|
355
355
|
array_of_attributes.each { |arr| arr << value }
|
data/test/import_test.rb
CHANGED
@@ -236,29 +236,38 @@ describe "#import" do
|
|
236
236
|
context "ActiveRecord timestamps" do
|
237
237
|
context "when the timestamps columns are present" do
|
238
238
|
setup do
|
239
|
+
@existing_book = Book.create(title: "Fell", author_name: "Curry", publisher: "Bayer", created_at: 2.years.ago.utc, created_on: 2.years.ago.utc)
|
239
240
|
ActiveRecord::Base.default_timezone = :utc
|
240
241
|
Delorean.time_travel_to("5 minutes ago") do
|
241
|
-
assert_difference "Book.count", +
|
242
|
-
result = Book.import [
|
242
|
+
assert_difference "Book.count", +2 do
|
243
|
+
result = Book.import ["title", "author_name", "publisher", "created_at", "created_on"], [["LDAP", "Big Bird", "Del Rey", nil, nil], [@existing_book.title, @existing_book.author_name, @existing_book.publisher, @existing_book.created_at, @existing_book.created_on]]
|
243
244
|
end
|
244
245
|
end
|
245
|
-
@
|
246
|
+
@new_book, @existing_book = Book.last 2
|
246
247
|
end
|
247
248
|
|
248
249
|
it "should set the created_at column for new records" do
|
249
|
-
assert_equal 5.minutes.ago.utc.strftime("%H:%M"), @
|
250
|
+
assert_equal 5.minutes.ago.utc.strftime("%H:%M"), @new_book.created_at.strftime("%H:%M")
|
250
251
|
end
|
251
252
|
|
252
253
|
it "should set the created_on column for new records" do
|
253
|
-
assert_equal 5.minutes.ago.utc.strftime("%H:%M"), @
|
254
|
+
assert_equal 5.minutes.ago.utc.strftime("%H:%M"), @new_book.created_on.strftime("%H:%M")
|
255
|
+
end
|
256
|
+
|
257
|
+
it "should not set the created_at column for existing records" do
|
258
|
+
assert_equal 2.years.ago.utc.strftime("%Y:%d"), @existing_book.created_at.strftime("%Y:%d")
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should not set the created_on column for existing records" do
|
262
|
+
assert_equal 2.years.ago.utc.strftime("%Y:%d"), @existing_book.created_on.strftime("%Y:%d")
|
254
263
|
end
|
255
264
|
|
256
265
|
it "should set the updated_at column for new records" do
|
257
|
-
assert_equal 5.minutes.ago.utc.strftime("%H:%M"), @
|
266
|
+
assert_equal 5.minutes.ago.utc.strftime("%H:%M"), @new_book.updated_at.strftime("%H:%M")
|
258
267
|
end
|
259
268
|
|
260
269
|
it "should set the updated_on column for new records" do
|
261
|
-
assert_equal 5.minutes.ago.utc.strftime("%H:%M"), @
|
270
|
+
assert_equal 5.minutes.ago.utc.strftime("%H:%M"), @new_book.updated_on.strftime("%H:%M")
|
262
271
|
end
|
263
272
|
end
|
264
273
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
set -e
|
3
|
+
set +x
|
4
|
+
|
5
|
+
bundle exec rake test:em_mysql2 # Run tests for em_mysql2
|
6
|
+
bundle exec rake test:mysql # Run tests for mysql
|
7
|
+
bundle exec rake test:mysql2 # Run tests for mysql2
|
8
|
+
bundle exec rake test:mysql2spatial # Run tests for mysql2spatial
|
9
|
+
bundle exec rake test:mysqlspatial # Run tests for mysqlspatial
|
10
|
+
bundle exec rake test:postgis # Run tests for postgis
|
11
|
+
bundle exec rake test:postgresql # Run tests for postgresql
|
12
|
+
bundle exec rake test:seamless_database_pool # Run tests for seamless_database_pool
|
13
|
+
bundle exec rake test:spatialite # Run tests for spatialite
|
14
|
+
# so far the version installed in travis seems < 3.7.11 so we cannot test sqlite3 on it
|
15
|
+
# bundle exec rake test:sqlite3
|
16
|
+
|
17
|
+
#jruby
|
18
|
+
#bundle exec rake test:jdbcmysql # Run tests for jdbcmysql
|
19
|
+
#bundle exec rake test:jdbcpostgresql # Run tests for jdbcpostgresql
|
@@ -0,0 +1,57 @@
|
|
1
|
+
common: &common
|
2
|
+
username: root
|
3
|
+
password:
|
4
|
+
encoding: utf8
|
5
|
+
host: localhost
|
6
|
+
database: activerecord_import_test
|
7
|
+
|
8
|
+
mysql: &mysql
|
9
|
+
<<: *common
|
10
|
+
adapter: mysql
|
11
|
+
|
12
|
+
mysql2: &mysql2
|
13
|
+
<<: *common
|
14
|
+
adapter: mysql2
|
15
|
+
|
16
|
+
mysqlspatial:
|
17
|
+
<<: *mysql
|
18
|
+
|
19
|
+
mysql2spatial:
|
20
|
+
<<: *mysql2
|
21
|
+
|
22
|
+
em_mysql2:
|
23
|
+
<<: *common
|
24
|
+
adapter: em_mysql2
|
25
|
+
pool: 5
|
26
|
+
|
27
|
+
seamless_database_pool:
|
28
|
+
<<: *common
|
29
|
+
adapter: seamless_database_pool
|
30
|
+
pool_adapter: mysql2
|
31
|
+
master:
|
32
|
+
host: localhost
|
33
|
+
|
34
|
+
postgresql: &postgresql
|
35
|
+
<<: *common
|
36
|
+
username: postgres
|
37
|
+
adapter: postgresql
|
38
|
+
min_messages: warning
|
39
|
+
|
40
|
+
postgis:
|
41
|
+
<<: *postgresql
|
42
|
+
|
43
|
+
oracle:
|
44
|
+
<<: *common
|
45
|
+
adapter: oracle
|
46
|
+
min_messages: debug
|
47
|
+
|
48
|
+
sqlite:
|
49
|
+
adapter: sqlite
|
50
|
+
dbfile: test.db
|
51
|
+
|
52
|
+
sqlite3: &sqlite3
|
53
|
+
adapter: sqlite3
|
54
|
+
database: ":memory:"
|
55
|
+
|
56
|
+
spatialite:
|
57
|
+
<<: *sqlite3
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Extraction of the ActiveRecord::Base#import functionality from ar-extensions
|
@@ -46,7 +46,8 @@ executables: []
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
-
- .gitignore
|
49
|
+
- ".gitignore"
|
50
|
+
- ".travis.yml"
|
50
51
|
- Brewfile
|
51
52
|
- Gemfile
|
52
53
|
- LICENSE
|
@@ -134,6 +135,8 @@ files:
|
|
134
135
|
- test/support/postgresql/import_examples.rb
|
135
136
|
- test/synchronize_test.rb
|
136
137
|
- test/test_helper.rb
|
138
|
+
- test/travis/build.sh
|
139
|
+
- test/travis/database.yml
|
137
140
|
- test/value_sets_bytes_parser_test.rb
|
138
141
|
- test/value_sets_records_parser_test.rb
|
139
142
|
homepage: http://github.com/zdennis/activerecord-import
|
@@ -146,17 +149,17 @@ require_paths:
|
|
146
149
|
- lib
|
147
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
148
151
|
requirements:
|
149
|
-
- -
|
152
|
+
- - ">="
|
150
153
|
- !ruby/object:Gem::Version
|
151
154
|
version: 1.9.2
|
152
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
156
|
requirements:
|
154
|
-
- -
|
157
|
+
- - ">="
|
155
158
|
- !ruby/object:Gem::Version
|
156
159
|
version: '0'
|
157
160
|
requirements: []
|
158
161
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.2.
|
162
|
+
rubygems_version: 2.2.2
|
160
163
|
signing_key:
|
161
164
|
specification_version: 4
|
162
165
|
summary: Bulk-loading extension for ActiveRecord
|
@@ -200,6 +203,8 @@ test_files:
|
|
200
203
|
- test/support/postgresql/import_examples.rb
|
201
204
|
- test/synchronize_test.rb
|
202
205
|
- test/test_helper.rb
|
206
|
+
- test/travis/build.sh
|
207
|
+
- test/travis/database.yml
|
203
208
|
- test/value_sets_bytes_parser_test.rb
|
204
209
|
- test/value_sets_records_parser_test.rb
|
205
210
|
has_rdoc:
|