stealth 1.0.0.pre2 → 1.0.0.rc1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +47 -3
- data/README.md +1 -0
- data/VERSION +1 -1
- data/lib/stealth/base.rb +17 -0
- data/lib/stealth/cli.rb +166 -1
- data/lib/stealth/generators/builder/.gitignore +30 -0
- data/lib/stealth/generators/builder/Gemfile +3 -1
- data/lib/stealth/generators/builder/Rakefile +2 -0
- data/lib/stealth/generators/builder/bot/controllers/concerns/.keep +0 -0
- data/lib/stealth/generators/builder/bot/models/bot_record.rb +3 -0
- data/lib/stealth/generators/builder/bot/models/concerns/.keep +0 -0
- data/lib/stealth/generators/builder/config/database.yml +25 -0
- data/lib/stealth/generators/builder/db/seeds.rb +7 -0
- data/lib/stealth/generators/builder.rb +3 -3
- data/lib/stealth/migrations/configurator.rb +74 -0
- data/lib/stealth/migrations/generators.rb +17 -0
- data/lib/stealth/migrations/railtie_config.rb +15 -0
- data/lib/stealth/migrations/tasks.rb +42 -0
- data/stealth.gemspec +2 -0
- metadata +41 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 700e83b0aa80370a383da65b62ae4d1456d61c38e47fdc52d9cb0c3ada142e79
|
|
4
|
+
data.tar.gz: b5a271f944ab3225b3552bac430aa10ff9d1a41cbbcd684b7b08bb7fbf6fca1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d90f66bd7df680518ebc93cba85b84d279780320e49b4ec817294be931b17af0d27047557bf626165eb0f44d4b12836848a07532613c8fc7793987f4af1eb171
|
|
7
|
+
data.tar.gz: f66eaf2c71bde6746333a26b05824bcd98f548e60d69e1bdb80f3a1dc772181f3257aa458d6090408db1a1b05ce0eab2565c27d15d0bb7d98a2e5165c5780e8c
|
data/Gemfile.lock
CHANGED
|
@@ -1,31 +1,63 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
stealth (1.0.0.
|
|
5
|
-
|
|
4
|
+
stealth (1.0.0.rc1)
|
|
5
|
+
activerecord (~> 5.2)
|
|
6
|
+
activesupport (~> 5.2)
|
|
6
7
|
multi_json (~> 1.12)
|
|
7
8
|
puma (~> 3.10)
|
|
9
|
+
railties (~> 5.2)
|
|
8
10
|
sidekiq (~> 5.0)
|
|
9
|
-
sinatra (~> 2.0
|
|
11
|
+
sinatra (~> 2.0)
|
|
10
12
|
thor (~> 0.20)
|
|
11
13
|
|
|
12
14
|
GEM
|
|
13
15
|
remote: https://rubygems.org/
|
|
14
16
|
specs:
|
|
17
|
+
actionpack (5.2.0)
|
|
18
|
+
actionview (= 5.2.0)
|
|
19
|
+
activesupport (= 5.2.0)
|
|
20
|
+
rack (~> 2.0)
|
|
21
|
+
rack-test (>= 0.6.3)
|
|
22
|
+
rails-dom-testing (~> 2.0)
|
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
24
|
+
actionview (5.2.0)
|
|
25
|
+
activesupport (= 5.2.0)
|
|
26
|
+
builder (~> 3.1)
|
|
27
|
+
erubi (~> 1.4)
|
|
28
|
+
rails-dom-testing (~> 2.0)
|
|
29
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
30
|
+
activemodel (5.2.0)
|
|
31
|
+
activesupport (= 5.2.0)
|
|
32
|
+
activerecord (5.2.0)
|
|
33
|
+
activemodel (= 5.2.0)
|
|
34
|
+
activesupport (= 5.2.0)
|
|
35
|
+
arel (>= 9.0)
|
|
15
36
|
activesupport (5.2.0)
|
|
16
37
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
17
38
|
i18n (>= 0.7, < 2)
|
|
18
39
|
minitest (~> 5.1)
|
|
19
40
|
tzinfo (~> 1.1)
|
|
41
|
+
arel (9.0.0)
|
|
42
|
+
builder (3.2.3)
|
|
20
43
|
concurrent-ruby (1.0.5)
|
|
21
44
|
connection_pool (2.2.1)
|
|
45
|
+
crass (1.0.4)
|
|
22
46
|
diff-lcs (1.3)
|
|
47
|
+
erubi (1.7.1)
|
|
23
48
|
i18n (1.0.1)
|
|
24
49
|
concurrent-ruby (~> 1.0)
|
|
50
|
+
loofah (2.2.2)
|
|
51
|
+
crass (~> 1.0.2)
|
|
52
|
+
nokogiri (>= 1.5.9)
|
|
53
|
+
method_source (0.9.0)
|
|
54
|
+
mini_portile2 (2.3.0)
|
|
25
55
|
minitest (5.11.3)
|
|
26
56
|
mock_redis (0.17.3)
|
|
27
57
|
multi_json (1.13.1)
|
|
28
58
|
mustermann (1.0.2)
|
|
59
|
+
nokogiri (1.8.2)
|
|
60
|
+
mini_portile2 (~> 2.3.0)
|
|
29
61
|
oj (3.5.0)
|
|
30
62
|
puma (3.11.4)
|
|
31
63
|
rack (2.0.4)
|
|
@@ -33,6 +65,18 @@ GEM
|
|
|
33
65
|
rack
|
|
34
66
|
rack-test (0.8.3)
|
|
35
67
|
rack (>= 1.0, < 3)
|
|
68
|
+
rails-dom-testing (2.0.3)
|
|
69
|
+
activesupport (>= 4.2.0)
|
|
70
|
+
nokogiri (>= 1.6)
|
|
71
|
+
rails-html-sanitizer (1.0.4)
|
|
72
|
+
loofah (~> 2.2, >= 2.2.2)
|
|
73
|
+
railties (5.2.0)
|
|
74
|
+
actionpack (= 5.2.0)
|
|
75
|
+
activesupport (= 5.2.0)
|
|
76
|
+
method_source
|
|
77
|
+
rake (>= 0.8.7)
|
|
78
|
+
thor (>= 0.18.1, < 2.0)
|
|
79
|
+
rake (12.3.1)
|
|
36
80
|
redis (4.0.1)
|
|
37
81
|
rspec (3.7.0)
|
|
38
82
|
rspec-core (~> 3.7.0)
|
data/README.md
CHANGED
|
@@ -40,6 +40,7 @@ Stealth wouldn't exist without the great work of many other open source projects
|
|
|
40
40
|
* [Thor](http://whatisthor.com) for providing us with CLI tools and generators;
|
|
41
41
|
* [Sinatra](http://sinatrarb.com) for providing a fantastic, modular way for handling HTTP requests;
|
|
42
42
|
* [Sidekiq](https://sidekiq.org) for the super quick background jobs;
|
|
43
|
+
* [standalone-migrations](https://github.com/thuss/standalone-migrations) for the help with Rails migrations;
|
|
43
44
|
* [Dr. Robert Ford](http://westworld.wikia.com/wiki/Robert_Ford) a.k.a. Anthony Hopkins.
|
|
44
45
|
|
|
45
46
|
## License
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.0.
|
|
1
|
+
1.0.0.rc1
|
data/lib/stealth/base.rb
CHANGED
|
@@ -6,6 +6,13 @@ require 'yaml'
|
|
|
6
6
|
require 'sidekiq'
|
|
7
7
|
require 'active_support/all'
|
|
8
8
|
|
|
9
|
+
begin
|
|
10
|
+
require "rails"
|
|
11
|
+
require "active_record"
|
|
12
|
+
rescue LoadError
|
|
13
|
+
# Don't require ActiveRecord
|
|
14
|
+
end
|
|
15
|
+
|
|
9
16
|
# core
|
|
10
17
|
require 'stealth/version'
|
|
11
18
|
require 'stealth/errors'
|
|
@@ -61,6 +68,12 @@ module Stealth
|
|
|
61
68
|
require File.join(Stealth.root, 'bot', 'controllers', 'bot_controller')
|
|
62
69
|
require File.join(Stealth.root, 'config', 'flow_map')
|
|
63
70
|
require_directory("bot")
|
|
71
|
+
|
|
72
|
+
if ENV['DATABASE_URL'].present? && defined?(ActiveRecord)
|
|
73
|
+
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
|
|
74
|
+
else
|
|
75
|
+
ActiveRecord::Base.establish_connection(YAML::load_file("config/database.yml")[Stealth.env])
|
|
76
|
+
end
|
|
64
77
|
end
|
|
65
78
|
|
|
66
79
|
private
|
|
@@ -94,3 +107,7 @@ require 'stealth/controller/helpers'
|
|
|
94
107
|
require 'stealth/controller/controller'
|
|
95
108
|
require 'stealth/flow/base'
|
|
96
109
|
require 'stealth/services/base_client'
|
|
110
|
+
require 'stealth/migrations/configurator'
|
|
111
|
+
require 'stealth/migrations/generators'
|
|
112
|
+
require 'stealth/migrations/railtie_config'
|
|
113
|
+
require 'stealth/migrations/tasks'
|
data/lib/stealth/cli.rb
CHANGED
|
@@ -21,6 +21,7 @@ module Stealth
|
|
|
21
21
|
Stealth::Generators::Builder.start([name])
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
|
|
24
25
|
desc 'generate', 'Generates scaffold Stealth files'
|
|
25
26
|
long_desc <<-EOS
|
|
26
27
|
`stealth generate <generator> <name>` generates scaffold Stealth files
|
|
@@ -28,10 +29,19 @@ module Stealth
|
|
|
28
29
|
$ > stealth generate flow quote
|
|
29
30
|
EOS
|
|
30
31
|
def generate(generator, name)
|
|
31
|
-
|
|
32
|
+
case generator
|
|
33
|
+
when 'migration'
|
|
34
|
+
Stealth::Migrations::Generator.migration(name)
|
|
35
|
+
when 'flow'
|
|
36
|
+
Stealth::Generators::Generate.start([generator, name])
|
|
37
|
+
else
|
|
38
|
+
puts "Could not find generator '#{generator}'."
|
|
39
|
+
puts "Run `stealth help generate` for more options."
|
|
40
|
+
end
|
|
32
41
|
end
|
|
33
42
|
map 'g' => 'generate'
|
|
34
43
|
|
|
44
|
+
|
|
35
45
|
desc 'version', 'Prints stealth version'
|
|
36
46
|
long_desc <<-EOS
|
|
37
47
|
`stealth version` prints the version of the bundled stealth gem.
|
|
@@ -95,6 +105,7 @@ module Stealth
|
|
|
95
105
|
service_setup_klass.trigger
|
|
96
106
|
end
|
|
97
107
|
|
|
108
|
+
|
|
98
109
|
desc 'sessions:clear', 'Clears all sessions in development'
|
|
99
110
|
long_desc <<-EOS
|
|
100
111
|
`stealth sessions:clear` clears all sessions from Redis in development.
|
|
@@ -106,5 +117,159 @@ module Stealth
|
|
|
106
117
|
$redis.flushdb if Stealth.env == 'development'
|
|
107
118
|
end
|
|
108
119
|
|
|
120
|
+
|
|
121
|
+
desc 'db:create', 'Creates the database from DATABASE_URL or config/database.yml for the current STEALTH_ENV'
|
|
122
|
+
long_desc <<-EOS
|
|
123
|
+
`stealth db:create` Creates the database from DATABASE_URL or config/database.yml for the current STEALTH_ENV (use db:create:all to create all databases in the config). Without STEALTH_ENV or when STEALTH_ENV is development, it defaults to creating the development and test databases.
|
|
124
|
+
|
|
125
|
+
$ > stealth db:create
|
|
126
|
+
EOS
|
|
127
|
+
define_method 'db:create' do
|
|
128
|
+
Kernel.exec('bundle exec rake db:create')
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
desc 'db:create:all', 'Creates all databases from DATABASE_URL or config/database.yml'
|
|
133
|
+
long_desc <<-EOS
|
|
134
|
+
`stealth db:create:all` Creates all databases from DATABASE_URL or config/database.yml regardless of the enviornment specified in STEALTH_ENV
|
|
135
|
+
|
|
136
|
+
$ > stealth db:create:all
|
|
137
|
+
EOS
|
|
138
|
+
define_method 'db:create:all' do
|
|
139
|
+
Kernel.exec('bundle exec rake db:create:all')
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
desc 'db:drop', 'Drops the database from DATABASE_URL or config/database.yml for the current STEALTH_ENV'
|
|
144
|
+
long_desc <<-EOS
|
|
145
|
+
`stealth db:drop` Drops the database from DATABASE_URL or config/database.yml for the current STEALTH_ENV (use db:drop:all to drop all databases in the config). Without STEALTH_ENV or when STEALTH_ENV is development, it defaults to dropping the development and test databases.
|
|
146
|
+
|
|
147
|
+
$ > stealth db:drop
|
|
148
|
+
EOS
|
|
149
|
+
define_method 'db:drop' do
|
|
150
|
+
Kernel.exec('bundle exec rake db:drop')
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
desc 'db:drop:all', 'Drops all databases from DATABASE_URL or config/database.yml'
|
|
155
|
+
long_desc <<-EOS
|
|
156
|
+
`stealth db:drop:all` Drops all databases from DATABASE_URL or config/database.yml
|
|
157
|
+
|
|
158
|
+
$ > stealth db:drop:all
|
|
159
|
+
EOS
|
|
160
|
+
define_method 'db:drop:all' do
|
|
161
|
+
Kernel.exec('bundle exec rake db:drop:all')
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
desc 'db:environment:set', 'Set the environment value for the database'
|
|
166
|
+
long_desc <<-EOS
|
|
167
|
+
`stealth db:environment:set` Set the environment value for the database
|
|
168
|
+
|
|
169
|
+
$ > stealth db:environment:set
|
|
170
|
+
EOS
|
|
171
|
+
define_method 'db:environment:set' do
|
|
172
|
+
Kernel.exec('bundle exec rake db:enviornment:set')
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
desc 'db:migrate', 'Migrate the database'
|
|
177
|
+
long_desc <<-EOS
|
|
178
|
+
`stealth db:migrate` Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog).
|
|
179
|
+
|
|
180
|
+
$ > stealth db:migrate
|
|
181
|
+
EOS
|
|
182
|
+
define_method 'db:migrate' do
|
|
183
|
+
Kernel.exec('bundle exec rake db:migrate')
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
desc 'db:rollback', 'Rolls the schema back to the previous version'
|
|
188
|
+
long_desc <<-EOS
|
|
189
|
+
`stealth db:rollback` Rolls the schema back to the previous version (specify steps w/ STEP=n).
|
|
190
|
+
|
|
191
|
+
$ > stealth db:rollback
|
|
192
|
+
EOS
|
|
193
|
+
define_method 'db:rollback' do
|
|
194
|
+
Kernel.exec('bundle exec rake db:rollback')
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
desc 'db:schema:load', 'Loads a schema.rb file into the database'
|
|
199
|
+
long_desc <<-EOS
|
|
200
|
+
`stealth db:schema:load` Loads a schema.rb file into the database
|
|
201
|
+
|
|
202
|
+
$ > stealth db:schema:load
|
|
203
|
+
EOS
|
|
204
|
+
define_method 'db:schema:load' do
|
|
205
|
+
Kernel.exec('bundle exec rake db:schema:load')
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
desc 'db:schema:dump', 'Creates a db/schema.rb file that is portable against any DB supported by Active Record'
|
|
210
|
+
long_desc <<-EOS
|
|
211
|
+
`stealth db:schema:dump` Creates a db/schema.rb file that is portable against any DB supported by Active Record
|
|
212
|
+
|
|
213
|
+
$ > stealth db:schema:dump
|
|
214
|
+
EOS
|
|
215
|
+
define_method 'db:schema:dump' do
|
|
216
|
+
Kernel.exec('bundle exec rake db:schema:dump')
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
desc 'db:seed', 'Creates the database, loads the schema, and initializes with the seed data (use db:reset to also drop the database first)'
|
|
221
|
+
long_desc <<-EOS
|
|
222
|
+
`stealth db:seed` Creates the database, loads the schema, and initializes with the seed data (use db:reset to also drop the database first)
|
|
223
|
+
|
|
224
|
+
$ > stealth db:seed
|
|
225
|
+
EOS
|
|
226
|
+
define_method 'db:seed' do
|
|
227
|
+
Kernel.exec('bundle exec rake db:seed')
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
desc 'db:version', 'Retrieves the current schema version number'
|
|
232
|
+
long_desc <<-EOS
|
|
233
|
+
`stealth db:version` Retrieves the current schema version number
|
|
234
|
+
|
|
235
|
+
$ > stealth db:version
|
|
236
|
+
EOS
|
|
237
|
+
define_method 'db:version' do
|
|
238
|
+
Kernel.exec('bundle exec rake db:version')
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
desc 'db:setup', 'Creates the database, loads the schema, and initializes with the seed data (use db:reset to also drop the database first)'
|
|
243
|
+
long_desc <<-EOS
|
|
244
|
+
`stealth db:setup` Creates the database, loads the schema, and initializes with the seed data (use db:reset to also drop the database first)
|
|
245
|
+
|
|
246
|
+
$ > stealth db:setup
|
|
247
|
+
EOS
|
|
248
|
+
define_method 'db:setup' do
|
|
249
|
+
Kernel.exec('bundle exec rake db:setup')
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
desc 'db:structure:dump', 'Dumps the database structure to db/structure.sql. Specify another file with SCHEMA=db/my_structure.sql'
|
|
254
|
+
long_desc <<-EOS
|
|
255
|
+
`stealth db:structure:dump` Dumps the database structure to db/structure.sql. Specify another file with SCHEMA=db/my_structure.sql
|
|
256
|
+
|
|
257
|
+
$ > stealth db:structure:dump
|
|
258
|
+
EOS
|
|
259
|
+
define_method 'db:structure:dump' do
|
|
260
|
+
Kernel.exec('bundle exec rake db:structure:dump')
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
desc 'db:structure:load', 'Recreates the databases from the structure.sql file'
|
|
265
|
+
long_desc <<-EOS
|
|
266
|
+
`stealth db:structure:load` Recreates the databases from the structure.sql file
|
|
267
|
+
|
|
268
|
+
$ > stealth db:structure:load
|
|
269
|
+
EOS
|
|
270
|
+
define_method 'db:structure:load' do
|
|
271
|
+
Kernel.exec('bundle exec rake db:structure:load')
|
|
272
|
+
end
|
|
273
|
+
|
|
109
274
|
end
|
|
110
275
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
|
2
|
+
#
|
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
|
6
|
+
|
|
7
|
+
# Ignore bundler config.
|
|
8
|
+
/.bundle
|
|
9
|
+
|
|
10
|
+
# Ignore the default SQLite database.
|
|
11
|
+
/db/*.sqlite3
|
|
12
|
+
/db/*.sqlite3-journal
|
|
13
|
+
|
|
14
|
+
# Ignore all logfiles and tempfiles.
|
|
15
|
+
/log/*
|
|
16
|
+
/tmp/*
|
|
17
|
+
!/log/.keep
|
|
18
|
+
!/tmp/.keep
|
|
19
|
+
|
|
20
|
+
# Ignore uploaded files in development
|
|
21
|
+
/storage/*
|
|
22
|
+
|
|
23
|
+
/node_modules
|
|
24
|
+
/yarn-error.log
|
|
25
|
+
|
|
26
|
+
/public/assets
|
|
27
|
+
.byebug_history
|
|
28
|
+
|
|
29
|
+
# Ignore master key for decrypting credentials and more.
|
|
30
|
+
/config/master.key
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# SQLite version 3.x
|
|
2
|
+
# gem install sqlite3
|
|
3
|
+
#
|
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
|
5
|
+
# gem 'sqlite3'
|
|
6
|
+
#
|
|
7
|
+
default: &default
|
|
8
|
+
adapter: sqlite3
|
|
9
|
+
pool: <%= ENV.fetch("STEALTH_MAX_THREADS") { 5 } %>
|
|
10
|
+
timeout: 5000
|
|
11
|
+
|
|
12
|
+
development:
|
|
13
|
+
<<: *default
|
|
14
|
+
database: db/development.sqlite3
|
|
15
|
+
|
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
|
17
|
+
# re-generated from your development database when you run "rake".
|
|
18
|
+
# Do not set this db to the same as development or production.
|
|
19
|
+
test:
|
|
20
|
+
<<: *default
|
|
21
|
+
database: db/test.sqlite3
|
|
22
|
+
|
|
23
|
+
production:
|
|
24
|
+
<<: *default
|
|
25
|
+
database: db/production.sqlite3
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
|
2
|
+
# The data can then be loaded with the stealth db:seed command (or created alongside the database with db:setup).
|
|
3
|
+
#
|
|
4
|
+
# Examples:
|
|
5
|
+
#
|
|
6
|
+
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
|
|
7
|
+
# Character.create(name: 'Luke', movie: movies.first)
|
|
@@ -19,17 +19,17 @@ module Stealth
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def create_bot_structure
|
|
22
|
-
# Bot Directory
|
|
23
22
|
directory('bot', "#{name}/bot")
|
|
24
|
-
|
|
25
|
-
# Config Directory
|
|
26
23
|
directory('config', "#{name}/config")
|
|
24
|
+
directory('db', "#{name}/db")
|
|
27
25
|
|
|
28
26
|
# Miscellaneous Files
|
|
29
27
|
copy_file "config.ru", "#{name}/config.ru"
|
|
28
|
+
copy_file "Rakefile", "#{name}/Rakefile"
|
|
30
29
|
copy_file "Gemfile", "#{name}/Gemfile"
|
|
31
30
|
copy_file "README.md", "#{name}/README.md"
|
|
32
31
|
copy_file "Procfile.dev", "#{name}/Procfile.dev"
|
|
32
|
+
copy_file ".gitignore", "#{name}/.gitignore"
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def change_directory_bundle
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Stealth
|
|
5
|
+
module Migrations
|
|
6
|
+
class InternalConfigurationsProxy
|
|
7
|
+
|
|
8
|
+
attr_reader :configurations
|
|
9
|
+
|
|
10
|
+
def initialize(configurations)
|
|
11
|
+
@configurations = configurations
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def on(config_key)
|
|
15
|
+
if @configurations[config_key] && block_given?
|
|
16
|
+
@configurations[config_key] = yield(@configurations[config_key]) || @configurations[config_key]
|
|
17
|
+
end
|
|
18
|
+
@configurations[config_key]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class Configurator
|
|
23
|
+
def self.load_configurations
|
|
24
|
+
self.new
|
|
25
|
+
@env_config ||= Rails.application.config.database_configuration
|
|
26
|
+
ActiveRecord::Base.configurations = @env_config
|
|
27
|
+
@env_config
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.environments_config
|
|
31
|
+
proxy = InternalConfigurationsProxy.new(load_configurations)
|
|
32
|
+
yield(proxy) if block_given?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def initialize(options = {})
|
|
36
|
+
default_schema = ENV['SCHEMA'] || ActiveRecord::Tasks::DatabaseTasks.schema_file(ActiveRecord::Base.schema_format)
|
|
37
|
+
defaults = {
|
|
38
|
+
config: "config/database.yml",
|
|
39
|
+
migrate_dir: "db/migrate",
|
|
40
|
+
seeds: "db/seeds.rb",
|
|
41
|
+
schema: default_schema
|
|
42
|
+
}
|
|
43
|
+
@options = defaults.merge(options)
|
|
44
|
+
|
|
45
|
+
Rails.application.config.root = Pathname.pwd
|
|
46
|
+
Rails.application.config.paths["config/database"] = config
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def config
|
|
50
|
+
@options[:config]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def migrate_dir
|
|
54
|
+
@options[:migrate_dir]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def seeds
|
|
58
|
+
@options[:seeds]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def schema
|
|
62
|
+
@options[:schema]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def config_for_all
|
|
66
|
+
Configurator.load_configurations.dup
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def config_for(environment)
|
|
70
|
+
config_for_all[environment.to_s]
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "rails/generators"
|
|
5
|
+
|
|
6
|
+
module Stealth
|
|
7
|
+
module Migrations
|
|
8
|
+
class Generator
|
|
9
|
+
def self.migration(name, options="")
|
|
10
|
+
generator_params = [name] + options.split(" ")
|
|
11
|
+
Rails::Generators.invoke("active_record:migration", generator_params,
|
|
12
|
+
destination_root: Stealth.root
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Stealth
|
|
5
|
+
module Migrations
|
|
6
|
+
class RailtieConfig < Rails::Application
|
|
7
|
+
config.generators.options[:rails] = { orm: :active_record }
|
|
8
|
+
|
|
9
|
+
config.generators.options[:active_record] = {
|
|
10
|
+
:migration => true,
|
|
11
|
+
:timestamps => true
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Stealth
|
|
5
|
+
module Migrations
|
|
6
|
+
class Tasks
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def configure
|
|
10
|
+
configurator = Configurator.new
|
|
11
|
+
|
|
12
|
+
paths = Rails.application.config.paths
|
|
13
|
+
|
|
14
|
+
paths.add "config/database", with: configurator.config
|
|
15
|
+
paths.add "db/migrate", with: configurator.migrate_dir
|
|
16
|
+
paths.add "db/seeds.rb", with: configurator.seeds
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def load_tasks
|
|
20
|
+
configure
|
|
21
|
+
|
|
22
|
+
Configurator.environments_config do |proxy|
|
|
23
|
+
ActiveRecord::Tasks::DatabaseTasks.database_configuration = proxy.configurations
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
RailtieConfig.load_tasks
|
|
27
|
+
|
|
28
|
+
# %w(
|
|
29
|
+
# connection
|
|
30
|
+
# environment
|
|
31
|
+
# db/new_migration
|
|
32
|
+
# ).each do
|
|
33
|
+
# |task| load "stealth/migrations/tasks/#{task}.rake"
|
|
34
|
+
# end
|
|
35
|
+
|
|
36
|
+
load "active_record/railties/databases.rake"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/stealth.gemspec
CHANGED
|
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
s.add_dependency 'multi_json', '~> 1.12'
|
|
19
19
|
s.add_dependency 'sidekiq', '~> 5.0'
|
|
20
20
|
s.add_dependency 'activesupport', '~> 5.2'
|
|
21
|
+
s.add_dependency 'activerecord', '~> 5.2'
|
|
22
|
+
s.add_dependency 'railties', '~> 5.2'
|
|
21
23
|
|
|
22
24
|
s.add_development_dependency 'rspec', '~> 3.6'
|
|
23
25
|
s.add_development_dependency 'rspec_junit_formatter', '~> 0.3'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stealth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.0.
|
|
4
|
+
version: 1.0.0.rc1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mauricio Gomes
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2018-05-
|
|
12
|
+
date: 2018-05-17 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: sinatra
|
|
@@ -95,6 +95,34 @@ dependencies:
|
|
|
95
95
|
- - "~>"
|
|
96
96
|
- !ruby/object:Gem::Version
|
|
97
97
|
version: '5.2'
|
|
98
|
+
- !ruby/object:Gem::Dependency
|
|
99
|
+
name: activerecord
|
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - "~>"
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '5.2'
|
|
105
|
+
type: :runtime
|
|
106
|
+
prerelease: false
|
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - "~>"
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '5.2'
|
|
112
|
+
- !ruby/object:Gem::Dependency
|
|
113
|
+
name: railties
|
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - "~>"
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '5.2'
|
|
119
|
+
type: :runtime
|
|
120
|
+
prerelease: false
|
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - "~>"
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '5.2'
|
|
98
126
|
- !ruby/object:Gem::Dependency
|
|
99
127
|
name: rspec
|
|
100
128
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -186,24 +214,31 @@ files:
|
|
|
186
214
|
- lib/stealth/flow/specification.rb
|
|
187
215
|
- lib/stealth/flow/state.rb
|
|
188
216
|
- lib/stealth/generators/builder.rb
|
|
217
|
+
- lib/stealth/generators/builder/.gitignore
|
|
189
218
|
- lib/stealth/generators/builder/Gemfile
|
|
190
219
|
- lib/stealth/generators/builder/Procfile.dev
|
|
220
|
+
- lib/stealth/generators/builder/Rakefile
|
|
191
221
|
- lib/stealth/generators/builder/bot/controllers/bot_controller.rb
|
|
192
222
|
- lib/stealth/generators/builder/bot/controllers/catch_alls_controller.rb
|
|
223
|
+
- lib/stealth/generators/builder/bot/controllers/concerns/.keep
|
|
193
224
|
- lib/stealth/generators/builder/bot/controllers/goodbyes_controller.rb
|
|
194
225
|
- lib/stealth/generators/builder/bot/controllers/hellos_controller.rb
|
|
195
226
|
- lib/stealth/generators/builder/bot/helpers/bot_helper.rb
|
|
227
|
+
- lib/stealth/generators/builder/bot/models/bot_record.rb
|
|
228
|
+
- lib/stealth/generators/builder/bot/models/concerns/.keep
|
|
196
229
|
- lib/stealth/generators/builder/bot/replies/catch_alls/level1.yml
|
|
197
230
|
- lib/stealth/generators/builder/bot/replies/goodbyes/say_goodbye.yml
|
|
198
231
|
- lib/stealth/generators/builder/bot/replies/hellos/say_hello.yml
|
|
199
232
|
- lib/stealth/generators/builder/config.ru
|
|
200
233
|
- lib/stealth/generators/builder/config/boot.rb
|
|
234
|
+
- lib/stealth/generators/builder/config/database.yml
|
|
201
235
|
- lib/stealth/generators/builder/config/environment.rb
|
|
202
236
|
- lib/stealth/generators/builder/config/flow_map.rb
|
|
203
237
|
- lib/stealth/generators/builder/config/initializers/.keep
|
|
204
238
|
- lib/stealth/generators/builder/config/puma.rb
|
|
205
239
|
- lib/stealth/generators/builder/config/services.yml
|
|
206
240
|
- lib/stealth/generators/builder/config/sidekiq.yml
|
|
241
|
+
- lib/stealth/generators/builder/db/seeds.rb
|
|
207
242
|
- lib/stealth/generators/builder/readme.md
|
|
208
243
|
- lib/stealth/generators/generate.rb
|
|
209
244
|
- lib/stealth/generators/generate/flow/controllers/controller.tt
|
|
@@ -213,6 +248,10 @@ files:
|
|
|
213
248
|
- lib/stealth/generators/generate/flow/replies/say_yes_reply.tt
|
|
214
249
|
- lib/stealth/jobs.rb
|
|
215
250
|
- lib/stealth/logger.rb
|
|
251
|
+
- lib/stealth/migrations/configurator.rb
|
|
252
|
+
- lib/stealth/migrations/generators.rb
|
|
253
|
+
- lib/stealth/migrations/railtie_config.rb
|
|
254
|
+
- lib/stealth/migrations/tasks.rb
|
|
216
255
|
- lib/stealth/reply.rb
|
|
217
256
|
- lib/stealth/scheduled_reply.rb
|
|
218
257
|
- lib/stealth/server.rb
|