ydd 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ydd/application.rb +9 -7
- data/lib/ydd/serialization_helper.rb +3 -1
- data/lib/ydd.rb +22 -4
- data/ydd.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/ydd/application.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'thor'
|
2
|
+
require 'ruby-debug'
|
2
3
|
|
3
4
|
module YDD
|
4
5
|
class Application < Thor
|
5
6
|
include Thor::Actions
|
6
7
|
|
7
|
-
method_options :env => :string, :force => :boolean
|
8
|
+
method_options :env => :string, :force => :boolean,
|
9
|
+
:skip_schema => :boolean, :skip_data => :boolean,
|
10
|
+
:tables => :string
|
8
11
|
|
9
12
|
desc "dump DUMP_DIR [APP_DIR='.'] [OPTIONS]", "Dumps the database contents and schema."
|
10
13
|
def dump(dump_dir, app_dir = ".")
|
@@ -27,7 +30,7 @@ module YDD
|
|
27
30
|
@app_dir = File.expand_path(app_dir)
|
28
31
|
@db_config = File.join(@app_dir, "config", "database.yml")
|
29
32
|
if !File.directory?(@app_dir)
|
30
|
-
die "The given application directory, #{@
|
33
|
+
die "The given application directory, #{@app_dir}, does not exist."
|
31
34
|
elsif !File.exist?(@db_config)
|
32
35
|
die "#{@db_config} does not exist."
|
33
36
|
elsif YDD.configuration_from(@db_config).blank?
|
@@ -38,7 +41,10 @@ module YDD
|
|
38
41
|
end
|
39
42
|
|
40
43
|
def setup!(dump_dir, app_dir, extra = {})
|
41
|
-
|
44
|
+
YDD.env = options.env if options.env.present?
|
45
|
+
YDD.tables = options.tables if options.tables.present?
|
46
|
+
YDD.skip_data = options.skip_data?
|
47
|
+
YDD.skip_schema = options.skip_schema?
|
42
48
|
setup_directories! dump_dir, app_dir, extra
|
43
49
|
connect_to_database!
|
44
50
|
end
|
@@ -47,10 +53,6 @@ module YDD
|
|
47
53
|
YDD.connect_from @db_config
|
48
54
|
end
|
49
55
|
|
50
|
-
def validate_environment!
|
51
|
-
YDD.env = options.env if options.env.present?
|
52
|
-
end
|
53
|
-
|
54
56
|
def die(error, code = 1)
|
55
57
|
say error
|
56
58
|
exit code
|
@@ -129,7 +129,9 @@ module YDD
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def self.tables
|
132
|
-
YDD.connection.tables
|
132
|
+
base_tables = YDD.connection.tables
|
133
|
+
base_tables &= YDD.tables if YDD.tables.present?
|
134
|
+
|
133
135
|
end
|
134
136
|
|
135
137
|
def self.dump_table(io, table)
|
data/lib/ydd.rb
CHANGED
@@ -12,6 +12,24 @@ module YDD
|
|
12
12
|
autoload :SerializationHelper, 'ydd/serialization_helper'
|
13
13
|
autoload :Application, 'ydd/application'
|
14
14
|
|
15
|
+
mattr_accessor :skip_schema, :skip_data
|
16
|
+
|
17
|
+
def self.skip_schema?
|
18
|
+
!!skip_schema
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.skip_data?
|
22
|
+
!!skip_data
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.tables=(value)
|
26
|
+
@@tables = value.blank? ? nil : Array(value).join(",").split(",")
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.tables
|
30
|
+
@@tables ||= nil
|
31
|
+
end
|
32
|
+
|
15
33
|
def self.env=(value)
|
16
34
|
if value.blank?
|
17
35
|
@@env = nil
|
@@ -45,8 +63,8 @@ module YDD
|
|
45
63
|
|
46
64
|
def self.dump(directory)
|
47
65
|
FileUtils.mkdir_p directory
|
48
|
-
SchemaManager.dump File.join(directory, "schema.rb")
|
49
|
-
DataManager.dump File.join(directory, "data.yml")
|
66
|
+
SchemaManager.dump File.join(directory, "schema.rb") unless skip_schema?
|
67
|
+
DataManager.dump File.join(directory, "data.yml") unless skip_data?
|
50
68
|
end
|
51
69
|
|
52
70
|
def self.load(directory)
|
@@ -54,8 +72,8 @@ module YDD
|
|
54
72
|
raise Error, "Please provide a valid directory - #{directory} doesn't exist."
|
55
73
|
end
|
56
74
|
check_files! directory, "schema.rb", "data.yml"
|
57
|
-
SchemaManager.load File.join(directory, "schema.rb")
|
58
|
-
DataManager.load File.join(directory, "data.yml")
|
75
|
+
SchemaManager.load File.join(directory, "schema.rb") unless skip_schema?
|
76
|
+
DataManager.load File.join(directory, "data.yml") unless skip_data?
|
59
77
|
end
|
60
78
|
|
61
79
|
def self.check_files!(dir, *files)
|
data/ydd.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ydd}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Adam Wiggins", "Orion Henry", "Darcy Laycock"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-20}
|
13
13
|
s.default_executable = %q{ydd}
|
14
14
|
s.description = %q{
|
15
15
|
YDD is a tool (a fork of yaml_db really) to make it generally easy
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ydd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adam Wiggins
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-09-
|
20
|
+
date: 2010-09-20 00:00:00 +08:00
|
21
21
|
default_executable: ydd
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|