rails-bigint-pk 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/.gitignore +8 -0
  2. data/.rspec +2 -0
  3. data/.rvmrc +1 -0
  4. data/.travis.yml +3 -0
  5. data/.vim/snippets/rspec.snippets +4 -0
  6. data/.vimrc +2 -0
  7. data/Changelog +11 -0
  8. data/Gemfile +4 -0
  9. data/Guardfile +20 -0
  10. data/LICENSE +7 -0
  11. data/Rakefile +6 -0
  12. data/Readme.md +61 -0
  13. data/lib/bigint_pk.rb +92 -0
  14. data/lib/bigint_pk/version.rb +3 -0
  15. data/lib/generators/bigint_pk.rb +5 -0
  16. data/lib/generators/bigint_pk/install_generator.rb +21 -0
  17. data/lib/generators/bigint_pk/templates/bigint_pk.rb +9 -0
  18. data/lib/generators/bigint_pk/templates/migration.rb +20 -0
  19. data/rails-bigint-pk.gemspec +37 -0
  20. data/spec/fixtures/Gemfile +8 -0
  21. data/spec/fixtures/mysql_database.yml +13 -0
  22. data/spec/fixtures/postgresql_database.yml +12 -0
  23. data/spec/fixtures/sqlite3_database.yml +11 -0
  24. data/spec/fixtures/test_rails_app/app/models/empire.rb +2 -0
  25. data/spec/fixtures/test_rails_app/app/models/ruler.rb +4 -0
  26. data/spec/fixtures/test_rails_app/db/migrate/19000101100000_create_empires_and_rulers.rb +10 -0
  27. data/spec/fixtures/test_rails_app/db/migrate/19000102100000_update_rulers_add_favourite_ruler.rb +7 -0
  28. data/spec/integration/generator_spec.rb +40 -0
  29. data/spec/integration/schema_spec.rb +222 -0
  30. data/spec/migration_spec.rb +102 -0
  31. data/spec/monkey_patch/connection_adapters_spec.rb +149 -0
  32. data/spec/spec_helper.rb +61 -0
  33. data/spec/support/cmd.rb +42 -0
  34. data/spec/support/file_utils.rb +7 -0
  35. data/spec/support/logging.rb +5 -0
  36. data/spec/support/rails.rb +32 -0
  37. data/spec/support/rspec.rb +3 -0
  38. metadata +340 -0
@@ -0,0 +1,61 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'bigint_pk'
4
+ require 'fileutils'
5
+ require 'active_record'
6
+ Dir["#{File.dirname __FILE__}/support/**"].each{|f| require f }
7
+
8
+ RSpec.configure do |c|
9
+ c.treat_symbols_as_metadata_keys_with_true_values = true
10
+
11
+ c.include Module.new{
12
+ Root = File.expand_path "#{File.dirname __FILE__}/.."
13
+ TmpDir = File.expand_path "#{Root}/tmp"
14
+ RailsAppName = "test_rails_app"
15
+ RailsDir = "#{TmpDir}/#{RailsAppName}"
16
+ FixturesDir = "#{Root}/spec/fixtures"
17
+ }
18
+
19
+ c.before :all, :integration do
20
+ log { %Q{ ENV:\n#{ENV.map{|k, v| "#{k}=#{v}"}}}}
21
+
22
+ FileUtils.mkdir_p TmpDir
23
+
24
+ in_directory TmpDir do
25
+ FileUtils.rm_rf RailsAppName
26
+ run "rails new #{RailsAppName}"
27
+ FileUtils.cp "#{FixturesDir}/Gemfile", "#{RailsDir}/Gemfile"
28
+ in_directory RailsDir do
29
+ Bundler.with_clean_env { run "bundle check || bundle install" }
30
+ end
31
+ File.open "#{RailsDir}/Gemfile", 'a' do |f|
32
+ f.puts %Q{gem 'rails-bigint-pk', path: '#{Root}'}
33
+ end
34
+ end
35
+
36
+ in_directory RailsDir do
37
+ %w(app/models db/migrate).each do |dir|
38
+ FileUtils.mkdir_p "#{RailsDir}/#{dir}"
39
+ FileUtils.cp_r Dir["#{FixturesDir}/test_rails_app/#{dir}/*.rb"],
40
+ "#{RailsDir}/#{dir}"
41
+ end
42
+
43
+ run "bundle install --binstubs"
44
+ run "git init && git add . && git commit -m 'Root'"
45
+ end
46
+ end
47
+
48
+ c.before :each, :integration do
49
+ in_directory RailsDir do
50
+ # Save anything done before :all
51
+ run 'git add . && git commit -m "test group setup"; true'
52
+ end
53
+ end
54
+
55
+ c.after :each, :integration do
56
+ in_directory RailsDir do
57
+ run 'git reset --hard'
58
+ run 'git clean -fd'
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,42 @@
1
+ require 'open3'
2
+
3
+ def run *args
4
+ _, stdout, stderr, wait_thr = Open3.popen3( *args )
5
+ cmd_process = wait_thr.value
6
+
7
+ log do
8
+ "(in #{Dir.pwd})
9
+ command: #{args.join ' '}"
10
+ end
11
+
12
+ unless cmd_process.success?
13
+ fail [
14
+ "Error",
15
+ "\n\nstdout:\n\n#{stdout.read}",
16
+ "\n\nstderr:\n\n#{stderr.read}"
17
+ ].join("\n")
18
+ end
19
+
20
+ if block_given?
21
+ yield stdout, stderr
22
+ else
23
+ output, error = stdout.read, stderr.read
24
+ log do
25
+ "stdout: #{output}
26
+ stderr: #{error}"
27
+ end
28
+ output.chomp
29
+ end
30
+ end
31
+
32
+ def rake task
33
+ bundle_exec "rake #{task}"
34
+ end
35
+
36
+ def bundle_exec command
37
+ in_directory( RailsDir) do
38
+ Bundler.with_clean_env do
39
+ run "bundle exec #{command}"
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,7 @@
1
+ def in_directory dir
2
+ previous_working_dir = FileUtils.pwd
3
+ FileUtils.cd dir
4
+ yield
5
+ ensure
6
+ FileUtils.cd previous_working_dir
7
+ end
@@ -0,0 +1,5 @@
1
+ # Switch to true to enable verbose logging.
2
+ $LOG = false
3
+ def log
4
+ STDERR.puts yield if $LOG
5
+ end
@@ -0,0 +1,32 @@
1
+ def use_database! db
2
+ src, dest =
3
+ case db
4
+ when :mysql
5
+ ["#{FixturesDir}/mysql_database.yml", "#{RailsDir}/config/database.yml"]
6
+ when :postgres
7
+ ["#{FixturesDir}/postgresql_database.yml", "#{RailsDir}/config/database.yml"]
8
+ when :sqlite3
9
+ ["#{FixturesDir}/sqlite3_database.yml", "#{RailsDir}/config/database.yml"]
10
+ end
11
+
12
+ log{ "copying #{src} to #{dest}" }
13
+ FileUtils.cp src, dest
14
+
15
+ rake 'db:drop'
16
+ rake 'db:create'
17
+ end
18
+
19
+ def execute_sql sql
20
+ File.open("#{TmpDir}/cmd.sql", 'w'){|f| f.print sql }
21
+ execute_ruby %Q{
22
+ sqls = File.read('#{TmpDir}/cmd.sql').gsub(/\\s+/, ' ').strip
23
+ sqls.split(';').each do |sql|
24
+ ActiveRecord::Base.connection.execute sql
25
+ end
26
+ }
27
+ end
28
+
29
+ def execute_ruby ruby
30
+ File.open("#{TmpDir}/cmd.rb", 'w'){|f| f.print ruby }
31
+ bundle_exec "rails runner #{TmpDir}/cmd.rb"
32
+ end
@@ -0,0 +1,3 @@
1
+ class << RSpec::Core::ExampleGroup
2
+ alias_method :they, :it
3
+ end
metadata ADDED
@@ -0,0 +1,340 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-bigint-pk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David J. Hamilton
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activerecord
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: railties
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 3.2.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 3.2.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: travis-lint
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rails
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: debugger
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: mysql2
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.3.10
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.3.10
126
+ - !ruby/object:Gem::Dependency
127
+ name: mysql
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 2.8.1
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 2.8.1
142
+ - !ruby/object:Gem::Dependency
143
+ name: pg
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: '0.11'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: '0.11'
158
+ - !ruby/object:Gem::Dependency
159
+ name: sqlite3
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: 1.3.6
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 1.3.6
174
+ - !ruby/object:Gem::Dependency
175
+ name: guard
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: guard-rspec
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: guard-bundler
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ - !ruby/object:Gem::Dependency
223
+ name: guard-ctags-bundler
224
+ requirement: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ! '>='
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
+ - !ruby/object:Gem::Dependency
239
+ name: rb-fsevent
240
+ requirement: !ruby/object:Gem::Requirement
241
+ none: false
242
+ requirements:
243
+ - - ! '>='
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
246
+ type: :development
247
+ prerelease: false
248
+ version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ! '>='
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
254
+ description: Easily use 64-bit primary keys in rails.
255
+ email:
256
+ - dhamilton@verticalresponse.com
257
+ executables: []
258
+ extensions: []
259
+ extra_rdoc_files: []
260
+ files:
261
+ - .gitignore
262
+ - .rspec
263
+ - .rvmrc
264
+ - .travis.yml
265
+ - .vim/snippets/rspec.snippets
266
+ - .vimrc
267
+ - Changelog
268
+ - Gemfile
269
+ - Guardfile
270
+ - LICENSE
271
+ - Rakefile
272
+ - Readme.md
273
+ - lib/bigint_pk.rb
274
+ - lib/bigint_pk/version.rb
275
+ - lib/generators/bigint_pk.rb
276
+ - lib/generators/bigint_pk/install_generator.rb
277
+ - lib/generators/bigint_pk/templates/bigint_pk.rb
278
+ - lib/generators/bigint_pk/templates/migration.rb
279
+ - rails-bigint-pk.gemspec
280
+ - spec/fixtures/Gemfile
281
+ - spec/fixtures/mysql_database.yml
282
+ - spec/fixtures/postgresql_database.yml
283
+ - spec/fixtures/sqlite3_database.yml
284
+ - spec/fixtures/test_rails_app/app/models/empire.rb
285
+ - spec/fixtures/test_rails_app/app/models/ruler.rb
286
+ - spec/fixtures/test_rails_app/db/migrate/19000101100000_create_empires_and_rulers.rb
287
+ - spec/fixtures/test_rails_app/db/migrate/19000102100000_update_rulers_add_favourite_ruler.rb
288
+ - spec/integration/generator_spec.rb
289
+ - spec/integration/schema_spec.rb
290
+ - spec/migration_spec.rb
291
+ - spec/monkey_patch/connection_adapters_spec.rb
292
+ - spec/spec_helper.rb
293
+ - spec/support/cmd.rb
294
+ - spec/support/file_utils.rb
295
+ - spec/support/logging.rb
296
+ - spec/support/rails.rb
297
+ - spec/support/rspec.rb
298
+ homepage: https://github.com/VerticalResponse/rails-bigint-pk
299
+ licenses: []
300
+ post_install_message:
301
+ rdoc_options: []
302
+ require_paths:
303
+ - lib
304
+ required_ruby_version: !ruby/object:Gem::Requirement
305
+ none: false
306
+ requirements:
307
+ - - ! '>='
308
+ - !ruby/object:Gem::Version
309
+ version: '0'
310
+ required_rubygems_version: !ruby/object:Gem::Requirement
311
+ none: false
312
+ requirements:
313
+ - - ! '>='
314
+ - !ruby/object:Gem::Version
315
+ version: '0'
316
+ requirements: []
317
+ rubyforge_project: rails-bigint-pk
318
+ rubygems_version: 1.8.25
319
+ signing_key:
320
+ specification_version: 3
321
+ summary: Easily use 64-bit primary keys in rails
322
+ test_files:
323
+ - spec/fixtures/Gemfile
324
+ - spec/fixtures/mysql_database.yml
325
+ - spec/fixtures/postgresql_database.yml
326
+ - spec/fixtures/sqlite3_database.yml
327
+ - spec/fixtures/test_rails_app/app/models/empire.rb
328
+ - spec/fixtures/test_rails_app/app/models/ruler.rb
329
+ - spec/fixtures/test_rails_app/db/migrate/19000101100000_create_empires_and_rulers.rb
330
+ - spec/fixtures/test_rails_app/db/migrate/19000102100000_update_rulers_add_favourite_ruler.rb
331
+ - spec/integration/generator_spec.rb
332
+ - spec/integration/schema_spec.rb
333
+ - spec/migration_spec.rb
334
+ - spec/monkey_patch/connection_adapters_spec.rb
335
+ - spec/spec_helper.rb
336
+ - spec/support/cmd.rb
337
+ - spec/support/file_utils.rb
338
+ - spec/support/logging.rb
339
+ - spec/support/rails.rb
340
+ - spec/support/rspec.rb