phil_columns 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +257 -0
- data/Rakefile +6 -0
- data/bin/phil_columns +6 -0
- data/lib/phil_columns.rb +27 -0
- data/lib/phil_columns/archivist.rb +36 -0
- data/lib/phil_columns/cli.rb +162 -0
- data/lib/phil_columns/cli/generate.rb +43 -0
- data/lib/phil_columns/cli/list.rb +68 -0
- data/lib/phil_columns/command.rb +14 -0
- data/lib/phil_columns/command/base.rb +64 -0
- data/lib/phil_columns/command/empty.rb +30 -0
- data/lib/phil_columns/command/generate.rb +9 -0
- data/lib/phil_columns/command/generate/seed.rb +25 -0
- data/lib/phil_columns/command/generator.rb +45 -0
- data/lib/phil_columns/command/install.rb +65 -0
- data/lib/phil_columns/command/list.rb +10 -0
- data/lib/phil_columns/command/list/tagged_with.rb +27 -0
- data/lib/phil_columns/command/list/tags.rb +37 -0
- data/lib/phil_columns/command/mulligan.rb +22 -0
- data/lib/phil_columns/command/seed.rb +44 -0
- data/lib/phil_columns/configuration.rb +88 -0
- data/lib/phil_columns/error.rb +5 -0
- data/lib/phil_columns/filter.rb +66 -0
- data/lib/phil_columns/migrator.rb +80 -0
- data/lib/phil_columns/output.rb +29 -0
- data/lib/phil_columns/railtie.rb +18 -0
- data/lib/phil_columns/seed.rb +37 -0
- data/lib/phil_columns/seed_utils.rb +59 -0
- data/lib/phil_columns/seeder.rb +58 -0
- data/lib/phil_columns/version.rb +3 -0
- data/lib/phil_columns/with_backend.rb +21 -0
- data/phil_columns.gemspec +30 -0
- data/spec/spec_helper.rb +2 -0
- data/templates/seed_class.erb +11 -0
- metadata +200 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
module PhilColumns
|
2
|
+
class Seeder
|
3
|
+
|
4
|
+
include PhilColumns::Output
|
5
|
+
|
6
|
+
def initialize( config )
|
7
|
+
@config = config
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute
|
11
|
+
seeds.each do |seed_meta|
|
12
|
+
confirm "Executing seed: #{clean_filepath seed_meta.filepath} ... ", :cyan do
|
13
|
+
instance = seed_meta.klass.new( config )
|
14
|
+
instance.send( method_name )
|
15
|
+
record_seed( seed_meta )
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
attr_reader :config
|
23
|
+
|
24
|
+
def record_seed( seed_meta )
|
25
|
+
if method_name == :up
|
26
|
+
archivist.record_seed( seed_meta.timestamp )
|
27
|
+
else
|
28
|
+
archivist.remove_seed( seed_meta.timestamp )
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def clean_filepath( filepath )
|
33
|
+
File.basename( filepath, '.rb' )
|
34
|
+
end
|
35
|
+
|
36
|
+
def archivist
|
37
|
+
@archivist ||= PhilColumns::Archivist.new
|
38
|
+
end
|
39
|
+
|
40
|
+
def seeds
|
41
|
+
@seeds ||= filter.seeds
|
42
|
+
end
|
43
|
+
|
44
|
+
def filter
|
45
|
+
@filter ||= Filter.new( config )
|
46
|
+
end
|
47
|
+
|
48
|
+
def method_name
|
49
|
+
return :down if down?
|
50
|
+
:up
|
51
|
+
end
|
52
|
+
|
53
|
+
def down?
|
54
|
+
config.down
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module PhilColumns
|
2
|
+
module WithBackend
|
3
|
+
|
4
|
+
def self.included( base )
|
5
|
+
base.class_eval do
|
6
|
+
attr_reader :backend
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def backend_responds?( method )
|
13
|
+
backend && backend.respond_to?( method )
|
14
|
+
end
|
15
|
+
|
16
|
+
def error
|
17
|
+
[NotImplementedError, "You must include a database adapter (ie. phil_columns-activerecord)"]
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'phil_columns/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "phil_columns"
|
8
|
+
spec.version = PhilColumns::VERSION
|
9
|
+
spec.authors = ["JC. ason Harrelson (midas)"]
|
10
|
+
spec.email = ["jason@lookforwardenterprises.com"]
|
11
|
+
spec.summary = %q{A utility for seeding databases for development and production.}
|
12
|
+
spec.description = %q{A utility for seeding databases for development and production. See README for more details.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "pry-debugger"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
|
26
|
+
spec.add_dependency "activesupport"
|
27
|
+
spec.add_dependency "hashie"
|
28
|
+
spec.add_dependency "rainbow"
|
29
|
+
spec.add_dependency "thor"
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phil_columns
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- JC. ason Harrelson (midas)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry-debugger
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: hashie
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rainbow
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: thor
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: A utility for seeding databases for development and production. See
|
126
|
+
README for more details.
|
127
|
+
email:
|
128
|
+
- jason@lookforwardenterprises.com
|
129
|
+
executables:
|
130
|
+
- phil_columns
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- ".gitignore"
|
135
|
+
- ".rspec"
|
136
|
+
- ".ruby-gemset"
|
137
|
+
- ".ruby-version"
|
138
|
+
- ".travis.yml"
|
139
|
+
- Gemfile
|
140
|
+
- LICENSE.txt
|
141
|
+
- README.md
|
142
|
+
- Rakefile
|
143
|
+
- bin/phil_columns
|
144
|
+
- lib/phil_columns.rb
|
145
|
+
- lib/phil_columns/archivist.rb
|
146
|
+
- lib/phil_columns/cli.rb
|
147
|
+
- lib/phil_columns/cli/generate.rb
|
148
|
+
- lib/phil_columns/cli/list.rb
|
149
|
+
- lib/phil_columns/command.rb
|
150
|
+
- lib/phil_columns/command/base.rb
|
151
|
+
- lib/phil_columns/command/empty.rb
|
152
|
+
- lib/phil_columns/command/generate.rb
|
153
|
+
- lib/phil_columns/command/generate/seed.rb
|
154
|
+
- lib/phil_columns/command/generator.rb
|
155
|
+
- lib/phil_columns/command/install.rb
|
156
|
+
- lib/phil_columns/command/list.rb
|
157
|
+
- lib/phil_columns/command/list/tagged_with.rb
|
158
|
+
- lib/phil_columns/command/list/tags.rb
|
159
|
+
- lib/phil_columns/command/mulligan.rb
|
160
|
+
- lib/phil_columns/command/seed.rb
|
161
|
+
- lib/phil_columns/configuration.rb
|
162
|
+
- lib/phil_columns/error.rb
|
163
|
+
- lib/phil_columns/filter.rb
|
164
|
+
- lib/phil_columns/migrator.rb
|
165
|
+
- lib/phil_columns/output.rb
|
166
|
+
- lib/phil_columns/railtie.rb
|
167
|
+
- lib/phil_columns/seed.rb
|
168
|
+
- lib/phil_columns/seed_utils.rb
|
169
|
+
- lib/phil_columns/seeder.rb
|
170
|
+
- lib/phil_columns/version.rb
|
171
|
+
- lib/phil_columns/with_backend.rb
|
172
|
+
- phil_columns.gemspec
|
173
|
+
- spec/spec_helper.rb
|
174
|
+
- templates/seed_class.erb
|
175
|
+
homepage: ''
|
176
|
+
licenses:
|
177
|
+
- MIT
|
178
|
+
metadata: {}
|
179
|
+
post_install_message:
|
180
|
+
rdoc_options: []
|
181
|
+
require_paths:
|
182
|
+
- lib
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
requirements: []
|
194
|
+
rubyforge_project:
|
195
|
+
rubygems_version: 2.2.1
|
196
|
+
signing_key:
|
197
|
+
specification_version: 4
|
198
|
+
summary: A utility for seeding databases for development and production.
|
199
|
+
test_files:
|
200
|
+
- spec/spec_helper.rb
|