ruby-app-ar 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,9 +3,12 @@ RubyAppAr
3
3
 
4
4
  [RubyApp](http://github.com/kostya/ruby-app) extension, adds ActiveRecord support.
5
5
 
6
+ Install
7
+ -------
8
+
6
9
  Use generator:
7
10
 
8
- ruby-app new_app -ar
11
+ ruby-app new app --ar
9
12
 
10
13
 
11
14
  ### OR Manually
@@ -25,5 +28,15 @@ Create
25
28
 
26
29
  db/migrate
27
30
  config/database.yml
31
+
32
+
33
+ Using
34
+ -----
35
+
36
+ Use as it is in Rails. But use APP_ENV for specify environment.
37
+
38
+ Examples:
39
+
40
+ $ rake db:create APP_ENV=test
41
+ $ rake db:migrate
28
42
 
29
-
@@ -0,0 +1,17 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ require 'active_record'
4
+
5
+ # establish connection
6
+ ActiveRecord::Base.configurations = App.config.database_yml
7
+ ActiveRecord::Base.establish_connection App.config.database_settings
8
+
9
+ if ActiveRecord::VERSION::MAJOR == 2
10
+
11
+ class RubyAppDumpLogger
12
+ def method_missing(method, *args)
13
+ end
14
+ end
15
+
16
+ ActiveRecord::Base.logger = RubyAppDumpLogger.new
17
+ end
@@ -9,7 +9,7 @@ if defined?(Application) && (Application.send(:identifier) rescue '-') == 'ruby-
9
9
  # add initializers
10
10
  App.initializer_paths << [
11
11
  File.join(File.dirname(__FILE__), %w{ config.rb }),
12
- File.join(File.dirname(__FILE__), %w{ activerecord.rb })
12
+ File.join(File.dirname(__FILE__), %w{ init-activerecord.rb })
13
13
  ].map{|f| File.expand_path(f) }
14
14
 
15
15
  end
@@ -187,7 +187,7 @@ namespace :db do
187
187
  end
188
188
 
189
189
  desc "Raises an error if there are pending migrations"
190
- task :abort_if_pending_migrations => :environment do
190
+ task :pending_migrations => :environment do
191
191
  if defined? ActiveRecord
192
192
  pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations
193
193
 
@@ -381,7 +381,11 @@ def drop_database(config)
381
381
  when 'mysql'
382
382
  ActiveRecord::Base.connection.drop_database config['database']
383
383
  when /^sqlite/
384
- FileUtils.rm(File.join(Application.root, config['database']))
384
+ if config['database'].start_with?('db')
385
+ FileUtils.rm(File.join(Application.root, config['database']))
386
+ else
387
+ FileUtils.rm(config['database'])
388
+ end
385
389
  when 'postgresql'
386
390
  ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
387
391
  ActiveRecord::Base.connection.drop_database config['database']
@@ -1,3 +1,3 @@
1
1
  module RubyAppAr
2
- VERSION = "0.1"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-app-ar
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- version: "0.1"
9
+ - 1
10
+ version: 0.1.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Makarchev Konstantin
@@ -14,11 +15,10 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2012-06-22 00:00:00 Z
18
+ date: 2012-06-23 00:00:00 Z
18
19
  dependencies:
19
20
  - !ruby/object:Gem::Dependency
20
- name: activerecord
21
- prerelease: false
21
+ type: :runtime
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
@@ -28,11 +28,11 @@ dependencies:
28
28
  segments:
29
29
  - 0
30
30
  version: "0"
31
- type: :runtime
32
31
  version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: ruby-app
35
32
  prerelease: false
33
+ name: activerecord
34
+ - !ruby/object:Gem::Dependency
35
+ type: :runtime
36
36
  requirement: &id002 !ruby/object:Gem::Requirement
37
37
  none: false
38
38
  requirements:
@@ -44,11 +44,11 @@ dependencies:
44
44
  - 1
45
45
  - 4
46
46
  version: 0.1.4
47
- type: :runtime
48
47
  version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: rspec
51
48
  prerelease: false
49
+ name: ruby-app
50
+ - !ruby/object:Gem::Dependency
51
+ type: :development
52
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
@@ -58,11 +58,11 @@ dependencies:
58
58
  segments:
59
59
  - 0
60
60
  version: "0"
61
- type: :development
62
61
  version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: rake
65
62
  prerelease: false
63
+ name: rspec
64
+ - !ruby/object:Gem::Dependency
65
+ type: :development
66
66
  requirement: &id004 !ruby/object:Gem::Requirement
67
67
  none: false
68
68
  requirements:
@@ -72,11 +72,11 @@ dependencies:
72
72
  segments:
73
73
  - 0
74
74
  version: "0"
75
- type: :development
76
75
  version_requirements: *id004
77
- - !ruby/object:Gem::Dependency
78
- name: sqlite3
79
76
  prerelease: false
77
+ name: rake
78
+ - !ruby/object:Gem::Dependency
79
+ type: :development
80
80
  requirement: &id005 !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
@@ -86,8 +86,9 @@ dependencies:
86
86
  segments:
87
87
  - 0
88
88
  version: "0"
89
- type: :development
90
89
  version_requirements: *id005
90
+ prerelease: false
91
+ name: sqlite3
91
92
  description: RubyApp extension, adds ActiveRecord support
92
93
  email: kostya27@gmail.com
93
94
  executables: []
@@ -102,8 +103,8 @@ files:
102
103
  - LICENSE
103
104
  - README.md
104
105
  - Rakefile
105
- - lib/activerecord.rb
106
106
  - lib/config.rb
107
+ - lib/init-activerecord.rb
107
108
  - lib/ruby-app-ar.rb
108
109
  - lib/ruby-app-ar/tasks.rake
109
110
  - lib/version.rb
@@ -1,6 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- require 'active_record'
4
-
5
- # establish connection
6
- ActiveRecord::Base.establish_connection App.config.database_settings