decko 0.11.5 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/card_controller.rb +4 -0
- data/lib/card_controller/errors.rb +11 -13
- data/lib/card_controller/response.rb +0 -12
- data/lib/card_controller/rest.rb +14 -4
- data/lib/decko.rb +2 -15
- data/lib/decko/all.rb +2 -0
- data/lib/decko/application.rb +8 -89
- data/lib/decko/cli.rb +1 -7
- data/lib/decko/commands.rb +17 -110
- data/lib/decko/commands/application.rb +2 -2
- data/lib/decko/commands/cucumber_command.rb +8 -7
- data/lib/decko/commands/cucumber_command/parser.rb +2 -2
- data/lib/decko/engine.rb +1 -45
- data/lib/decko/generators.rb +17 -0
- data/lib/decko/mods_spec_helper.rb +1 -1
- data/lib/decko/railtie.rb +27 -0
- data/lib/decko/script_decko_loader.rb +5 -38
- data/lib/decko/tasks/cucumber.rake +25 -16
- data/lib/decko/tasks/decko.rake +7 -28
- data/lib/decko/tasks/decko/benchmark.rake +38 -0
- data/lib/decko/tasks/decko/docs.rake +1 -1
- data/lib/decko/tasks/decko/seed.rake +16 -7
- data/lib/generators/deck/deck_generator.rb +12 -0
- metadata +25 -72
- data/lib/decko/commands/command.rb +0 -28
- data/lib/decko/commands/rake_command.rb +0 -42
- data/lib/decko/commands/rake_command/parser.rb +0 -35
- data/lib/decko/commands/rspec_command.rb +0 -36
- data/lib/decko/commands/rspec_command/parser.rb +0 -97
- data/lib/decko/config/environments/cucumber.rb +0 -41
- data/lib/decko/config/environments/cypress.rb +0 -100
- data/lib/decko/config/environments/development.rb +0 -95
- data/lib/decko/config/environments/production.rb +0 -75
- data/lib/decko/config/environments/profile.rb +0 -33
- data/lib/decko/config/environments/test.rb +0 -69
- data/lib/decko/config/initializers/secret_token.rb +0 -15
- data/lib/decko/config/initializers/sedate_parser.rb +0 -8
- data/lib/decko/config/initializers/session_store.rb +0 -2
- data/lib/decko/generators/deck/USAGE +0 -9
- data/lib/decko/generators/deck/deck_generator.rb +0 -134
- data/lib/decko/generators/deck/deck_generator/deck_helper.rb +0 -110
- data/lib/decko/generators/deck/deck_generator/interactive.rb +0 -120
- data/lib/decko/generators/deck/deck_generator/rails_overrides.rb +0 -54
- data/lib/decko/generators/deck/templates/Gemfile.erb +0 -56
- data/lib/decko/generators/deck/templates/Rakefile.erb +0 -6
- data/lib/decko/generators/deck/templates/bin/spring.erb +0 -20
- data/lib/decko/generators/deck/templates/config.ru.erb +0 -11
- data/lib/decko/generators/deck/templates/config/application.rb.erb +0 -107
- data/lib/decko/generators/deck/templates/config/boot.rb.erb +0 -11
- data/lib/decko/generators/deck/templates/config/cucumber.yml +0 -1
- data/lib/decko/generators/deck/templates/config/databases/frontbase.yml +0 -34
- data/lib/decko/generators/deck/templates/config/databases/ibm_db.yml +0 -89
- data/lib/decko/generators/deck/templates/config/databases/jdbc.yml +0 -65
- data/lib/decko/generators/deck/templates/config/databases/jdbcmysql.yml +0 -36
- data/lib/decko/generators/deck/templates/config/databases/jdbcpostgresql.yml +0 -46
- data/lib/decko/generators/deck/templates/config/databases/jdbcsqlite3.yml +0 -23
- data/lib/decko/generators/deck/templates/config/databases/mysql.yml +0 -37
- data/lib/decko/generators/deck/templates/config/databases/oracle.yml +0 -42
- data/lib/decko/generators/deck/templates/config/databases/postgresql.yml +0 -39
- data/lib/decko/generators/deck/templates/config/databases/sqlite3.yml +0 -21
- data/lib/decko/generators/deck/templates/config/deck.yml +0 -10
- data/lib/decko/generators/deck/templates/config/environment.rb.erb +0 -5
- data/lib/decko/generators/deck/templates/config/initializers/cypress.rb +0 -12
- data/lib/decko/generators/deck/templates/config/puma.rb +0 -16
- data/lib/decko/generators/deck/templates/config/routes.rb.erb +0 -11
- data/lib/decko/generators/deck/templates/config/storage.yml +0 -0
- data/lib/decko/generators/deck/templates/gitignore +0 -18
- data/lib/decko/generators/deck/templates/pryrc +0 -6
- data/lib/decko/generators/deck/templates/public/files/htaccess +0 -9
- data/lib/decko/generators/deck/templates/public/robots.txt +0 -13
- data/lib/decko/generators/deck/templates/rspec.erb +0 -6
- data/lib/decko/generators/deck/templates/script/decko +0 -6
- data/lib/decko/generators/deck/templates/script/decko_cucumber +0 -8
- data/lib/decko/generators/deck/templates/script/decko_rspec +0 -8
- data/lib/decko/generators/deck/templates/script/delayed_job +0 -5
- data/lib/decko/generators/deck/templates/simplecov.rb.erb +0 -34
- data/lib/decko/generators/deck/templates/spec/javascripts/support/deck_jasmine.yml.erb +0 -56
- data/lib/decko/generators/deck/templates/spec/javascripts/support/decko_jasmine.yml.erb +0 -74
- data/lib/decko/generators/deck/templates/spec/spec_helper.rb +0 -1
- data/rails/application-routes.rb +0 -3
- data/rails/assets/external_link.png +0 -0
- data/rails/assets/jasmine/404.html +0 -27
- data/rails/assets/jasmine/500.html +0 -28
- data/rails/assets/jasmine/card_form.html +0 -13
- data/rails/assets/jquery.min.map +0 -1
- data/rails/engine-routes.rb +0 -53
- data/script/autospec +0 -4
- data/script/decko +0 -6
- data/script/rails +0 -6
@@ -3,7 +3,7 @@
|
|
3
3
|
require "optparse"
|
4
4
|
|
5
5
|
module Decko
|
6
|
-
|
6
|
+
class Commands
|
7
7
|
class CucumberCommand
|
8
8
|
class Parser < OptionParser
|
9
9
|
class Flagger
|
@@ -34,7 +34,7 @@ module Decko
|
|
34
34
|
super() do |parser|
|
35
35
|
parser.banner = "Usage: decko cucumber [DECKO ARGS] -- [CUCUMBER ARGS]\n\n"
|
36
36
|
parser.separator "\nDECKO ARGS"
|
37
|
-
opts[:env] = ["RAILS_ROOT=."]
|
37
|
+
opts[:env] = ["RAILS_ROOT=. RAILS_ENV=cucumber"]
|
38
38
|
Flagger.new(parser, opts).add_flags
|
39
39
|
parse_spring parser, opts
|
40
40
|
end
|
data/lib/decko/engine.rb
CHANGED
@@ -1,55 +1,11 @@
|
|
1
|
-
require "rails/all"
|
2
|
-
require "cardio"
|
3
|
-
|
4
|
-
# TODO: Move these to modules that use them
|
5
|
-
require "htmlentities"
|
6
|
-
require "coderay"
|
7
|
-
require "haml"
|
8
|
-
require "kaminari"
|
9
|
-
require "bootstrap4-kaminari-views"
|
10
|
-
require "diff/lcs"
|
11
|
-
require "builder"
|
12
|
-
|
13
|
-
require "decko"
|
14
|
-
|
15
1
|
module Decko
|
16
2
|
class Engine < ::Rails::Engine
|
17
|
-
paths.add "
|
18
|
-
paths.add "config/routes.rb", with: "rails/engine-routes.rb"
|
19
|
-
paths.add "lib/tasks", with: "#{::Decko.gem_root}/lib/decko/tasks",
|
20
|
-
glob: "**/*.rake"
|
21
|
-
paths["lib/tasks"] << "#{::Cardio.gem_root}/lib/card/tasks"
|
22
|
-
paths.add "lib/decko/config/initializers",
|
23
|
-
with: File.join(Decko.gem_root, "lib/decko/config/initializers"),
|
24
|
-
glob: "**/*.rb"
|
25
|
-
|
26
|
-
initializer "decko.engine.load_config_initializers",
|
27
|
-
after: :load_config_initializers do
|
28
|
-
paths["lib/decko/config/initializers"].existent.sort.each do |initializer|
|
29
|
-
load(initializer)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
initializer "engine.copy_configs",
|
34
|
-
before: "decko.engine.load_config_initializers" do
|
35
|
-
# this code should all be in Decko somewhere, and it is now, gem-wize
|
36
|
-
# Ideally railties would do this for us; this is needed for both use cases
|
37
|
-
Engine.paths["request_log"] = Decko.paths["request_log"]
|
38
|
-
Engine.paths["log"] = Decko.paths["log"]
|
39
|
-
Engine.paths["lib/tasks"] = Decko.paths["lib/tasks"]
|
40
|
-
Engine.paths["config/routes.rb"] = Decko.paths["config/routes.rb"]
|
41
|
-
end
|
3
|
+
paths.add "config/routes.rb", with: "config/engine_routes.rb"
|
42
4
|
|
43
5
|
initializer :connect_on_load do
|
44
6
|
ActiveSupport.on_load(:active_record) do
|
45
7
|
ActiveRecord::Base.establish_connection(::Rails.env.to_sym)
|
46
8
|
end
|
47
|
-
# ActiveSupport.on_load(:after_initialize) do
|
48
|
-
# # require "card" if Cardio.load_card?
|
49
|
-
# Card if Cardio.load_card?
|
50
|
-
# rescue ActiveRecord::StatementInvalid => e
|
51
|
-
# ::Rails.logger.warn "database not available[#{::Rails.env}] #{e}"
|
52
|
-
# end
|
53
9
|
end
|
54
10
|
end
|
55
11
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
require "cardio/generators"
|
4
|
+
require "cardio/generators/class_methods"
|
5
|
+
|
6
|
+
# note: despite the decko file name the base class is Cardio
|
7
|
+
module Cardio
|
8
|
+
module Generators
|
9
|
+
# main definition of this module is in card gem
|
10
|
+
module ClassMethods
|
11
|
+
# generator USAGE docs will use "decko" rather than "card" when called with decko
|
12
|
+
def banner_command
|
13
|
+
"decko"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -11,7 +11,7 @@ CardSpecLoader.prefork do
|
|
11
11
|
Bundler.require(:test)
|
12
12
|
# if simplecov is activated in the Gemfile, it has to be required here
|
13
13
|
end
|
14
|
-
#
|
14
|
+
# Cardio::Seed.test_path = File.dirname(__FILE__) + '/../fixtures'
|
15
15
|
CardSpecLoader.rspec_config
|
16
16
|
end
|
17
17
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Decko
|
2
|
+
# decko configuration (also see cardio/railtie)
|
3
|
+
class Railtie < Rails::Railtie
|
4
|
+
config.assets.enabled = false
|
5
|
+
# config.assets.version = "1.0" # does the version matter if not enabled??
|
6
|
+
|
7
|
+
config.before_configuration do |app|
|
8
|
+
gem_root = Decko.gem_root
|
9
|
+
app.config.tap do |c|
|
10
|
+
c.allow_concurrency = false
|
11
|
+
c.filter_parameters += [:password]
|
12
|
+
c.autoload_paths += Dir["#{gem_root}/lib"]
|
13
|
+
|
14
|
+
c.paths.tap do |p|
|
15
|
+
p["lib/tasks"].unshift "#{gem_root}/lib/decko/tasks"
|
16
|
+
|
17
|
+
p["config/environments"].unshift "#{gem_root}/config/environments"
|
18
|
+
p["config/initializers"].unshift "#{gem_root}/config/initializers"
|
19
|
+
|
20
|
+
unless p["config/routes.rb"].existent.present?
|
21
|
+
p["config/routes.rb"] << "#{gem_root}/config/application_routes.rb"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,46 +1,13 @@
|
|
1
1
|
require "pathname"
|
2
2
|
|
3
|
+
require "cardio/script_loader"
|
4
|
+
|
3
5
|
module Decko
|
4
6
|
module ScriptDeckoLoader
|
5
|
-
|
6
|
-
RbConfig::CONFIG["EXEEXT"]
|
7
|
-
SCRIPT_DECKO = File.join("script", "decko")
|
8
|
-
|
9
|
-
class << self
|
10
|
-
def exec!
|
11
|
-
cwd = Dir.pwd
|
12
|
-
return unless continue?
|
13
|
-
|
14
|
-
exec_decko_script
|
15
|
-
recurse cwd
|
16
|
-
rescue SystemCallError
|
17
|
-
# could not chdir, no problem just return
|
18
|
-
end
|
19
|
-
|
20
|
-
def recurse cwd
|
21
|
-
Dir.chdir("..") do
|
22
|
-
# Recurse in a chdir block: if the search fails we want to be sure
|
23
|
-
# the application is generated in the original working directory.
|
24
|
-
exec! unless cwd == Dir.pwd
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def exec_decko_script
|
29
|
-
exec RUBY, SCRIPT_DECKO, *ARGV if in_application?
|
30
|
-
end
|
31
|
-
|
32
|
-
def continue?
|
33
|
-
in_application? || in_application_subdirectory?
|
34
|
-
end
|
35
|
-
|
36
|
-
def in_application?
|
37
|
-
File.exist?(SCRIPT_DECKO)
|
38
|
-
end
|
7
|
+
extend Cardio::ScriptLoader::ClassMethods
|
39
8
|
|
40
|
-
|
41
|
-
|
42
|
-
!path.root? && in_application_subdirectory?(path.parent)
|
43
|
-
end
|
9
|
+
def self.script
|
10
|
+
File.join("script", "decko")
|
44
11
|
end
|
45
12
|
end
|
46
13
|
end
|
@@ -5,35 +5,32 @@
|
|
5
5
|
# files.
|
6
6
|
|
7
7
|
unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gems:* tasks
|
8
|
-
|
9
|
-
|
10
|
-
unless vendored_cucumber_bin.nil?
|
11
|
-
$LOAD_PATH.unshift("#{File.dirname(vendored_cucumber_bin)}/../lib")
|
12
|
-
end
|
8
|
+
vendor_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
9
|
+
$LOAD_PATH.unshift(File.dirname(vendor_bin) + "/../lib") unless vendor_bin.nil?
|
13
10
|
|
14
11
|
begin
|
15
12
|
require "cucumber/rake/task"
|
16
13
|
|
17
14
|
namespace :cucumber do
|
18
|
-
Cucumber::Rake::Task.new({ ok: "
|
15
|
+
Cucumber::Rake::Task.new({ ok: "test:prepare" },
|
19
16
|
"Run features that should pass") do |t|
|
20
|
-
t.binary =
|
17
|
+
t.binary = vendor_bin # If nil, the gem's binary is used.
|
21
18
|
t.fork = true # You may get faster startup if you set this to false
|
22
19
|
t.profile = "default"
|
23
20
|
end
|
24
21
|
|
25
|
-
Cucumber::Rake::Task.new({ wip: "
|
22
|
+
Cucumber::Rake::Task.new({ wip: "test:prepare" },
|
26
23
|
"Run features that are being worked on") do |t|
|
27
|
-
t.binary =
|
24
|
+
t.binary = vendor_bin
|
28
25
|
t.fork = true # You may get faster startup if you set this to false
|
29
26
|
t.profile = "wip"
|
30
27
|
end
|
31
28
|
|
32
29
|
Cucumber::Rake::Task.new(
|
33
|
-
{ rerun: "
|
30
|
+
{ rerun: "test:prepare" },
|
34
31
|
"Record failing features and run only them if any exist"
|
35
32
|
) do |t|
|
36
|
-
t.binary =
|
33
|
+
t.binary = vendor_bin
|
37
34
|
t.fork = true # You may get faster startup if you set this to false
|
38
35
|
t.profile = "rerun"
|
39
36
|
end
|
@@ -45,7 +42,17 @@ unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gem
|
|
45
42
|
require "rails/code_statistics"
|
46
43
|
::STATS_DIRECTORIES << %w[Cucumber\ features features] if File.exist?("features")
|
47
44
|
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?("features")
|
48
|
-
|
45
|
+
end
|
46
|
+
|
47
|
+
task :annotations_setup do
|
48
|
+
Rails.application.configure do
|
49
|
+
if config.respond_to?(:annotations)
|
50
|
+
config.annotations.directories << "features"
|
51
|
+
config.annotations.register_extensions("feature") do |tag|
|
52
|
+
/#\s*(#{tag}):?\s*(.*)$/
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
49
56
|
end
|
50
57
|
end
|
51
58
|
desc "Alias for cucumber:ok"
|
@@ -54,14 +61,17 @@ unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gem
|
|
54
61
|
task default: :cucumber
|
55
62
|
|
56
63
|
task features: :cucumber do
|
57
|
-
|
64
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
58
65
|
end
|
59
66
|
|
60
|
-
# In case we don't have
|
61
|
-
task
|
67
|
+
# In case we don't have the generic Rails test:prepare hook,
|
68
|
+
# append a no-op task that we can depend upon.
|
69
|
+
task "test:prepare" do
|
62
70
|
end
|
63
71
|
|
64
72
|
task stats: "cucumber:statsetup"
|
73
|
+
|
74
|
+
task notes: "cucumber:annotations_setup"
|
65
75
|
rescue LoadError
|
66
76
|
desc "cucumber rake task not available (cucumber not installed)"
|
67
77
|
task :cucumber do
|
@@ -69,5 +79,4 @@ unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gem
|
|
69
79
|
"Be sure to install cucumber as a gem or plugin"
|
70
80
|
end
|
71
81
|
end
|
72
|
-
|
73
82
|
end
|
data/lib/decko/tasks/decko.rake
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "decko/application"
|
2
2
|
require_relative "alias"
|
3
|
-
require "card/seed_consts"
|
4
3
|
|
5
4
|
CARD_TASKS =
|
6
5
|
[
|
@@ -41,7 +40,7 @@ decko_namespace = namespace :decko do
|
|
41
40
|
conn = ActiveRecord::Base.connection
|
42
41
|
|
43
42
|
puts "delete all data in bootstrap tables"
|
44
|
-
|
43
|
+
Cardio::Seed::TABLES.each do |table|
|
45
44
|
conn.delete "delete from #{table}"
|
46
45
|
end
|
47
46
|
end
|
@@ -71,7 +70,7 @@ decko_namespace = namespace :decko do
|
|
71
70
|
end
|
72
71
|
|
73
72
|
puts "set symlink for assets"
|
74
|
-
decko_namespace["
|
73
|
+
decko_namespace["card:mod:symlink"].invoke
|
75
74
|
end
|
76
75
|
|
77
76
|
desc "reset with an empty tmp directory"
|
@@ -95,38 +94,19 @@ decko_namespace = namespace :decko do
|
|
95
94
|
decko_namespace["migrate"].invoke
|
96
95
|
decko_namespace["reset_tmp"].invoke
|
97
96
|
Card::Cache.reset_all
|
98
|
-
|
97
|
+
Rake::Task["card:mod:install"].invoke
|
98
|
+
Rake::Task["card:mod:symlink"].invoke
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
prepped_asset_path do |assets_path|
|
105
|
-
Cardio::Mod.dirs.each_assets_path do |mod, target|
|
106
|
-
link = File.join assets_path, mod
|
107
|
-
FileUtils.rm_rf link
|
108
|
-
FileUtils.ln_s target, link, force: true
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def prepped_asset_path
|
114
|
-
return if Rails.root.to_s == Decko.gem_root # inside decko gem
|
115
|
-
|
116
|
-
assets_path = File.join Rails.public_path, "assets"
|
117
|
-
if File.symlink?(assets_path) || !File.directory?(assets_path)
|
118
|
-
FileUtils.rm_rf assets_path
|
119
|
-
FileUtils.mkdir assets_path
|
120
|
-
end
|
121
|
-
yield assets_path
|
122
|
-
end
|
123
|
-
|
102
|
+
alias_task "mod:symlink", "card:mod:symlink"
|
103
|
+
alias_task "mod:install", "card:mod:install"
|
124
104
|
alias_task :migrate, "card:migrate"
|
125
105
|
|
126
106
|
desc "insert existing card migrations into schema_migrations_cards to avoid re-migrating"
|
127
107
|
task :assume_card_migrations do
|
128
108
|
require "decko/engine"
|
129
|
-
Cardio.assume_migrated_upto_version :core_cards
|
109
|
+
Cardio::Schema.assume_migrated_upto_version :core_cards
|
130
110
|
end
|
131
111
|
|
132
112
|
def seed with_cache_reset: true
|
@@ -143,7 +123,6 @@ decko_namespace = namespace :decko do
|
|
143
123
|
Rake::Task["db:create"].invoke
|
144
124
|
|
145
125
|
puts "loading schema"
|
146
|
-
|
147
126
|
Rake::Task["db:schema:load"].invoke
|
148
127
|
|
149
128
|
load_task = "decko:load"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "colorize"
|
2
|
+
require "benchmark"
|
3
|
+
|
4
|
+
namespace :decko do
|
5
|
+
namespace :benchmark do
|
6
|
+
desc "measure time for script generation"
|
7
|
+
task machines: :environment do
|
8
|
+
Benchmark.bm do |x|
|
9
|
+
regenerate x, :style
|
10
|
+
regenerate x, :script
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def regenerate benchmarker, all_field
|
17
|
+
Card::Auth.as_bot do
|
18
|
+
card = Card[:all, all_field]
|
19
|
+
Card::Machine.reset_all
|
20
|
+
|
21
|
+
card.machine_input_card.extended_item_cards.each do |i_card|
|
22
|
+
puts i_card
|
23
|
+
i_card.expire_machine_cache
|
24
|
+
end
|
25
|
+
|
26
|
+
%w[machine_output machine_cache].each do |code|
|
27
|
+
Card.search(right: { codename: code }).each(&:delete)
|
28
|
+
end
|
29
|
+
|
30
|
+
Card::Cache.reset_all
|
31
|
+
|
32
|
+
benchmarker.report(all_field) do
|
33
|
+
card.update_machine_output
|
34
|
+
# regenerate_machine_output
|
35
|
+
end
|
36
|
+
# puts Card[:all, all_field, :machine_output].attachment.read
|
37
|
+
end
|
38
|
+
end
|
@@ -16,7 +16,7 @@ namespace :decko do
|
|
16
16
|
|
17
17
|
# run yardoc command, which generates the docs content in the repo root
|
18
18
|
#
|
19
|
-
# If you run this while decko
|
19
|
+
# If you run this while using decko as a built gem, you could get some funky docs in
|
20
20
|
# your gems directory...
|
21
21
|
task :yardoc do
|
22
22
|
doc_dir = File.expand_path "..", Decko.gem_root
|
@@ -1,10 +1,12 @@
|
|
1
|
+
require "cardio/seed"
|
2
|
+
|
1
3
|
namespace :decko do
|
2
4
|
namespace :seed do
|
3
5
|
desc "reseed, migrate, re-clean, and re-dump"
|
4
6
|
task update: :environment do
|
5
7
|
ENV["STAMP_MIGRATIONS"] = "true"
|
6
8
|
ENV["GENERATE_FIXTURES"] = "true"
|
7
|
-
%w[reseed update seed:clean seed:supplement seed:dump].each do |task|
|
9
|
+
%w[reseed update mod:install seed:clean seed:supplement seed:dump].each do |task|
|
8
10
|
Rake::Task["decko:#{task}"].invoke
|
9
11
|
end
|
10
12
|
end
|
@@ -45,7 +47,7 @@ namespace :decko do
|
|
45
47
|
|
46
48
|
def clean_machines
|
47
49
|
puts "clean machines"
|
48
|
-
Card.
|
50
|
+
Card::Machine.reset_all
|
49
51
|
reseed_machine_output
|
50
52
|
clean_inputs_and_outputs
|
51
53
|
end
|
@@ -55,6 +57,9 @@ namespace :decko do
|
|
55
57
|
puts "coding machine output for #{name}"
|
56
58
|
Card[name].make_machine_output_coded
|
57
59
|
end
|
60
|
+
Card.search(type_id: Card::ModScriptAssetsID) do |card|
|
61
|
+
card.make_machine_output_coded true
|
62
|
+
end
|
58
63
|
end
|
59
64
|
|
60
65
|
def clean_inputs_and_outputs
|
@@ -70,13 +75,17 @@ namespace :decko do
|
|
70
75
|
end
|
71
76
|
|
72
77
|
def reserved_output? name
|
73
|
-
(
|
78
|
+
machine_seed_member?(name) &&
|
74
79
|
(name.right_name.key == :machine_output.cardname.key)
|
75
80
|
end
|
76
81
|
|
82
|
+
def machine_seed_member? name
|
83
|
+
machine_seed_names.member?(name.left_name.key) || name.match(/^mod:/)
|
84
|
+
end
|
85
|
+
|
77
86
|
def machine_seed_names
|
78
87
|
@machine_seed_names ||=
|
79
|
-
[%i[all
|
88
|
+
[%i[all style], [:script_html5shiv_printshiv]].map do |name|
|
80
89
|
Card::Name[*name]
|
81
90
|
end
|
82
91
|
end
|
@@ -119,14 +128,14 @@ namespace :decko do
|
|
119
128
|
def add_test_data
|
120
129
|
return unless Rails.env == "test"
|
121
130
|
|
122
|
-
load
|
131
|
+
load Cardio::Seed.test_script_path
|
123
132
|
SharedData.add_test_data
|
124
133
|
end
|
125
134
|
|
126
135
|
desc "dump db to bootstrap fixtures"
|
127
136
|
task dump: :environment do
|
128
137
|
Card::Cache.reset_all
|
129
|
-
|
138
|
+
Cardio::Seed::TABLES.each do |table|
|
130
139
|
i = "000"
|
131
140
|
write_seed_file table do
|
132
141
|
yamlize_records table do |record, hash|
|
@@ -137,7 +146,7 @@ namespace :decko do
|
|
137
146
|
end
|
138
147
|
|
139
148
|
def write_seed_file table
|
140
|
-
path = Rails.env == "test" ?
|
149
|
+
path = Rails.env == "test" ? Cardio::Seed.test_path : Cardio::Seed.path
|
141
150
|
filename = File.join path, "#{table}.yml"
|
142
151
|
File.open filename, "w" do |file|
|
143
152
|
file.write yield
|