Empact-activerecord-import 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -36,7 +36,7 @@ namespace :display do
36
36
  end
37
37
  task :default => ["display:notice"]
38
38
 
39
- ADAPTERS = %w(mysql mysql2 postgresql sqlite3)
39
+ ADAPTERS = %w(mysql mysql2 jdbcmysql postgresql sqlite3)
40
40
  ADAPTERS.each do |adapter|
41
41
  namespace :test do
42
42
  desc "Runs #{adapter} database tests."
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
@@ -0,0 +1,6 @@
1
+ require "active_record/connection_adapters/mysql_adapter"
2
+ require "activerecord-import/adapters/mysql_adapter"
3
+
4
+ class ActiveRecord::ConnectionAdapters::MysqlAdapter
5
+ include ActiveRecord::Import::MysqlAdapter::InstanceMethods
6
+ end
@@ -1,60 +1,60 @@
1
1
  module ActiveRecord::Import::AbstractAdapter
2
2
  NO_MAX_PACKET = 0
3
3
  QUERY_OVERHEAD = 8 #This was shown to be true for MySQL, but it's not clear where the overhead is from.
4
-
4
+
5
5
  module ClassMethods
6
6
  def get_insert_value_sets( values, sql_size, max_bytes ) # :nodoc:
7
- value_sets = []
7
+ value_sets = []
8
8
  arr, current_arr_values_size, current_size = [], 0, 0
9
9
  values.each_with_index do |val,i|
10
10
  comma_bytes = arr.size
11
11
  sql_size_thus_far = sql_size + current_size + val.size + comma_bytes
12
12
  if NO_MAX_PACKET == max_bytes or sql_size_thus_far <= max_bytes
13
- current_size += val.size
13
+ current_size += val.bytesize
14
14
  arr << val
15
15
  else
16
16
  value_sets << arr
17
17
  arr = [ val ]
18
- current_size = val.size
18
+ current_size = val.bytesize
19
19
  end
20
-
20
+
21
21
  # if we're on the last iteration push whatever we have in arr to value_sets
22
22
  value_sets << arr if i == (values.size-1)
23
23
  end
24
24
  [ *value_sets ]
25
25
  end
26
26
  end
27
-
27
+
28
28
  module InstanceMethods
29
29
  def next_value_for_sequence(sequence_name)
30
30
  %{#{sequence_name}.nextval}
31
31
  end
32
-
33
- # +sql+ can be a single string or an array. If it is an array all
32
+
33
+ # +sql+ can be a single string or an array. If it is an array all
34
34
  # elements that are in position >= 1 will be appended to the final SQL.
35
35
  def insert_many( sql, values, *args ) # :nodoc:
36
36
  # the number of inserts default
37
37
  number_of_inserts = 0
38
-
38
+
39
39
  base_sql,post_sql = if sql.is_a?( String )
40
40
  [ sql, '' ]
41
41
  elsif sql.is_a?( Array )
42
42
  [ sql.shift, sql.join( ' ' ) ]
43
43
  end
44
-
45
- sql_size = QUERY_OVERHEAD + base_sql.size + post_sql.size
44
+
45
+ sql_size = QUERY_OVERHEAD + base_sql.size + post_sql.size
46
46
 
47
47
  # the number of bytes the requested insert statement values will take up
48
48
  values_in_bytes = values.sum {|value| value.size }
49
-
49
+
50
50
  # the number of bytes (commas) it will take to comma separate our values
51
51
  comma_separated_bytes = values.size-1
52
-
52
+
53
53
  # the total number of bytes required if this statement is one statement
54
54
  total_bytes = sql_size + values_in_bytes + comma_separated_bytes
55
-
55
+
56
56
  max = max_allowed_packet
57
-
57
+
58
58
  # if we can insert it all as one statement
59
59
  if NO_MAX_PACKET == max or total_bytes < max
60
60
  number_of_inserts += 1
@@ -23,6 +23,6 @@ end
23
23
 
24
24
 
25
25
  this_dir = Pathname.new File.dirname(__FILE__)
26
- require this_dir.join("import")
27
- require this_dir.join("active_record/adapters/abstract_adapter")
28
- require this_dir.join("synchronize")
26
+ require this_dir.join("import").to_s
27
+ require this_dir.join("active_record/adapters/abstract_adapter").to_s
28
+ require this_dir.join("synchronize").to_s
metadata CHANGED
@@ -1,76 +1,75 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: Empact-activerecord-import
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.4
4
5
  prerelease:
5
- version: 0.3.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Zach Dennis
9
9
  - Ben Woosley
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
-
14
- date: 2011-05-26 00:00:00 Z
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
13
+ date: 2011-08-16 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: activerecord
18
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2152287780 !ruby/object:Gem::Requirement
19
18
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
23
22
  version: 3.0.0
24
23
  type: :runtime
25
24
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *2152287780
26
+ - !ruby/object:Gem::Dependency
28
27
  name: rake
29
- requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirement: &2152285900 !ruby/object:Gem::Requirement
30
29
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
35
34
  type: :development
36
35
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *2152285900
37
+ - !ruby/object:Gem::Dependency
39
38
  name: jeweler
40
- requirement: &id003 !ruby/object:Gem::Requirement
39
+ requirement: &2152283860 !ruby/object:Gem::Requirement
41
40
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
45
44
  version: 1.4.0
46
45
  type: :development
47
46
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
47
+ version_requirements: *2152283860
48
+ - !ruby/object:Gem::Dependency
50
49
  name: activerecord
51
- requirement: &id004 !ruby/object:Gem::Requirement
50
+ requirement: &2152281560 !ruby/object:Gem::Requirement
52
51
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
56
55
  version: 3.0.0
57
56
  type: :runtime
58
57
  prerelease: false
59
- version_requirements: *id004
60
- description: Extraction of the ActiveRecord::Base#import functionality from ar-extensions for Rails 3 and beyond
58
+ version_requirements: *2152281560
59
+ description: Extraction of the ActiveRecord::Base#import functionality from ar-extensions
60
+ for Rails 3 and beyond
61
61
  email: ben.woosley@gmail.com
62
62
  executables: []
63
-
64
63
  extensions: []
65
-
66
- extra_rdoc_files:
64
+ extra_rdoc_files:
67
65
  - README.markdown
68
- files:
66
+ files:
69
67
  - README.markdown
70
68
  - Rakefile
71
69
  - VERSION
72
70
  - lib/activerecord-import.rb
73
71
  - lib/activerecord-import/active_record/adapters/abstract_adapter.rb
72
+ - lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb
74
73
  - lib/activerecord-import/active_record/adapters/mysql2_adapter.rb
75
74
  - lib/activerecord-import/active_record/adapters/mysql_adapter.rb
76
75
  - lib/activerecord-import/active_record/adapters/postgresql_adapter.rb
@@ -88,33 +87,29 @@ files:
88
87
  - lib/activerecord-import/synchronize.rb
89
88
  homepage: http://github.com/Empact/activerecord-import
90
89
  licenses: []
91
-
92
90
  post_install_message:
93
91
  rdoc_options: []
94
-
95
- require_paths:
92
+ require_paths:
96
93
  - lib
97
- required_ruby_version: !ruby/object:Gem::Requirement
94
+ required_ruby_version: !ruby/object:Gem::Requirement
98
95
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: -548077034181520687
103
- segments:
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ segments:
104
101
  - 0
105
- version: "0"
106
- required_rubygems_version: !ruby/object:Gem::Requirement
102
+ hash: 2262008768261655531
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
104
  none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: "0"
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
112
109
  requirements: []
113
-
114
110
  rubyforge_project:
115
- rubygems_version: 1.8.4
111
+ rubygems_version: 1.8.5
116
112
  signing_key:
117
113
  specification_version: 3
118
114
  summary: Bulk-loading extension for ActiveRecord
119
115
  test_files: []
120
-