snapshots 0.0.1 → 0.0.2
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.
- data/VERSION +1 -1
- data/lib/snapshots/app.rb +24 -7
- data/snapshots.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/snapshots/app.rb
CHANGED
@@ -7,9 +7,14 @@ module Snapshots
|
|
7
7
|
:banner => 'rails_root',
|
8
8
|
:group => 'Global'
|
9
9
|
|
10
|
+
class_option :environment, :default => (ENV['RAILS_ENV'] || 'development'), :type => :string,
|
11
|
+
:desc => 'Rails environment',
|
12
|
+
:banner => 'env',
|
13
|
+
:group => 'Global'
|
14
|
+
|
10
15
|
desc 'list', 'List all snapshots for a rails app.'
|
11
16
|
def list
|
12
|
-
goto_rails
|
17
|
+
goto_rails do
|
13
18
|
|
14
19
|
Snapshots.find.each do |snapshot|
|
15
20
|
snapshot =~ /snapshot_(\d+)\.rb$/
|
@@ -22,7 +27,7 @@ module Snapshots
|
|
22
27
|
|
23
28
|
desc 'dump', 'Make a new snapshot.'
|
24
29
|
def dump
|
25
|
-
goto_rails
|
30
|
+
goto_rails do
|
26
31
|
load_environment!
|
27
32
|
|
28
33
|
begin
|
@@ -38,7 +43,7 @@ module Snapshots
|
|
38
43
|
|
39
44
|
desc 'load VERSION', 'Restore a snapshot.'
|
40
45
|
def load(version)
|
41
|
-
goto_rails
|
46
|
+
goto_rails do
|
42
47
|
load_environment!
|
43
48
|
|
44
49
|
begin
|
@@ -54,7 +59,7 @@ module Snapshots
|
|
54
59
|
|
55
60
|
desc 'install', 'Install rake tasks in rails app.'
|
56
61
|
def install
|
57
|
-
goto_rails
|
62
|
+
goto_rails do
|
58
63
|
File.open('lib/tasks/snapshots.rake', 'w+') do |f|
|
59
64
|
f.write <<-EOR
|
60
65
|
begin
|
@@ -72,11 +77,16 @@ EOR
|
|
72
77
|
private
|
73
78
|
|
74
79
|
def load_environment!
|
80
|
+
Object.const_set('RAILS_ROOT', rails_root) rescue nil
|
81
|
+
ENV['RAILS_ENV'] = environment
|
75
82
|
$rails_rake_task = true
|
76
83
|
require(File.join(RAILS_ROOT, 'config', 'environment'))
|
77
84
|
end
|
78
85
|
|
79
|
-
def
|
86
|
+
def rails_root
|
87
|
+
return @rails_root if @rails_root
|
88
|
+
|
89
|
+
root_path = self.options.app
|
80
90
|
root_path = File.expand_path(root_path)
|
81
91
|
|
82
92
|
unless File.directory?(root_path) and File.file?(File.join(root_path, 'config', 'environment.rb'))
|
@@ -84,8 +94,15 @@ EOR
|
|
84
94
|
exit(1)
|
85
95
|
end
|
86
96
|
|
87
|
-
|
88
|
-
|
97
|
+
@rails_root = root_path
|
98
|
+
end
|
99
|
+
|
100
|
+
def environment
|
101
|
+
self.options.environment
|
102
|
+
end
|
103
|
+
|
104
|
+
def goto_rails(&proc)
|
105
|
+
Dir.chdir(rails_root, &proc)
|
89
106
|
end
|
90
107
|
|
91
108
|
end
|
data/snapshots.gemspec
CHANGED