fast_seeder 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/{README.md → README.markdown} +11 -2
  3. data/Rakefile +3 -1
  4. data/lib/fast_seeder/version.rb +1 -1
  5. data/spec/dummy/Rakefile +7 -0
  6. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  7. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  8. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  9. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  10. data/spec/dummy/app/models/book.rb +2 -0
  11. data/spec/dummy/app/models/book_without_timestamps.rb +3 -0
  12. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  13. data/spec/dummy/config.ru +4 -0
  14. data/spec/dummy/config/application.rb +53 -0
  15. data/spec/dummy/config/boot.rb +10 -0
  16. data/spec/dummy/config/database.yml +60 -0
  17. data/spec/dummy/config/environment.rb +5 -0
  18. data/spec/dummy/config/environments/development.rb +30 -0
  19. data/spec/dummy/config/environments/production.rb +80 -0
  20. data/spec/dummy/config/environments/test.rb +36 -0
  21. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  22. data/spec/dummy/config/initializers/inflections.rb +15 -0
  23. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  24. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  25. data/spec/dummy/config/initializers/session_store.rb +8 -0
  26. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  27. data/spec/dummy/config/locales/en.yml +5 -0
  28. data/spec/dummy/config/routes.rb +58 -0
  29. data/spec/dummy/db/development.sqlite3 +0 -0
  30. data/spec/dummy/db/migrate/20120805115707_create_books.rb +11 -0
  31. data/spec/dummy/db/migrate/20120805151848_create_books_without_timestamps.rb +9 -0
  32. data/spec/dummy/db/schema.rb +30 -0
  33. data/spec/dummy/db/test.sqlite3 +0 -0
  34. data/spec/dummy/log/development.log +757 -0
  35. data/spec/dummy/log/test.log +1226 -0
  36. data/spec/dummy/public/404.html +26 -0
  37. data/spec/dummy/public/422.html +26 -0
  38. data/spec/dummy/public/500.html +25 -0
  39. data/spec/dummy/public/favicon.ico +0 -0
  40. data/spec/dummy/script/rails +6 -0
  41. data/spec/lib/fast_seeder_spec.rb +109 -0
  42. data/spec/spec_helper.rb +16 -0
  43. metadata +121 -67
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,109 @@
1
+ require 'spec_helper'
2
+
3
+ describe FastSeeder do
4
+ let(:idiot_attrs) {{ :name => "The Idiot" , :published_in => 1868 }}
5
+ let(:crime_attrs) {{ :name => "Crime and Punishment", :published_in => 1866 }}
6
+ let(:idiot_book) { Book.where(idiot_attrs).first }
7
+ let(:crime_book) { Book.where(crime_attrs).first }
8
+
9
+
10
+ describe '.seed_csv!' do
11
+ before :all do
12
+ file = Tempfile.new('books')
13
+ file.write(
14
+ "Crime and Punishment,1866\n" \
15
+ "The Idiot,1868\n"
16
+ )
17
+ file.close
18
+ @seeds_path, @csv_file = File.dirname(file.path), File.basename(file.path)
19
+ end
20
+
21
+ before do
22
+ FastSeeder.stub(:seeds_path => @seeds_path)
23
+ end
24
+
25
+
26
+ context 'without default values' do
27
+ before { FastSeeder.seed_csv!(Book, @csv_file, :name, :published_in) }
28
+
29
+ it 'populates only with CSV data' do
30
+ Book.count.should == 2
31
+ idiot_book.should_not be_nil
32
+ crime_book.should_not be_nil
33
+ end
34
+
35
+ it 'populates timestamps with now' do
36
+ idiot_book.created_at.should be_within(1.minute).of(Time.zone.now)
37
+ idiot_book.updated_at.should be_within(1.minute).of(Time.zone.now)
38
+ end
39
+ end
40
+
41
+ context 'with default values' do
42
+ it 'populates with CSV and default values' do
43
+ FastSeeder.seed_csv!(Book, @csv_file, :name, :published_in, :author => "Dostoyevsky F.M.")
44
+
45
+ idiot_book.author.should == "Dostoyevsky F.M."
46
+ crime_book.author.should == "Dostoyevsky F.M."
47
+ end
48
+ end
49
+
50
+ context 'with timestamps as default values' do
51
+ it 'populates with timestamps as well' do
52
+ created_time = Time.parse("2010-01-01 00:00:00")
53
+ updated_time = Time.parse("2012-06-07 08:15:30")
54
+
55
+ FastSeeder.seed_csv!(Book, @csv_file, :name, :published_in, :created_at => created_time, :updated_at => updated_time)
56
+
57
+ idiot_book.created_at.should == created_time
58
+ idiot_book.updated_at.should == updated_time
59
+ end
60
+ end
61
+
62
+ context 'when model has no timestamps' do
63
+ it 'populates as expected' do
64
+ BookWithoutTimestamps.column_names.should_not include('created_at')
65
+ BookWithoutTimestamps.column_names.should_not include('updated_at')
66
+
67
+ FastSeeder.seed_csv!(BookWithoutTimestamps, @csv_file, :name, :published_in, :author => "Dostoyevsky F.M.")
68
+
69
+ BookWithoutTimestamps.count.should == 2
70
+ BookWithoutTimestamps.where(idiot_attrs).should_not be_empty
71
+ BookWithoutTimestamps.where(crime_attrs).should_not be_empty
72
+ end
73
+ end
74
+ end
75
+
76
+
77
+ describe '.seed!' do
78
+ context 'without default values' do
79
+ it 'populates data' do
80
+ FastSeeder.seed!(Book, :name, :published_in) do
81
+ record "Crime and Punishment", 1866
82
+ record "The Idiot" , 1868
83
+ end
84
+ Book.count.should == 2
85
+ idiot_book.should_not be_nil
86
+ crime_book.should_not be_nil
87
+ end
88
+ end
89
+
90
+ context 'with default values' do
91
+ it 'populates with default values' do
92
+ FastSeeder.seed!(Book, :name, :published_in, :author => "Dostoyevsky F.M.") do
93
+ record "Crime and Punishment", 1866
94
+ record "The Idiot" , 1868
95
+ end
96
+ Book.count.should == 2
97
+ idiot_book.author.should == "Dostoyevsky F.M."
98
+ crime_book.author.should == "Dostoyevsky F.M."
99
+ end
100
+ end
101
+ end
102
+
103
+ context 'no block is passed' do
104
+ it 'raises error' do
105
+ expect { FastSeeder.seed!(Book, :name) }.
106
+ to raise_error(FastSeeder::Error, "`FastSeeder.seed!` requires a block to be passed")
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+
3
+ # Configure Rails Envinronment
4
+ ENV["RAILS_ENV"] ||= "test"
5
+
6
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
7
+ require 'rspec/autorun'
8
+ require 'rspec/rails'
9
+ require 'pry'
10
+
11
+ RSpec.configure do |config|
12
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
13
+ config.use_transactional_fixtures = true
14
+ config.infer_base_class_for_anonymous_controllers = false
15
+ end
16
+
metadata CHANGED
@@ -1,95 +1,149 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fast_seeder
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Sergey Potapov
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2012-08-05 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2014-05-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: rails
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 7
29
- segments:
30
- - 3
31
- - 0
32
- version: "3.0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
33
20
  type: :runtime
34
- version_requirements: *id001
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
35
27
  description: Speeds up seeding database using multiple SQL inserts
36
- email:
28
+ email:
37
29
  - blake131313@gmail.com
38
30
  executables: []
39
-
40
31
  extensions: []
41
-
42
32
  extra_rdoc_files: []
43
-
44
- files:
45
- - lib/fast_seeder/version.rb
46
- - lib/fast_seeder/seeders.rb
47
- - lib/fast_seeder/seeders/inline_seeder.rb
48
- - lib/fast_seeder/seeders/csv_seeder.rb
49
- - lib/fast_seeder/seeders/base_seeder.rb
33
+ files:
34
+ - LGPL-LICENSE
35
+ - README.markdown
36
+ - Rakefile
37
+ - lib/fast_seeder.rb
50
38
  - lib/fast_seeder/adapters.rb
51
- - lib/fast_seeder/record_set.rb
39
+ - lib/fast_seeder/adapters/base_adapter.rb
40
+ - lib/fast_seeder/adapters/mysql_adapter.rb
52
41
  - lib/fast_seeder/adapters/postgresql_adapter.rb
53
42
  - lib/fast_seeder/adapters/sqlite_adapter.rb
54
- - lib/fast_seeder/adapters/mysql_adapter.rb
55
- - lib/fast_seeder/adapters/base_adapter.rb
56
43
  - lib/fast_seeder/error.rb
57
- - lib/fast_seeder.rb
58
- - LGPL-LICENSE
59
- - Rakefile
60
- - README.md
44
+ - lib/fast_seeder/record_set.rb
45
+ - lib/fast_seeder/seeders.rb
46
+ - lib/fast_seeder/seeders/base_seeder.rb
47
+ - lib/fast_seeder/seeders/csv_seeder.rb
48
+ - lib/fast_seeder/seeders/inline_seeder.rb
49
+ - lib/fast_seeder/version.rb
50
+ - spec/dummy/Rakefile
51
+ - spec/dummy/app/assets/javascripts/application.js
52
+ - spec/dummy/app/assets/stylesheets/application.css
53
+ - spec/dummy/app/controllers/application_controller.rb
54
+ - spec/dummy/app/helpers/application_helper.rb
55
+ - spec/dummy/app/models/book.rb
56
+ - spec/dummy/app/models/book_without_timestamps.rb
57
+ - spec/dummy/app/views/layouts/application.html.erb
58
+ - spec/dummy/config.ru
59
+ - spec/dummy/config/application.rb
60
+ - spec/dummy/config/boot.rb
61
+ - spec/dummy/config/database.yml
62
+ - spec/dummy/config/environment.rb
63
+ - spec/dummy/config/environments/development.rb
64
+ - spec/dummy/config/environments/production.rb
65
+ - spec/dummy/config/environments/test.rb
66
+ - spec/dummy/config/initializers/backtrace_silencers.rb
67
+ - spec/dummy/config/initializers/inflections.rb
68
+ - spec/dummy/config/initializers/mime_types.rb
69
+ - spec/dummy/config/initializers/secret_token.rb
70
+ - spec/dummy/config/initializers/session_store.rb
71
+ - spec/dummy/config/initializers/wrap_parameters.rb
72
+ - spec/dummy/config/locales/en.yml
73
+ - spec/dummy/config/routes.rb
74
+ - spec/dummy/db/development.sqlite3
75
+ - spec/dummy/db/migrate/20120805115707_create_books.rb
76
+ - spec/dummy/db/migrate/20120805151848_create_books_without_timestamps.rb
77
+ - spec/dummy/db/schema.rb
78
+ - spec/dummy/db/test.sqlite3
79
+ - spec/dummy/log/development.log
80
+ - spec/dummy/log/test.log
81
+ - spec/dummy/public/404.html
82
+ - spec/dummy/public/422.html
83
+ - spec/dummy/public/500.html
84
+ - spec/dummy/public/favicon.ico
85
+ - spec/dummy/script/rails
86
+ - spec/lib/fast_seeder_spec.rb
87
+ - spec/spec_helper.rb
61
88
  homepage: https://github.com/greyblake/fast_seeder
62
89
  licenses: []
63
-
90
+ metadata: {}
64
91
  post_install_message:
65
92
  rdoc_options: []
66
-
67
- require_paths:
93
+ require_paths:
68
94
  - lib
69
- required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
- requirements:
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
72
97
  - - ">="
73
- - !ruby/object:Gem::Version
74
- hash: 3
75
- segments:
76
- - 0
77
- version: "0"
78
- required_rubygems_version: !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
81
102
  - - ">="
82
- - !ruby/object:Gem::Version
83
- hash: 3
84
- segments:
85
- - 0
86
- version: "0"
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
87
105
  requirements: []
88
-
89
106
  rubyforge_project:
90
- rubygems_version: 1.8.15
107
+ rubygems_version: 2.2.2
91
108
  signing_key:
92
- specification_version: 3
109
+ specification_version: 4
93
110
  summary: Speeds up seeding database using multiple SQL inserts
94
- test_files: []
95
-
111
+ test_files:
112
+ - spec/dummy/public/422.html
113
+ - spec/dummy/public/404.html
114
+ - spec/dummy/public/favicon.ico
115
+ - spec/dummy/public/500.html
116
+ - spec/dummy/app/views/layouts/application.html.erb
117
+ - spec/dummy/app/models/book_without_timestamps.rb
118
+ - spec/dummy/app/models/book.rb
119
+ - spec/dummy/app/helpers/application_helper.rb
120
+ - spec/dummy/app/assets/javascripts/application.js
121
+ - spec/dummy/app/assets/stylesheets/application.css
122
+ - spec/dummy/app/controllers/application_controller.rb
123
+ - spec/dummy/script/rails
124
+ - spec/dummy/log/test.log
125
+ - spec/dummy/log/development.log
126
+ - spec/dummy/config.ru
127
+ - spec/dummy/Rakefile
128
+ - spec/dummy/db/schema.rb
129
+ - spec/dummy/db/test.sqlite3
130
+ - spec/dummy/db/development.sqlite3
131
+ - spec/dummy/db/migrate/20120805115707_create_books.rb
132
+ - spec/dummy/db/migrate/20120805151848_create_books_without_timestamps.rb
133
+ - spec/dummy/config/boot.rb
134
+ - spec/dummy/config/routes.rb
135
+ - spec/dummy/config/locales/en.yml
136
+ - spec/dummy/config/initializers/secret_token.rb
137
+ - spec/dummy/config/initializers/wrap_parameters.rb
138
+ - spec/dummy/config/initializers/inflections.rb
139
+ - spec/dummy/config/initializers/session_store.rb
140
+ - spec/dummy/config/initializers/backtrace_silencers.rb
141
+ - spec/dummy/config/initializers/mime_types.rb
142
+ - spec/dummy/config/application.rb
143
+ - spec/dummy/config/environments/production.rb
144
+ - spec/dummy/config/environments/test.rb
145
+ - spec/dummy/config/environments/development.rb
146
+ - spec/dummy/config/database.yml
147
+ - spec/dummy/config/environment.rb
148
+ - spec/spec_helper.rb
149
+ - spec/lib/fast_seeder_spec.rb