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.
- checksums.yaml +5 -13
- data/.gitignore +2 -0
- data/.travis.yml +12 -10
- data/Gemfile +9 -8
- data/LICENSE.txt +1 -1
- data/README.md +34 -78
- data/Rakefile +19 -24
- data/lib/mass_insert/adapters/abstract_adapter.rb +54 -0
- data/lib/mass_insert/adapters/mysql2_adapter.rb +5 -0
- data/lib/mass_insert/adapters/postgresql_adapter.rb +5 -0
- data/lib/mass_insert/adapters/sqlite3_adapter.rb +5 -0
- data/lib/mass_insert/base.rb +3 -84
- data/lib/mass_insert/builder.rb +8 -0
- data/lib/mass_insert/executer.rb +2 -6
- data/lib/mass_insert/process.rb +14 -14
- data/lib/mass_insert/utilities.rb +25 -0
- data/lib/mass_insert/version.rb +1 -1
- data/lib/mass_insert.rb +9 -5
- data/mass_insert.gemspec +10 -10
- data/test/adapters/mysql2/example_test.rb +3 -0
- data/test/adapters/postgresql/example_test.rb +3 -0
- data/test/adapters/sqlite3/example_test.rb +3 -0
- data/test/database.yml.example +18 -0
- data/test/models/user.rb +2 -0
- data/test/schema.rb +11 -0
- data/test/support/adapters/mysql2.rb +1 -0
- data/test/support/adapters/postgresql.rb +1 -0
- data/test/support/adapters/sqlite3.rb +1 -0
- data/test/support/shared_examples.rb +57 -0
- data/test/test_helper.rb +20 -0
- metadata +42 -188
- data/.rvmrc +0 -62
- data/lib/mass_insert/builder/adapters/adapter.rb +0 -52
- data/lib/mass_insert/builder/adapters/helpers/abstract_query.rb +0 -52
- data/lib/mass_insert/builder/adapters/helpers/column_value.rb +0 -90
- data/lib/mass_insert/builder/adapters/mysql2_adapter.rb +0 -7
- data/lib/mass_insert/builder/adapters/postgresql_adapter.rb +0 -7
- data/lib/mass_insert/builder/adapters/sqlite3_adapter.rb +0 -27
- data/lib/mass_insert/builder/adapters/sqlserver_adapter.rb +0 -20
- data/lib/mass_insert/builder/adapters.rb +0 -16
- data/lib/mass_insert/builder/base.rb +0 -28
- data/lib/mass_insert/builder/utilities.rb +0 -13
- data/lib/mass_insert/result.rb +0 -33
- data/spec/adapters/column_types/binary_spec.rb +0 -64
- data/spec/adapters/column_types/boolean_spec.rb +0 -48
- data/spec/adapters/column_types/date_spec.rb +0 -14
- data/spec/adapters/column_types/datetime_spec.rb +0 -14
- data/spec/adapters/column_types/decimal_spec.rb +0 -59
- data/spec/adapters/column_types/integer_spec.rb +0 -59
- data/spec/adapters/column_types/string_spec.rb +0 -46
- data/spec/adapters/column_types/time_spec.rb +0 -14
- data/spec/adapters/model_spec.rb +0 -83
- data/spec/dummy/.gitignore +0 -15
- data/spec/dummy/Gemfile +0 -40
- data/spec/dummy/README.rdoc +0 -261
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/user.rb +0 -3
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/config/application.rb +0 -68
- data/spec/dummy/config/boot.rb +0 -6
- data/spec/dummy/config/database.yml +0 -49
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/mysql2.rb +0 -37
- data/spec/dummy/config/environments/postgresql.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -67
- data/spec/dummy/config/environments/sqlite3.rb +0 -37
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -58
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/migrate/20130412154541_create_users.rb +0 -16
- data/spec/dummy/db/schema.rb +0 -29
- data/spec/dummy/db/seeds.rb +0 -7
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/lib/tasks/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/index.html +0 -241
- data/spec/dummy/public/robots.txt +0 -5
- data/spec/dummy/script/rails +0 -6
- data/spec/dummy/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/dummy/vendor/plugins/.gitkeep +0 -0
- data/spec/lib/mass_insert/base_spec.rb +0 -40
- data/spec/lib/mass_insert/builder/adapters/adapter_spec.rb +0 -116
- data/spec/lib/mass_insert/builder/adapters/helpers/abstract_query_spec.rb +0 -130
- data/spec/lib/mass_insert/builder/adapters/helpers/column_value_spec.rb +0 -222
- data/spec/lib/mass_insert/builder/adapters/mysql_adapter_spec.rb +0 -9
- data/spec/lib/mass_insert/builder/adapters/postgresql_adapter_spec.rb +0 -9
- data/spec/lib/mass_insert/builder/adapters/sqlite3_adapter_spec.rb +0 -52
- data/spec/lib/mass_insert/builder/adapters/sqlserver_adapter_spec.rb +0 -32
- data/spec/lib/mass_insert/builder/adapters_spec.rb +0 -31
- data/spec/lib/mass_insert/builder/base_spec.rb +0 -28
- data/spec/lib/mass_insert/builder/utilities_spec.rb +0 -11
- data/spec/lib/mass_insert/executer_spec.rb +0 -33
- data/spec/lib/mass_insert/process_spec.rb +0 -58
- data/spec/lib/mass_insert/result_spec.rb +0 -45
- data/spec/lib/mass_insert_spec.rb +0 -35
- data/spec/spec_helper.rb +0 -15
- 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
|