mass_insert 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +5 -13
  2. data/.gitignore +2 -0
  3. data/.travis.yml +12 -10
  4. data/Gemfile +9 -8
  5. data/LICENSE.txt +1 -1
  6. data/README.md +34 -78
  7. data/Rakefile +19 -24
  8. data/lib/mass_insert/adapters/abstract_adapter.rb +54 -0
  9. data/lib/mass_insert/adapters/mysql2_adapter.rb +5 -0
  10. data/lib/mass_insert/adapters/postgresql_adapter.rb +5 -0
  11. data/lib/mass_insert/adapters/sqlite3_adapter.rb +5 -0
  12. data/lib/mass_insert/base.rb +3 -84
  13. data/lib/mass_insert/builder.rb +8 -0
  14. data/lib/mass_insert/executer.rb +2 -6
  15. data/lib/mass_insert/process.rb +14 -14
  16. data/lib/mass_insert/utilities.rb +25 -0
  17. data/lib/mass_insert/version.rb +1 -1
  18. data/lib/mass_insert.rb +9 -5
  19. data/mass_insert.gemspec +10 -10
  20. data/test/adapters/mysql2/example_test.rb +3 -0
  21. data/test/adapters/postgresql/example_test.rb +3 -0
  22. data/test/adapters/sqlite3/example_test.rb +3 -0
  23. data/test/database.yml.example +18 -0
  24. data/test/models/user.rb +2 -0
  25. data/test/schema.rb +11 -0
  26. data/test/support/adapters/mysql2.rb +1 -0
  27. data/test/support/adapters/postgresql.rb +1 -0
  28. data/test/support/adapters/sqlite3.rb +1 -0
  29. data/test/support/shared_examples.rb +57 -0
  30. data/test/test_helper.rb +20 -0
  31. metadata +42 -188
  32. data/.rvmrc +0 -62
  33. data/lib/mass_insert/builder/adapters/adapter.rb +0 -52
  34. data/lib/mass_insert/builder/adapters/helpers/abstract_query.rb +0 -52
  35. data/lib/mass_insert/builder/adapters/helpers/column_value.rb +0 -90
  36. data/lib/mass_insert/builder/adapters/mysql2_adapter.rb +0 -7
  37. data/lib/mass_insert/builder/adapters/postgresql_adapter.rb +0 -7
  38. data/lib/mass_insert/builder/adapters/sqlite3_adapter.rb +0 -27
  39. data/lib/mass_insert/builder/adapters/sqlserver_adapter.rb +0 -20
  40. data/lib/mass_insert/builder/adapters.rb +0 -16
  41. data/lib/mass_insert/builder/base.rb +0 -28
  42. data/lib/mass_insert/builder/utilities.rb +0 -13
  43. data/lib/mass_insert/result.rb +0 -33
  44. data/spec/adapters/column_types/binary_spec.rb +0 -64
  45. data/spec/adapters/column_types/boolean_spec.rb +0 -48
  46. data/spec/adapters/column_types/date_spec.rb +0 -14
  47. data/spec/adapters/column_types/datetime_spec.rb +0 -14
  48. data/spec/adapters/column_types/decimal_spec.rb +0 -59
  49. data/spec/adapters/column_types/integer_spec.rb +0 -59
  50. data/spec/adapters/column_types/string_spec.rb +0 -46
  51. data/spec/adapters/column_types/time_spec.rb +0 -14
  52. data/spec/adapters/model_spec.rb +0 -83
  53. data/spec/dummy/.gitignore +0 -15
  54. data/spec/dummy/Gemfile +0 -40
  55. data/spec/dummy/README.rdoc +0 -261
  56. data/spec/dummy/Rakefile +0 -7
  57. data/spec/dummy/app/assets/images/rails.png +0 -0
  58. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  59. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  60. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  61. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  62. data/spec/dummy/app/mailers/.gitkeep +0 -0
  63. data/spec/dummy/app/models/.gitkeep +0 -0
  64. data/spec/dummy/app/models/user.rb +0 -3
  65. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  66. data/spec/dummy/config/application.rb +0 -68
  67. data/spec/dummy/config/boot.rb +0 -6
  68. data/spec/dummy/config/database.yml +0 -49
  69. data/spec/dummy/config/environment.rb +0 -5
  70. data/spec/dummy/config/environments/development.rb +0 -37
  71. data/spec/dummy/config/environments/mysql2.rb +0 -37
  72. data/spec/dummy/config/environments/postgresql.rb +0 -37
  73. data/spec/dummy/config/environments/production.rb +0 -67
  74. data/spec/dummy/config/environments/sqlite3.rb +0 -37
  75. data/spec/dummy/config/environments/test.rb +0 -37
  76. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  77. data/spec/dummy/config/initializers/inflections.rb +0 -15
  78. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  79. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  80. data/spec/dummy/config/initializers/session_store.rb +0 -8
  81. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  82. data/spec/dummy/config/locales/en.yml +0 -5
  83. data/spec/dummy/config/routes.rb +0 -58
  84. data/spec/dummy/config.ru +0 -4
  85. data/spec/dummy/db/migrate/20130412154541_create_users.rb +0 -16
  86. data/spec/dummy/db/schema.rb +0 -29
  87. data/spec/dummy/db/seeds.rb +0 -7
  88. data/spec/dummy/lib/assets/.gitkeep +0 -0
  89. data/spec/dummy/lib/tasks/.gitkeep +0 -0
  90. data/spec/dummy/log/.gitkeep +0 -0
  91. data/spec/dummy/public/404.html +0 -26
  92. data/spec/dummy/public/422.html +0 -26
  93. data/spec/dummy/public/500.html +0 -25
  94. data/spec/dummy/public/favicon.ico +0 -0
  95. data/spec/dummy/public/index.html +0 -241
  96. data/spec/dummy/public/robots.txt +0 -5
  97. data/spec/dummy/script/rails +0 -6
  98. data/spec/dummy/vendor/assets/javascripts/.gitkeep +0 -0
  99. data/spec/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
  100. data/spec/dummy/vendor/plugins/.gitkeep +0 -0
  101. data/spec/lib/mass_insert/base_spec.rb +0 -40
  102. data/spec/lib/mass_insert/builder/adapters/adapter_spec.rb +0 -116
  103. data/spec/lib/mass_insert/builder/adapters/helpers/abstract_query_spec.rb +0 -130
  104. data/spec/lib/mass_insert/builder/adapters/helpers/column_value_spec.rb +0 -222
  105. data/spec/lib/mass_insert/builder/adapters/mysql_adapter_spec.rb +0 -9
  106. data/spec/lib/mass_insert/builder/adapters/postgresql_adapter_spec.rb +0 -9
  107. data/spec/lib/mass_insert/builder/adapters/sqlite3_adapter_spec.rb +0 -52
  108. data/spec/lib/mass_insert/builder/adapters/sqlserver_adapter_spec.rb +0 -32
  109. data/spec/lib/mass_insert/builder/adapters_spec.rb +0 -31
  110. data/spec/lib/mass_insert/builder/base_spec.rb +0 -28
  111. data/spec/lib/mass_insert/builder/utilities_spec.rb +0 -11
  112. data/spec/lib/mass_insert/executer_spec.rb +0 -33
  113. data/spec/lib/mass_insert/process_spec.rb +0 -58
  114. data/spec/lib/mass_insert/result_spec.rb +0 -45
  115. data/spec/lib/mass_insert_spec.rb +0 -35
  116. data/spec/spec_helper.rb +0 -15
  117. data/spec/support/mass_insert_support.rb +0 -12
@@ -1,58 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module MassInsert
4
- describe Process do
5
- let!(:subject){ described_class.new("values", "options") }
6
-
7
- describe "#initialize" do
8
- it "sets instance values variable" do
9
- expect(subject.instance_variable_get(:@values)).to eq("values")
10
- end
11
-
12
- it "sets instance options variable" do
13
- expect(subject.instance_variable_get(:@options)).to eq("options")
14
- end
15
- end
16
-
17
- describe "#start" do
18
- before :each do
19
- Builder::Base.any_instance.stub(:build).and_return("queries")
20
- Executer.any_instance.stub(:execute)
21
- end
22
-
23
- it "calls method to build the queries" do
24
- Builder::Base.any_instance.should_receive(:build).with("values", "options")
25
- subject.start
26
- end
27
-
28
- it "calls method to execute the queries" do
29
- Executer.any_instance.should_receive(:execute).with("queries")
30
- subject.start
31
- end
32
-
33
- it "sets instance building_time variable" do
34
- subject.start
35
- building_time = subject.instance_variable_get(:@building_time)
36
- expect(building_time).to be_an_instance_of(Benchmark::Tms)
37
- end
38
-
39
- it "sets instance execution_time variable" do
40
- subject.start
41
- execution_time = subject.instance_variable_get(:@execution_time)
42
- expect(execution_time).to be_an_instance_of(Benchmark::Tms)
43
- end
44
- end
45
-
46
- describe '#builder' do
47
- it 'returns new Builder::Base instace' do
48
- expect(subject.builder).to be_an_instance_of(Builder::Base)
49
- end
50
- end
51
-
52
- describe '#executer' do
53
- it 'returns new Executer instace' do
54
- expect(subject.executer).to be_an_instance_of(Executer)
55
- end
56
- end
57
- end
58
- end
@@ -1,45 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe MassInsert::Result do
4
- let!(:values) { [{name: "name"}] }
5
- let!(:options){ {option: "value"} }
6
- let!(:process){ MassInsert::Process.new(values, options) }
7
- let!(:subject){ MassInsert::Result.new(process) }
8
-
9
- before :each do
10
- benchmark = Benchmark.measure{}
11
- benchmark.stub(:total).and_return(10)
12
- process.instance_variable_set(:@building_time, benchmark)
13
- process.instance_variable_set(:@execution_time, benchmark)
14
- end
15
-
16
- describe "initialize" do
17
- it "sets instance process variable" do
18
- expect(subject.instance_variable_get(:@process)).to eq(process)
19
- end
20
- end
21
-
22
- describe "#building_time" do
23
- it "returns instance building_time variable in process instance" do
24
- expect(subject.building_time).to be(10)
25
- end
26
- end
27
-
28
- describe "#execution_time" do
29
- it "returns instance execution_time variable in process instance" do
30
- expect(subject.execution_time).to be(10)
31
- end
32
- end
33
-
34
- describe "#time" do
35
- it "sums building_time and execution_time" do
36
- expect(subject.time).to be(20)
37
- end
38
- end
39
-
40
- describe "#records" do
41
- it "returns size of instance values variable in process instance" do
42
- expect(subject.records).to be(1)
43
- end
44
- end
45
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe MassInsert do
4
- it 'loads Base module' do
5
- expect(described_class::Base).to be
6
- end
7
-
8
- it 'loads Result class' do
9
- expect(described_class::Result).to be
10
- end
11
-
12
- it 'loads Process class' do
13
- expect(described_class::Process).to be
14
- end
15
-
16
- it 'loads Executer class' do
17
- expect(described_class::Executer).to be
18
- end
19
-
20
- it 'loads VERSION constant' do
21
- expect(described_class::VERSION).to be
22
- end
23
-
24
- it 'loads Builder Base module' do
25
- expect(described_class::Builder::Base).to be
26
- end
27
-
28
- it 'loads Builder Adapters module' do
29
- expect(described_class::Builder::Adapters).to be
30
- end
31
-
32
- it 'loads Builder Utilities module' do
33
- expect(described_class::Builder::Utilities).to be
34
- end
35
- end
data/spec/spec_helper.rb DELETED
@@ -1,15 +0,0 @@
1
- require 'coveralls'
2
- Coveralls.wear!
3
- Coveralls::Output.silent = true
4
-
5
- require 'dummy/config/environment'
6
- require 'simplecov'
7
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
8
-
9
- SimpleCov.start do
10
- minimum_coverage 90
11
- end
12
-
13
- RSpec.configure do |config|
14
- config.extend MassInsertSupport
15
- end
@@ -1,12 +0,0 @@
1
- module MassInsertSupport
2
-
3
- def adapters_supported
4
- {
5
- "mysql2" => "Mysql2Adapter",
6
- "postgresql" => "PostgreSQLAdapter",
7
- "sqlite3" => "SQLite3Adapter",
8
- "sqlserver" => "SQLServerAdapter"
9
- }
10
- end
11
-
12
- end