sinatra-activerecord 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: df482d4502c4ec453c920973b1d320b52bf73004
4
+ data.tar.gz: 71444319646733beec15f7870d705f032ed8f8fe
5
+ SHA512:
6
+ metadata.gz: aaf20aefd61ec304017921ac7b7fc596ee21cfaf8000a2f8d252d0e7301613fa450f59f1c0138f80dc98fdb272dc3e12025b23c1c04e2221e81512413e1c4e1b
7
+ data.tar.gz: 60f09420981822a3c263d6c8cd39fd3a60077846266b62ad3897c446d09e4850d5fa1a2c5968cfaec9f96b0499136a3c7b22babb7da13f29e7a1c5eee43f44cd
data/README.md CHANGED
@@ -12,6 +12,7 @@ simplicity, let's assume you're using SQLite:
12
12
  ```ruby
13
13
  gem "sinatra-activerecord"
14
14
  gem "sqlite3"
15
+ gem "rake"
15
16
  ```
16
17
 
17
18
  Now require it in your Sinatra application, and establish the database
@@ -52,7 +52,7 @@ module Sinatra
52
52
  app.helpers ActiveRecordHelper
53
53
 
54
54
  # re-connect if database connection dropped
55
- app.before { ActiveRecord::Base.verify_active_connections! }
55
+ app.before { ActiveRecord::Base.verify_active_connections! if ActiveRecord::Base.respond_to?(:verify_active_connections!) }
56
56
  app.after { ActiveRecord::Base.clear_active_connections! }
57
57
  end
58
58
 
@@ -41,6 +41,24 @@ module Sinatra
41
41
  end
42
42
  end
43
43
 
44
+ def dump_schema(file_name = 'db/schema.rb')
45
+ silence_activerecord do
46
+ ActiveRecord::Migration.suppress_messages do
47
+ # Create file
48
+ out = File.new(file_name, 'w')
49
+
50
+ # Load schema
51
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, out)
52
+
53
+ out.close
54
+ end
55
+ end
56
+ end
57
+
58
+ def load_schema(file_name = 'db/schema.rb')
59
+ load(file_name)
60
+ end
61
+
44
62
  private
45
63
 
46
64
  def migrations_dir
@@ -9,10 +9,24 @@ namespace :db do
9
9
  desc "migrate the database (use version with VERSION=n)"
10
10
  task :migrate do
11
11
  Sinatra::ActiveRecordTasks.migrate(ENV["VERSION"])
12
+ Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
12
13
  end
13
14
 
14
15
  desc "roll back the migration (use steps with STEP=n)"
15
16
  task :rollback do
16
17
  Sinatra::ActiveRecordTasks.rollback(ENV["STEP"])
18
+ Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
19
+ end
20
+
21
+ namespace :schema do
22
+ desc "dump schema into file"
23
+ task :dump do
24
+ Sinatra::ActiveRecordTasks.dump_schema()
25
+ end
26
+
27
+ desc "load schema into database"
28
+ task :load do
29
+ Sinatra::ActiveRecordTasks.load_schema()
30
+ end
17
31
  end
18
32
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
5
- prerelease:
4
+ version: 1.2.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Blake Mizerany
@@ -10,12 +9,11 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-02-12 00:00:00.000000000 Z
12
+ date: 2013-06-26 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: sinatra
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
@@ -23,7 +21,6 @@ dependencies:
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ~>
29
26
  - !ruby/object:Gem::Version
@@ -31,65 +28,57 @@ dependencies:
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: activerecord
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ~>
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '3.0'
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ~>
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: '3.0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rake
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - '>='
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - '>='
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: rspec
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - '>='
69
61
  - !ruby/object:Gem::Version
70
62
  version: '2.10'
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - '>='
77
68
  - !ruby/object:Gem::Version
78
69
  version: '2.10'
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: sqlite3
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
- - - ! '>='
74
+ - - '>='
85
75
  - !ruby/object:Gem::Version
86
76
  version: '0'
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
- - - ! '>='
81
+ - - '>='
93
82
  - !ruby/object:Gem::Version
94
83
  version: '0'
95
84
  description: Extends Sinatra with ActiveRecord helpers.
@@ -106,29 +95,25 @@ files:
106
95
  homepage: http://github.com/janko-m/sinatra-activerecord
107
96
  licenses:
108
97
  - MIT
98
+ metadata: {}
109
99
  post_install_message:
110
100
  rdoc_options: []
111
101
  require_paths:
112
102
  - lib
113
103
  required_ruby_version: !ruby/object:Gem::Requirement
114
- none: false
115
104
  requirements:
116
- - - ! '>='
105
+ - - '>='
117
106
  - !ruby/object:Gem::Version
118
107
  version: 1.9.2
119
108
  required_rubygems_version: !ruby/object:Gem::Requirement
120
- none: false
121
109
  requirements:
122
- - - ! '>='
110
+ - - '>='
123
111
  - !ruby/object:Gem::Version
124
112
  version: '0'
125
- segments:
126
- - 0
127
- hash: -897588111
128
113
  requirements: []
129
114
  rubyforge_project:
130
- rubygems_version: 1.8.23
115
+ rubygems_version: 2.0.2
131
116
  signing_key:
132
- specification_version: 3
117
+ specification_version: 4
133
118
  summary: Extends Sinatra with ActiveRecord helpers.
134
119
  test_files: []