dump 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +1 -0
  3. data/.travis.database.yml +14 -0
  4. data/.travis.yml +30 -0
  5. data/Gemfile +20 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.markdown +5 -3
  8. data/dump.gemspec +1 -2
  9. data/lib/dump_rake/dump.rb +4 -0
  10. data/lib/dump_rake/dump_reader.rb +1 -1
  11. data/lib/dump_rake/dump_writer.rb +1 -1
  12. data/lib/dump_rake/table_manipulation.rb +1 -1
  13. data/spec/.gitignore +18 -0
  14. data/spec/cycle_spec.rb +22 -14
  15. data/spec/dummy-2.3/config/boot.rb +114 -0
  16. data/spec/dummy-2.3/config/database.yml +22 -0
  17. data/spec/dummy-2.3/config/environment.rb +41 -0
  18. data/spec/dummy-2.3/config/environments/development.rb +17 -0
  19. data/spec/dummy-2.3/config/environments/production.rb +28 -0
  20. data/spec/dummy-2.3/config/environments/test.rb +28 -0
  21. data/spec/dummy-2.3/config/initializers/backtrace_silencers.rb +7 -0
  22. data/spec/dummy-2.3/config/initializers/cookie_verification_secret.rb +7 -0
  23. data/spec/dummy-2.3/config/initializers/inflections.rb +10 -0
  24. data/spec/{dummy-3.1.3 → dummy-2.3}/config/initializers/mime_types.rb +0 -0
  25. data/spec/dummy-2.3/config/initializers/new_rails_defaults.rb +21 -0
  26. data/spec/dummy-2.3/config/initializers/session_store.rb +15 -0
  27. data/spec/dummy-2.3/config/locales/en.yml +5 -0
  28. data/spec/dummy-2.3/config/routes.rb +43 -0
  29. data/spec/dummy-2.3/db/seeds.rb +7 -0
  30. data/spec/dummy-3.0/.gitignore +4 -0
  31. data/spec/{dummy-3.1.3 → dummy-3.0}/config.ru +1 -1
  32. data/spec/dummy-3.0/config/application.rb +42 -0
  33. data/spec/{dummy-3.1.3 → dummy-3.0}/config/boot.rb +0 -0
  34. data/spec/dummy-3.0/config/database.yml +22 -0
  35. data/spec/{dummy-3.1.3 → dummy-3.0}/config/environment.rb +1 -1
  36. data/spec/dummy-3.0/config/environments/development.rb +26 -0
  37. data/spec/dummy-3.0/config/environments/production.rb +49 -0
  38. data/spec/dummy-3.0/config/environments/test.rb +35 -0
  39. data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/backtrace_silencers.rb +0 -0
  40. data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/inflections.rb +0 -0
  41. data/spec/dummy-3.0/config/initializers/mime_types.rb +5 -0
  42. data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/secret_token.rb +1 -1
  43. data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/session_store.rb +2 -2
  44. data/spec/dummy-3.0/config/locales/en.yml +5 -0
  45. data/spec/dummy-3.0/config/routes.rb +58 -0
  46. data/spec/dummy-3.0/db/seeds.rb +7 -0
  47. data/spec/{dummy-3.1.3 → dummy-3.1}/.gitignore +0 -0
  48. data/spec/dummy-3.1/config.ru +4 -0
  49. data/spec/{dummy-3.1.3 → dummy-3.1}/config/application.rb +2 -7
  50. data/spec/dummy-3.1/config/boot.rb +6 -0
  51. data/spec/{dummy-3.1.3 → dummy-3.1}/config/database.yml +0 -0
  52. data/spec/dummy-3.1/config/environment.rb +5 -0
  53. data/spec/{dummy-3.1.3 → dummy-3.1}/config/environments/development.rb +1 -6
  54. data/spec/{dummy-3.1.3 → dummy-3.1}/config/environments/production.rb +1 -14
  55. data/spec/{dummy-3.1.3 → dummy-3.1}/config/environments/test.rb +1 -1
  56. data/spec/dummy-3.1/config/initializers/backtrace_silencers.rb +7 -0
  57. data/spec/dummy-3.1/config/initializers/inflections.rb +10 -0
  58. data/spec/dummy-3.1/config/initializers/mime_types.rb +5 -0
  59. data/spec/dummy-3.1/config/initializers/secret_token.rb +7 -0
  60. data/spec/dummy-3.1/config/initializers/session_store.rb +8 -0
  61. data/spec/{dummy-3.1.3 → dummy-3.1}/config/initializers/wrap_parameters.rb +0 -0
  62. data/spec/{dummy-3.1.3 → dummy-3.1}/config/locales/en.yml +0 -0
  63. data/spec/{dummy-3.1.3 → dummy-3.1}/config/routes.rb +1 -1
  64. data/spec/{dummy-3.1.3 → dummy-3.1}/db/seeds.rb +0 -0
  65. data/spec/{dummy-3.1.3/app/mailers → dummy-3.1/log}/.gitkeep +0 -0
  66. data/spec/dummy-3.2/.gitignore +15 -0
  67. data/spec/dummy-3.2/config.ru +4 -0
  68. data/spec/dummy-3.2/config/application.rb +63 -0
  69. data/spec/dummy-3.2/config/boot.rb +6 -0
  70. data/spec/dummy-3.2/config/database.yml +25 -0
  71. data/spec/dummy-3.2/config/environment.rb +5 -0
  72. data/spec/dummy-3.2/config/environments/development.rb +32 -0
  73. data/spec/dummy-3.2/config/environments/production.rb +54 -0
  74. data/spec/dummy-3.2/config/environments/test.rb +37 -0
  75. data/spec/dummy-3.2/config/initializers/backtrace_silencers.rb +7 -0
  76. data/spec/dummy-3.2/config/initializers/inflections.rb +15 -0
  77. data/spec/dummy-3.2/config/initializers/mime_types.rb +5 -0
  78. data/spec/dummy-3.2/config/initializers/secret_token.rb +7 -0
  79. data/spec/dummy-3.2/config/initializers/session_store.rb +8 -0
  80. data/spec/dummy-3.2/config/initializers/wrap_parameters.rb +14 -0
  81. data/spec/dummy-3.2/config/locales/en.yml +5 -0
  82. data/spec/dummy-3.2/config/routes.rb +58 -0
  83. data/spec/dummy-3.2/db/seeds.rb +7 -0
  84. data/spec/{dummy-3.1.3/app/models → dummy-3.2/log}/.gitkeep +0 -0
  85. data/spec/dummy-4.0/.gitignore +16 -0
  86. data/spec/dummy-4.0/config.ru +4 -0
  87. data/spec/dummy-4.0/config/application.rb +31 -0
  88. data/spec/dummy-4.0/config/boot.rb +4 -0
  89. data/spec/dummy-4.0/config/database.yml +25 -0
  90. data/spec/dummy-4.0/config/environment.rb +5 -0
  91. data/spec/dummy-4.0/config/environments/development.rb +25 -0
  92. data/spec/dummy-4.0/config/environments/production.rb +65 -0
  93. data/spec/dummy-4.0/config/environments/test.rb +36 -0
  94. data/spec/dummy-4.0/config/initializers/backtrace_silencers.rb +7 -0
  95. data/spec/dummy-4.0/config/initializers/filter_parameter_logging.rb +4 -0
  96. data/spec/dummy-4.0/config/initializers/inflections.rb +16 -0
  97. data/spec/dummy-4.0/config/initializers/mime_types.rb +5 -0
  98. data/spec/dummy-4.0/config/initializers/secret_token.rb +12 -0
  99. data/spec/dummy-4.0/config/initializers/session_store.rb +3 -0
  100. data/spec/dummy-4.0/config/initializers/wrap_parameters.rb +14 -0
  101. data/spec/dummy-4.0/config/locales/en.yml +23 -0
  102. data/spec/dummy-4.0/config/routes.rb +56 -0
  103. data/spec/dummy-4.0/db/seeds.rb +7 -0
  104. data/spec/{dummy-3.1.3/lib/assets/.gitkeep → dummy-4.0/log/.keep} +0 -0
  105. data/spec/lib/dump_rake/dump_reader_spec.rb +90 -89
  106. data/spec/lib/dump_rake/dump_spec.rb +9 -9
  107. data/spec/lib/dump_rake/dump_writer_spec.rb +79 -78
  108. data/spec/lib/dump_rake/rails_root_spec.rb +2 -2
  109. data/spec/lib/dump_rake/table_manipulation_spec.rb +10 -10
  110. data/spec/lib/dump_rake_spec.rb +34 -34
  111. data/spec/recipes/dump_spec.rb +34 -34
  112. data/spec/spec_helper.rb +35 -10
  113. data/spec/tasks/assets_spec.rb +6 -6
  114. metadata +240 -183
  115. data/spec/dummy-3.1.3/.rspec +0 -1
  116. data/spec/dummy-3.1.3/Gemfile +0 -14
  117. data/spec/dummy-3.1.3/Gemfile.lock +0 -133
  118. data/spec/dummy-3.1.3/README +0 -261
  119. data/spec/dummy-3.1.3/Rakefile +0 -7
  120. data/spec/dummy-3.1.3/app/assets/images/rails.png +0 -0
  121. data/spec/dummy-3.1.3/app/assets/javascripts/application.js +0 -9
  122. data/spec/dummy-3.1.3/app/assets/stylesheets/application.css +0 -7
  123. data/spec/dummy-3.1.3/app/controllers/application_controller.rb +0 -3
  124. data/spec/dummy-3.1.3/app/helpers/application_helper.rb +0 -2
  125. data/spec/dummy-3.1.3/app/views/layouts/application.html.erb +0 -14
  126. data/spec/dummy-3.1.3/doc/README_FOR_APP +0 -2
  127. data/spec/dummy-3.1.3/lib/tasks/.gitkeep +0 -0
  128. data/spec/dummy-3.1.3/log/.gitkeep +0 -0
  129. data/spec/dummy-3.1.3/public/404.html +0 -26
  130. data/spec/dummy-3.1.3/public/422.html +0 -26
  131. data/spec/dummy-3.1.3/public/500.html +0 -26
  132. data/spec/dummy-3.1.3/public/favicon.ico +0 -0
  133. data/spec/dummy-3.1.3/public/index.html +0 -241
  134. data/spec/dummy-3.1.3/public/robots.txt +0 -5
  135. data/spec/dummy-3.1.3/script/rails +0 -6
  136. data/spec/dummy-3.1.3/spec/spec_helper.rb +0 -32
  137. data/spec/dummy-3.1.3/vendor/assets/stylesheets/.gitkeep +0 -0
  138. data/spec/dummy-3.1.3/vendor/plugins/.gitkeep +0 -0
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2EzOWRiZTc2MWU1MDNiYWE5YzJjZjQzMDcwZjAwMTdhM2ExYmIzNQ==
5
+ data.tar.gz: !binary |-
6
+ Y2YxZDcwMjZjZjY4ZjBhYTM1ZjdhMTBjN2FkZjViZjc1NTExZGE3YQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ Y2JmYjU5ODAwZGZhMmM1M2EwNjFkZmNiMjJhZDEwNjlkZDZjMjMxNGM1YzMw
10
+ MTZiODc2ZmI5YzA2ZTUzNTU5ZDhlNzZmMzRlZTUyZTA3M2UzOGNkMTQ2ZTI0
11
+ NTRkYjlkNDc3OTY5MmE2ODFlNjhhYjE2MzQ2MDY4Y2NjZGIyMWQ=
12
+ data.tar.gz: !binary |-
13
+ NjRjYTYxZjIyZGJiZTI4OTM2OWJmZGRkOGZlNjNiODkxYjEwM2I3NWFjNWM4
14
+ YjI1ZDNiNGM3NWM2Njg1NGU3ZGI5NjlhZmI2ZjE3NWRiMWRjYjk3NGU1MzM5
15
+ Njg0YjNhNjQwMjhiYmMyY2IwMzk3OWIyZDVlZGFjYWE1ZTNjMWE=
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /.yardoc/
7
7
  /coverage/
8
8
 
9
+ Gemfile.lock
9
10
  Makefile
10
11
  *.o
11
12
  *.bundle
@@ -0,0 +1,14 @@
1
+ sqlite3:
2
+ adapter: sqlite3
3
+ database: ':memory:'
4
+
5
+ mysql:
6
+ adapter: mysql2
7
+ database: myapp_test
8
+ username: travis
9
+ encoding: utf8
10
+
11
+ postgresql:
12
+ adapter: postgresql
13
+ database: myapp_test
14
+ username: postgres
@@ -0,0 +1,30 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - jruby-19mode
7
+ - rbx-19mode
8
+ - ree
9
+ env:
10
+ - RAILS_VERSION='~> 2.3.0'
11
+ # - RAILS_VERSION='~> 3.0.0' # conflicting adapters for postgresql and mysql2
12
+ - RAILS_VERSION='~> 3.1.0'
13
+ - RAILS_VERSION='~> 3.2.0'
14
+ - RAILS_VERSION='~> 4.0.0'
15
+ script: "bundle exec rspec"
16
+ before_install:
17
+ - mysql -e 'create database myapp_test;'
18
+ - psql -c 'create database myapp_test;' -U postgres
19
+ - cp .travis.database.yml spec/db/database.yml
20
+ matrix:
21
+ allow_failures:
22
+ - rvm: jruby-19mode
23
+ - rvm: rbx-19mode
24
+ exclude:
25
+ - rvm: 1.8.7 # not supported by rails 4
26
+ env: RAILS_VERSION='~> 4.0.0'
27
+ - rvm: ree # not supported by rails 4
28
+ env: RAILS_VERSION='~> 4.0.0'
29
+ - rvm: 2.0.0 # problems with iconv
30
+ env: RAILS_VERSION='~> 2.3.0'
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ source 'http://rubygems.org'
2
+
3
+ rails_version = ENV['RAILS_VERSION'] || '~> 4.0'
4
+ gem 'rails', rails_version
5
+
6
+ if defined?(JRUBY_VERSION)
7
+ gem 'activerecord-jdbcsqlite3-adapter'
8
+ gem 'activerecord-jdbcmysql-adapter'
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ else
11
+ gem 'sqlite3'
12
+ gem 'mysql2'
13
+ gem 'pg'
14
+ if rails_version =~ /(^|[^.\d])(2|3\.0)\.\d+/
15
+ gem 'activerecord-mysql2-adapter'
16
+ end
17
+ end
18
+
19
+ gem 'capistrano'
20
+ gemspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2012 Ivan Kuchin
1
+ Copyright (c) 2008-2013 Ivan Kuchin
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -2,9 +2,11 @@
2
2
 
3
3
  Rails app rake and capistrano tasks to create and restore dumps of database and assets.
4
4
 
5
- Works with rails 2 and rails 3.
5
+ Tested against rails 2.3, 3.0, 3.1, 3.2 and 4.0 (rails 2.3 has problems on ruby 2.0).
6
6
 
7
- Requires at least ruby 1.8.7, tested with ruby 1.9.
7
+ Works with ruby 1.8.7, ree, 1.9, 2.0 (rails 4.0 requires at least ruby 1.9).
8
+
9
+ [![Build Status](https://travis-ci.org/toy/dump.png?branch=master)](https://travis-ci.org/toy/dump)
8
10
 
9
11
  ## Install
10
12
 
@@ -247,4 +249,4 @@ restore backup (upload dump and restore on remote):
247
249
 
248
250
  ## Copyright
249
251
 
250
- Copyright (c) 2008-2012 Ivan Kuchin. See LICENSE.txt for details.
252
+ Copyright (c) 2008-2013 Ivan Kuchin. See LICENSE.txt for details.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'dump'
5
- s.version = '1.0.2'
5
+ s.version = '1.0.3'
6
6
  s.summary = %q{Rails app rake and capistrano tasks to create and restore dumps of database and assets}
7
7
  s.homepage = "http://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
@@ -18,5 +18,4 @@ Gem::Specification.new do |s|
18
18
  s.add_dependency 'archive-tar-minitar', '= 0.5.2'
19
19
  s.add_dependency 'progress', '~> 2.4.0'
20
20
  s.add_development_dependency 'rspec'
21
- s.add_development_dependency 'sqlite3'
22
21
  end
@@ -118,6 +118,10 @@ class DumpRake
118
118
  end
119
119
  end
120
120
 
121
+ def silence(&block)
122
+ Rails.logger.silence(&block)
123
+ end
124
+
121
125
  protected
122
126
 
123
127
  def assets_root_link
@@ -4,7 +4,7 @@ class DumpRake
4
4
 
5
5
  def self.restore(path)
6
6
  new(path).open do |dump|
7
- ActiveRecord::Base.logger.silence do
7
+ dump.silence do
8
8
  dump.read_config
9
9
  dump.migrate_down
10
10
  dump.read_schema
@@ -4,7 +4,7 @@ class DumpRake
4
4
 
5
5
  def self.create(path)
6
6
  new(path).open do |dump|
7
- ActiveRecord::Base.logger.silence do
7
+ dump.silence do
8
8
  dump.write_schema
9
9
 
10
10
  dump.write_tables
@@ -112,7 +112,7 @@ class DumpRake
112
112
  rows = select_all_by_sql(select_where_primary_key % '>= 0')
113
113
  until rows.blank?
114
114
  rows.each(&block)
115
- break if rows.length < chunk_size
115
+ break if rows.count < chunk_size
116
116
  rows = select_all_by_sql(select_where_primary_key % "> #{rows.last[primary_key].to_i}")
117
117
  end
118
118
  else
@@ -1 +1,19 @@
1
1
  /db/database.yml
2
+
3
+ /dummy-*/.bundle/
4
+ /dummy-*/db/*.sqlite3
5
+ /dummy-*/db/*.sqlite3-journal
6
+ /dummy-*/log/*.log
7
+ /dummy-*/tmp/
8
+
9
+ /dummy-*/app/
10
+ /dummy-*/bin/
11
+ /dummy-*/doc/
12
+ /dummy-*/Gemfile
13
+ /dummy-*/lib/
14
+ /dummy-*/public/
15
+ /dummy-*/Rakefile
16
+ /dummy-*/README*
17
+ /dummy-*/script/
18
+ /dummy-*/test/
19
+ /dummy-*/vendor/
@@ -16,10 +16,12 @@ def use_adapter(adapter)
16
16
  case config['adapter']
17
17
  when /^mysql/
18
18
  ActiveRecord::Base.establish_connection(config.merge('database' => nil))
19
+ ActiveRecord::Base.connection.drop_database config['database'] rescue nil
19
20
  ActiveRecord::Base.connection.create_database(config['database'])
20
21
  ActiveRecord::Base.establish_connection(config)
21
22
  when /^postgresql/
22
23
  ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
24
+ ActiveRecord::Base.connection.drop_database config['database'] rescue nil
23
25
  ActiveRecord::Base.connection.create_database(config['database'])
24
26
  ActiveRecord::Base.establish_connection(config)
25
27
  else
@@ -52,7 +54,7 @@ def in_temp_rails_app
52
54
  DumpRake::RailsRoot.replace(File.join(PLUGIN_SPEC_DIR, 'temp_rails_app'))
53
55
  FileUtils.remove_entry(DumpRake::RailsRoot) if File.exist?(DumpRake::RailsRoot)
54
56
  FileUtils.mkpath(DumpRake::RailsRoot)
55
- Progress.stub!(:io).and_return(StringIO.new)
57
+ Progress.stub(:io).and_return(StringIO.new)
56
58
  yield
57
59
  ensure
58
60
  FileUtils.remove_entry(DumpRake::RailsRoot) if File.exist?(DumpRake::RailsRoot)
@@ -74,22 +76,28 @@ def create_chickens!(options = {})
74
76
  :boolean => [true, false],
75
77
  }
76
78
  Chicken.create!
77
- data.each do |type, values|
78
- values.each do |value|
79
- Chicken.create!("#{type}_col" => value)
79
+ data.values.map(&:length).max.times do |i|
80
+ Chicken.create! do |chicken|
81
+ data.each do |type, values|
82
+ chicken["#{type}_col"] = values[i]
83
+ end
80
84
  end
81
85
  end
82
86
  if options[:random]
83
87
  options[:random].to_i.times do
84
- attributes = {}
85
- data.each do |type, values|
86
- attributes["#{type}_col"] = values[rand(values.length)] if rand > 0.5
88
+ Chicken.create! do |chicken|
89
+ data.each do |type, values|
90
+ chicken["#{type}_col"] = values[rand(values.length)] if rand > 0.5
91
+ end
87
92
  end
88
- Chicken.create!(attributes)
89
93
  end
90
94
  end
91
95
  end
92
96
 
97
+ def chicken_data
98
+ Chicken.all.map(&:attributes).sort_by{ |attributes| attributes['id'] }
99
+ end
100
+
93
101
  def reset_rake!
94
102
  @rake = Rake::Application.new
95
103
  Rake.application = @rake
@@ -139,7 +147,7 @@ describe 'full cycle' do
139
147
  use_adapter(adapter) do
140
148
  #add chickens store their attributes and create dump
141
149
  create_chickens!(:random => 100)
142
- chicken_attributes = Chicken.all.map(&:attributes)
150
+ saved_chicken_data = chicken_data
143
151
  call_rake_create(:description => 'chickens')
144
152
 
145
153
  #clear database
@@ -148,14 +156,14 @@ describe 'full cycle' do
148
156
 
149
157
  #restore dump and verify equality
150
158
  call_rake_restore(:version => 'chickens')
151
- Chicken.all.map(&:attributes).should == chicken_attributes
159
+ chicken_data.should == saved_chicken_data
152
160
 
153
161
  # go throught create/restore cycle and verify equality
154
162
  call_rake_create
155
163
  load_schema
156
164
  Chicken.all.should be_empty
157
165
  call_rake_restore
158
- Chicken.all.map(&:attributes).should == chicken_attributes
166
+ chicken_data.should == saved_chicken_data
159
167
  end
160
168
  end
161
169
  end
@@ -178,12 +186,12 @@ describe 'full cycle' do
178
186
  adapters.combination(2) do |adapter_src, adapter_dst|
179
187
  it "should dump using #{adapter_src} and restore using #{adapter_dst}" do
180
188
  in_temp_rails_app do
181
- chicken_attributes = nil
189
+ saved_chicken_data = nil
182
190
  use_adapter(adapter_src) do
183
191
  Chicken.all.should be_empty
184
192
 
185
193
  create_chickens!(:random => 100)
186
- chicken_attributes = Chicken.all.map(&:attributes)
194
+ saved_chicken_data = chicken_data
187
195
  call_rake_create
188
196
  end
189
197
 
@@ -191,7 +199,7 @@ describe 'full cycle' do
191
199
  Chicken.all.should be_empty
192
200
 
193
201
  call_rake_restore
194
- chicken_attributes.should == Chicken.all.map(&:attributes)
202
+ chicken_data.should == saved_chicken_data
195
203
  end
196
204
  end
197
205
  end
@@ -0,0 +1,114 @@
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
3
+
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
+
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
14
+
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
26
+
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exist?(preinitializer_path)
29
+ end
30
+
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
35
+
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
42
+
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ Rails::Initializer.run(:install_gem_spec_stubs)
47
+ Rails::GemDependency.add_frozen_gem_path
48
+ end
49
+ end
50
+
51
+ class GemBoot < Boot
52
+ def load_initializer
53
+ self.class.load_rubygems
54
+ load_rails_gem
55
+ require 'initializer'
56
+ end
57
+
58
+ def load_rails_gem
59
+ if version = self.class.gem_version
60
+ gem 'rails', version
61
+ else
62
+ gem 'rails'
63
+ end
64
+ rescue Gem::LoadError => load_error
65
+ if load_error.message =~ /Could not find RubyGem rails/
66
+ STDERR.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
67
+ exit 1
68
+ else
69
+ raise
70
+ end
71
+ end
72
+
73
+ class << self
74
+ def rubygems_version
75
+ Gem::RubyGemsVersion rescue nil
76
+ end
77
+
78
+ def gem_version
79
+ if defined? RAILS_GEM_VERSION
80
+ RAILS_GEM_VERSION
81
+ elsif ENV.include?('RAILS_GEM_VERSION')
82
+ ENV['RAILS_GEM_VERSION']
83
+ else
84
+ parse_gem_version(read_environment_rb)
85
+ end
86
+ end
87
+
88
+ def load_rubygems
89
+ min_version = '1.3.2'
90
+ require 'rubygems'
91
+ unless rubygems_version >= min_version
92
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
93
+ exit 1
94
+ end
95
+
96
+ rescue LoadError
97
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
98
+ exit 1
99
+ end
100
+
101
+ def parse_gem_version(text)
102
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
103
+ end
104
+
105
+ private
106
+ def read_environment_rb
107
+ File.read("#{RAILS_ROOT}/config/environment.rb")
108
+ end
109
+ end
110
+ end
111
+ end
112
+
113
+ # All that for this:
114
+ Rails.boot!
@@ -0,0 +1,22 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: db/production.sqlite3
21
+ pool: 5
22
+ timeout: 5000
@@ -0,0 +1,41 @@
1
+ # Be sure to restart your server when you modify this file
2
+
3
+ # Specifies gem version of Rails to use when vendor/rails is not present
4
+ RAILS_GEM_VERSION = '2.3.18' unless defined? RAILS_GEM_VERSION
5
+
6
+ # Bootstrap the Rails environment, frameworks, and default configuration
7
+ require File.join(File.dirname(__FILE__), 'boot')
8
+
9
+ Rails::Initializer.run do |config|
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Add additional load paths for your own custom dirs
15
+ # config.autoload_paths += %W( #{RAILS_ROOT}/extras )
16
+
17
+ # Specify gems that this application depends on and have them installed with rake gems:install
18
+ # config.gem "bj"
19
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
20
+ # config.gem "sqlite3-ruby", :lib => "sqlite3"
21
+ # config.gem "aws-s3", :lib => "aws/s3"
22
+
23
+ # Only load the plugins named here, in the order given (default is alphabetical).
24
+ # :all can be used as a placeholder for all plugins not explicitly named
25
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26
+
27
+ # Skip frameworks you're not going to use. To use Rails without a database,
28
+ # you must remove the Active Record framework.
29
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
30
+
31
+ # Activate observers that should always be running
32
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
33
+
34
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
35
+ # Run "rake -D time" for a list of tasks for finding time zone names.
36
+ config.time_zone = 'UTC'
37
+
38
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
39
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
40
+ # config.i18n.default_locale = :de
41
+ end