wagn 1.18.6 → 1.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +2 -2
- data/bin/wagn +3 -3
- data/features/notifications.feature +1 -0
- data/features/rules.feature +2 -0
- data/features/step_definitions/email_steps.rb +10 -2
- data/features/step_definitions/history_steps.rb +1 -1
- data/features/step_definitions/wagn_steps.rb +72 -48
- data/features/step_definitions/web_steps.rb +12 -12
- data/features/step_definitions/window_steps.rb +3 -3
- data/features/structure.feature +1 -0
- data/features/support/delayed_job.rb +18 -0
- data/features/support/env.rb +43 -24
- data/features/support/paths.rb +4 -4
- data/features/support/scopes.rb +6 -6
- data/features/support/wagn_env.rb +2 -2
- data/features/table_of_contents.feature +1 -0
- data/features/update_includers.feature +2 -4
- data/lib/decko/engine.rb +29 -28
- data/lib/wagn.rb +1 -1
- data/lib/wagn/all.rb +1 -1
- data/lib/wagn/application.rb +9 -9
- data/lib/wagn/cli.rb +5 -5
- data/lib/wagn/commands.rb +48 -48
- data/lib/wagn/commands/application.rb +4 -4
- data/lib/wagn/config/environments/cucumber.rb +2 -0
- data/lib/wagn/config/environments/development.rb +2 -2
- data/lib/wagn/config/environments/production.rb +2 -2
- data/lib/wagn/config/environments/test.rb +12 -3
- data/lib/wagn/config/initializers/secret_token.rb +2 -2
- data/lib/wagn/generators/wagn/templates/Gemfile +38 -51
- data/lib/wagn/generators/wagn/templates/bin/spring +6 -6
- data/lib/wagn/generators/wagn/templates/config/application.rb +12 -1
- data/lib/wagn/generators/wagn/templates/spec/javascripts/support/deck_jasmine.yml +2 -2
- data/lib/wagn/generators/wagn/templates/spec/javascripts/support/wagn_jasmine.yml +15 -10
- data/lib/wagn/generators/wagn/templates/spec/spec_helper.rb +1 -1
- data/lib/wagn/generators/wagn/wagn_generator.rb +87 -87
- data/lib/wagn/generators/wagn/wagn_generator/interactive.rb +28 -28
- data/lib/wagn/mods_spec_helper.rb +9 -9
- data/lib/wagn/parser.rb +27 -27
- data/lib/wagn/response.rb +106 -0
- data/lib/wagn/script_wagn_loader.rb +4 -4
- data/lib/wagn/simplecov_helper.rb +19 -19
- data/lib/wagn/tasks/cucumber.rake +19 -19
- data/lib/wagn/tasks/db.rake +8 -8
- data/lib/wagn/tasks/test.rake +25 -25
- data/lib/wagn/tasks/wagn.rake +107 -110
- data/rails/application-routes.rb +2 -2
- data/rails/controllers/card_controller.rb +37 -196
- data/rails/engine-routes.rb +29 -29
- data/script/autospec +3 -3
- data/script/rails +3 -3
- data/script/test_filter +2 -2
- data/script/wagn +3 -3
- data/spec/controllers/card_controller_spec.rb +194 -170
- data/spec/controllers/location_spec.rb +10 -10
- data/spec/javascripts/support/jasmine.yml.erb +4 -4
- data/spec/javascripts/support/jasmine_config.rb +4 -4
- data/spec/javascripts/support/jasmine_runner.rb +5 -5
- data/test/performance/card_create_test.rb +5 -5
- data/test/performance/fetch_test.rb +3 -3
- data/test/performance/homepage_test.rb +3 -3
- data/test/performance/render_test.rb +3 -3
- data/test/test_helper.rb +14 -14
- data/wagn.gemspec +16 -16
- metadata +7 -5
@@ -7,42 +7,42 @@
|
|
7
7
|
unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gems:* tasks
|
8
8
|
|
9
9
|
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
10
|
-
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) +
|
10
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + "/../lib") unless vendored_cucumber_bin.nil?
|
11
11
|
|
12
12
|
begin
|
13
|
-
require
|
13
|
+
require "cucumber/rake/task"
|
14
14
|
|
15
15
|
namespace :cucumber do
|
16
|
-
Cucumber::Rake::Task.new({ ok:
|
16
|
+
Cucumber::Rake::Task.new({ ok: "db:test:prepare" }, "Run features that should pass") do |t|
|
17
17
|
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
18
18
|
t.fork = true # You may get faster startup if you set this to false
|
19
|
-
t.profile =
|
19
|
+
t.profile = "default"
|
20
20
|
end
|
21
21
|
|
22
|
-
Cucumber::Rake::Task.new({ wip:
|
22
|
+
Cucumber::Rake::Task.new({ wip: "db:test:prepare" }, "Run features that are being worked on") do |t|
|
23
23
|
t.binary = vendored_cucumber_bin
|
24
24
|
t.fork = true # You may get faster startup if you set this to false
|
25
|
-
t.profile =
|
25
|
+
t.profile = "wip"
|
26
26
|
end
|
27
27
|
|
28
|
-
Cucumber::Rake::Task.new({ rerun:
|
28
|
+
Cucumber::Rake::Task.new({ rerun: "db:test:prepare" }, "Record failing features and run only them if any exist") do |t|
|
29
29
|
t.binary = vendored_cucumber_bin
|
30
30
|
t.fork = true # You may get faster startup if you set this to false
|
31
|
-
t.profile =
|
31
|
+
t.profile = "rerun"
|
32
32
|
end
|
33
33
|
|
34
|
-
desc
|
34
|
+
desc "Run all features"
|
35
35
|
task all: [:ok, :wip]
|
36
36
|
|
37
37
|
task :statsetup do
|
38
|
-
require
|
39
|
-
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?(
|
40
|
-
::CodeStatistics::TEST_TYPES <<
|
41
|
-
::STATS_DIRECTORIES << %w(Mods mods) if File.exist?(
|
38
|
+
require "rails/code_statistics"
|
39
|
+
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?("features")
|
40
|
+
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?("features")
|
41
|
+
::STATS_DIRECTORIES << %w(Mods mods) if File.exist?("mods") # hack! should be elsewhere
|
42
42
|
end
|
43
43
|
end
|
44
|
-
desc
|
45
|
-
task cucumber:
|
44
|
+
desc "Alias for cucumber:ok"
|
45
|
+
task cucumber: "cucumber:ok"
|
46
46
|
|
47
47
|
task default: :cucumber
|
48
48
|
|
@@ -51,14 +51,14 @@ begin
|
|
51
51
|
end
|
52
52
|
|
53
53
|
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
|
54
|
-
task
|
54
|
+
task "db:test:prepare" do
|
55
55
|
end
|
56
56
|
|
57
|
-
task stats:
|
57
|
+
task stats: "cucumber:statsetup"
|
58
58
|
rescue LoadError
|
59
|
-
desc
|
59
|
+
desc "cucumber rake task not available (cucumber not installed)"
|
60
60
|
task :cucumber do
|
61
|
-
abort
|
61
|
+
abort "Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin"
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
data/lib/wagn/tasks/db.rake
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "rake"
|
2
2
|
|
3
3
|
# This code lets us redefine existing Rake tasks, which is extremely
|
4
4
|
# handy for modifying existing Rails rake tasks.
|
@@ -33,22 +33,22 @@ namespace :db do
|
|
33
33
|
namespace :fixtures do
|
34
34
|
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
35
35
|
task load: :environment do
|
36
|
-
require
|
37
|
-
fixture_path = File.join(Cardio.gem_root,
|
36
|
+
require "active_record/fixtures"
|
37
|
+
fixture_path = File.join(Cardio.gem_root, "db", "seed", "test", "fixtures")
|
38
38
|
ActiveRecord::Base.establish_connection(::Rails.env.to_sym)
|
39
|
-
(ENV[
|
40
|
-
ActiveRecord::FixtureSet.create_fixtures(fixture_path, File.basename(fixture_file,
|
39
|
+
(ENV["FIXTURES"] ? ENV["FIXTURES"].split(/,/) : Dir.glob(File.join(fixture_path, "*.{yml,csv}"))).each do |fixture_file|
|
40
|
+
ActiveRecord::FixtureSet.create_fixtures(fixture_path, File.basename(fixture_file, ".*"))
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
namespace :test do
|
46
|
-
desc
|
46
|
+
desc "Prepare the test database and load the schema"
|
47
47
|
Rake::Task.redefine_task(prepare: :environment) do
|
48
|
-
if ENV[
|
48
|
+
if ENV["RELOAD_TEST_DATA"] == "true" || ENV["RUN_CODE_RUN"]
|
49
49
|
puts `env RAILS_ENV=test rake wagn:seed`
|
50
50
|
else
|
51
|
-
puts
|
51
|
+
puts "skipping loading test data. to force, run `env RELOAD_TEST_DATA=true rake db:test:prepare`"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
data/lib/wagn/tasks/test.rake
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
TEST_SEED_PATH = File.join(
|
2
|
-
ENV[
|
2
|
+
ENV["DECKO_SEED_REPO_PATH"] || [Cardio.gem_root, "db", "seed"], "test"
|
3
3
|
)
|
4
4
|
|
5
5
|
namespace :test do
|
6
6
|
task all: :environment do
|
7
|
-
puts
|
8
|
-
Rake::Task[
|
9
|
-
puts
|
10
|
-
Rake::Task[
|
11
|
-
puts
|
7
|
+
puts "This is not yet working; only first invocation takes effect"
|
8
|
+
Rake::Task["test:functionals"].invoke
|
9
|
+
puts "put 2"
|
10
|
+
Rake::Task["test:functionals"].invoke
|
11
|
+
puts "put 3"
|
12
12
|
|
13
13
|
# Rake::Task['test'].invoke
|
14
14
|
# Rake::Task['spec'].invoke
|
@@ -17,40 +17,40 @@ namespace :test do
|
|
17
17
|
|
18
18
|
## FIXME: this generates an "Adminstrator links" card with the wrong reader_id, I have been
|
19
19
|
## setting it by hand after fixture generation.
|
20
|
-
desc
|
20
|
+
desc "recreate test fixtures from fresh db"
|
21
21
|
task generate_fixtures: :environment do
|
22
|
-
ENV[
|
23
|
-
raise
|
22
|
+
ENV["GENERATE_FIXTURES"] = "true"
|
23
|
+
raise "must be test env" unless Rails.env == "test"
|
24
24
|
|
25
|
-
Rake::Task[
|
25
|
+
Rake::Task["wagn:reset_cache"]
|
26
26
|
|
27
|
-
puts
|
28
|
-
Rake::Task[
|
27
|
+
puts "reseed test db"
|
28
|
+
Rake::Task["wagn:seed"].invoke
|
29
29
|
|
30
|
-
puts
|
30
|
+
puts ">>populating test data"
|
31
31
|
puts `rake test:populate_template_database --trace`
|
32
32
|
|
33
|
-
puts
|
33
|
+
puts ">>extracting to fixtures"
|
34
34
|
puts `rake test:extract_fixtures --trace`
|
35
35
|
end
|
36
36
|
|
37
|
-
desc
|
37
|
+
desc "dump current db to test fixtures"
|
38
38
|
task extract_fixtures: :environment do
|
39
|
-
raise
|
40
|
-
YAML::ENGINE.yamler =
|
39
|
+
raise "must be test env" unless Rails.env == "test"
|
40
|
+
YAML::ENGINE.yamler = "syck" if RUBY_VERSION !~ /^(2|1\.9)/
|
41
41
|
# use old engine while we're supporting ruby 1.8.7 because it can't support Psych,
|
42
42
|
# which dumps with slashes that syck can't understand (also !!null stuff)
|
43
43
|
|
44
|
-
sql =
|
45
|
-
tables = %w(
|
44
|
+
sql = "SELECT * FROM %s"
|
45
|
+
tables = %w(cards card_acts card_actions card_changes card_references)
|
46
46
|
ActiveRecord::Base.establish_connection
|
47
47
|
tables.each do |table_name|
|
48
|
-
i =
|
49
|
-
File.open("#{TEST_SEED_PATH}/fixtures/#{table_name}.yml",
|
48
|
+
i = "000"
|
49
|
+
File.open("#{TEST_SEED_PATH}/fixtures/#{table_name}.yml", "w") do |file|
|
50
50
|
data = ActiveRecord::Base.connection.select_all(sql % table_name)
|
51
51
|
file.write data.inject({}) { |hash, record|
|
52
|
-
record[
|
53
|
-
record[
|
52
|
+
record["trash"] = false if record.key? "trash"
|
53
|
+
record["draft"] = false if record.key? "draft"
|
54
54
|
hash["#{table_name}_#{i.succ!}"] = record
|
55
55
|
hash
|
56
56
|
}.to_yaml
|
@@ -58,9 +58,9 @@ namespace :test do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
desc
|
61
|
+
desc "create sample data for testing"
|
62
62
|
task populate_template_database: :environment do
|
63
|
-
raise
|
63
|
+
raise "must be test env" unless Rails.env == "test"
|
64
64
|
puts "populate test data\n"
|
65
65
|
load "#{TEST_SEED_PATH}/seed.rb"
|
66
66
|
SharedData.add_test_data
|
data/lib/wagn/tasks/wagn.rake
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require "wagn/application"
|
2
2
|
|
3
3
|
WAGN_SEED_TABLES = %w( cards card_actions card_acts card_changes
|
4
4
|
card_references ).freeze
|
5
5
|
WAGN_SEED_PATH = File.join(
|
6
|
-
ENV[
|
6
|
+
ENV["DECKO_SEED_REPO_PATH"] || [Cardio.gem_root, "db", "seed"], "new"
|
7
7
|
)
|
8
8
|
|
9
9
|
def run_card_migration core_or_deck
|
10
10
|
prepare_migration
|
11
|
-
verbose = ENV[
|
11
|
+
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
12
12
|
Cardio.schema_mode(core_or_deck) do |paths|
|
13
13
|
ActiveRecord::Migrator.migrations_paths = paths
|
14
14
|
ActiveRecord::Migration.verbose = verbose
|
@@ -18,7 +18,7 @@ end
|
|
18
18
|
|
19
19
|
def prepare_migration
|
20
20
|
Card::Cache.reset_all
|
21
|
-
ENV[
|
21
|
+
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
22
22
|
Card::Cache.reset_all
|
23
23
|
Card.config.action_mailer.perform_deliveries = false
|
24
24
|
Card.reset_column_information
|
@@ -28,183 +28,180 @@ def prepare_migration
|
|
28
28
|
end
|
29
29
|
|
30
30
|
namespace :wagn do
|
31
|
-
desc
|
31
|
+
desc "create a wagn database from scratch, load initial data"
|
32
32
|
task :seed do
|
33
|
-
ENV[
|
34
|
-
puts
|
33
|
+
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
34
|
+
puts "dropping"
|
35
35
|
# FIXME: this should be an option, but should not happen on standard
|
36
36
|
# creates!
|
37
37
|
begin
|
38
|
-
Rake::Task[
|
38
|
+
Rake::Task["db:drop"].invoke
|
39
39
|
rescue
|
40
|
-
puts
|
40
|
+
puts "not dropped"
|
41
41
|
end
|
42
42
|
|
43
|
-
puts
|
44
|
-
Rake::Task[
|
43
|
+
puts "creating"
|
44
|
+
Rake::Task["db:create"].invoke
|
45
45
|
|
46
|
-
puts
|
47
|
-
Rake::Task[
|
46
|
+
puts "loading schema"
|
47
|
+
Rake::Task["db:schema:load"].invoke
|
48
48
|
|
49
|
-
Rake::Task[
|
49
|
+
Rake::Task["wagn:load"].invoke
|
50
50
|
end
|
51
51
|
|
52
|
-
desc
|
52
|
+
desc "clear and load fixtures with existing tables"
|
53
53
|
task :reseed do
|
54
|
-
ENV[
|
54
|
+
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
55
55
|
|
56
|
-
Rake::Task[
|
56
|
+
Rake::Task["wagn:clear"].invoke
|
57
57
|
|
58
|
-
Rake::Task[
|
58
|
+
Rake::Task["wagn:load"].invoke
|
59
59
|
end
|
60
60
|
|
61
|
-
desc
|
61
|
+
desc "empty the card tables"
|
62
62
|
task :clear do
|
63
63
|
conn = ActiveRecord::Base.connection
|
64
64
|
|
65
|
-
puts
|
65
|
+
puts "delete all data in bootstrap tables"
|
66
66
|
WAGN_SEED_TABLES.each do |table|
|
67
67
|
conn.delete "delete from #{table}"
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
desc
|
71
|
+
desc "Load bootstrap data into database"
|
72
72
|
task :load do
|
73
|
-
require
|
74
|
-
puts
|
75
|
-
Rake::Task[
|
73
|
+
require "decko/engine"
|
74
|
+
puts "update card_migrations"
|
75
|
+
Rake::Task["wagn:assume_card_migrations"].invoke
|
76
76
|
|
77
|
-
if Rails.env ==
|
78
|
-
puts
|
79
|
-
Rake::Task[
|
77
|
+
if Rails.env == "test" && !ENV["GENERATE_FIXTURES"]
|
78
|
+
puts "loading test fixtures"
|
79
|
+
Rake::Task["db:fixtures:load"].invoke
|
80
80
|
else
|
81
|
-
puts
|
82
|
-
Rake::Task[
|
81
|
+
puts "loading bootstrap"
|
82
|
+
Rake::Task["wagn:bootstrap:load"].invoke
|
83
83
|
end
|
84
84
|
|
85
|
-
puts
|
86
|
-
Rake::Task[
|
85
|
+
puts "set symlink for assets"
|
86
|
+
Rake::Task["wagn:update_assets_symlink"].invoke
|
87
87
|
|
88
|
-
puts
|
89
|
-
system
|
88
|
+
puts "reset cache"
|
89
|
+
system "bundle exec rake wagn:reset_cache" # needs loaded environment
|
90
90
|
end
|
91
91
|
|
92
|
-
desc
|
92
|
+
desc "update wagn gems and database"
|
93
93
|
task :update do
|
94
|
-
ENV[
|
94
|
+
ENV["NO_RAILS_CACHE"] = "true"
|
95
95
|
# system 'bundle update'
|
96
|
-
if Wagn.paths[
|
97
|
-
FileUtils.rm_rf Wagn.paths[
|
96
|
+
if Wagn.paths["tmp"].existent
|
97
|
+
FileUtils.rm_rf Wagn.paths["tmp"].first, secure: true
|
98
98
|
end
|
99
|
-
Dir.mkdir Wagn.paths[
|
100
|
-
Rake::Task[
|
99
|
+
Dir.mkdir Wagn.paths["tmp"].first
|
100
|
+
Rake::Task["wagn:migrate"].invoke
|
101
101
|
# FIXME: remove tmp dir / clear cache
|
102
|
-
puts
|
103
|
-
Rake::Task[
|
102
|
+
puts "set symlink for assets"
|
103
|
+
Rake::Task["wagn:update_assets_symlink"].invoke
|
104
104
|
end
|
105
105
|
|
106
|
-
desc
|
106
|
+
desc "reset cache"
|
107
107
|
task reset_cache: :environment do
|
108
108
|
Card::Cache.reset_all
|
109
109
|
end
|
110
110
|
|
111
|
-
desc
|
111
|
+
desc "set symlink for assets"
|
112
112
|
task :update_assets_symlink do
|
113
|
-
assets_path = File.join(Rails.public_path,
|
113
|
+
assets_path = File.join(Rails.public_path, "assets")
|
114
114
|
if Rails.root.to_s != Wagn.gem_root && !File.exist?(assets_path)
|
115
115
|
FileUtils.rm assets_path if File.symlink? assets_path
|
116
|
-
FileUtils.ln_s(Decko::Engine.paths[
|
116
|
+
FileUtils.ln_s(Decko::Engine.paths["gem-assets"].first, assets_path)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
-
desc
|
120
|
+
desc "migrate structure and cards"
|
121
121
|
task migrate: :environment do
|
122
|
-
ENV[
|
123
|
-
ENV[
|
122
|
+
ENV["NO_RAILS_CACHE"] = "true"
|
123
|
+
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
124
124
|
|
125
|
-
stamp = ENV[
|
125
|
+
stamp = ENV["STAMP_MIGRATIONS"]
|
126
126
|
|
127
|
-
puts
|
128
|
-
Rake::Task[
|
129
|
-
Rake::Task[
|
127
|
+
puts "migrating structure"
|
128
|
+
Rake::Task["wagn:migrate:structure"].invoke
|
129
|
+
Rake::Task["wagn:migrate:stamp"].invoke :structure if stamp
|
130
130
|
|
131
|
-
puts
|
131
|
+
puts "migrating core cards"
|
132
132
|
Card::Cache.reset_all
|
133
133
|
# not invoke because we don't want to reload environment
|
134
|
-
Rake::Task[
|
134
|
+
Rake::Task["wagn:migrate:core_cards"].execute
|
135
135
|
if stamp
|
136
|
-
Rake::Task[
|
137
|
-
Rake::Task[
|
136
|
+
Rake::Task["wagn:migrate:stamp"].reenable
|
137
|
+
Rake::Task["wagn:migrate:stamp"].invoke :core_cards
|
138
138
|
end
|
139
139
|
|
140
|
-
puts
|
140
|
+
puts "migrating deck cards"
|
141
141
|
# not invoke because we don't want to reload environment
|
142
|
-
Rake::Task[
|
142
|
+
Rake::Task["wagn:migrate:deck_cards"].execute
|
143
143
|
if stamp
|
144
|
-
Rake::Task[
|
145
|
-
Rake::Task[
|
144
|
+
Rake::Task["wagn:migrate:stamp"].reenable
|
145
|
+
Rake::Task["wagn:migrate:stamp"].invoke :deck_cards
|
146
146
|
end
|
147
147
|
|
148
148
|
Card::Cache.reset_all
|
149
149
|
end
|
150
150
|
|
151
|
-
desc
|
151
|
+
desc "insert existing card migrations into schema_migrations_cards to avoid re-migrating"
|
152
152
|
task :assume_card_migrations do
|
153
|
-
require
|
153
|
+
require "decko/engine"
|
154
154
|
|
155
155
|
Cardio.assume_migrated_upto_version :core_cards
|
156
156
|
end
|
157
157
|
|
158
158
|
namespace :migrate do
|
159
|
-
desc
|
160
|
-
task cards: :
|
161
|
-
Rake::Task['wagn:migrate:core_cards'].invoke
|
162
|
-
Rake::Task['wagn:migrate:deck_cards'].execute
|
163
|
-
end
|
159
|
+
desc "migrate cards"
|
160
|
+
task cards: [:core_cards, :deck_cards]
|
164
161
|
|
165
|
-
desc
|
162
|
+
desc "migrate structure"
|
166
163
|
task structure: :environment do
|
167
|
-
ENV[
|
164
|
+
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
168
165
|
Cardio.schema_mode(:structure) do |paths|
|
169
166
|
ActiveRecord::Migrator.migrations_paths = paths
|
170
167
|
ActiveRecord::Migrator.migrate paths, version
|
171
|
-
Rake::Task[
|
168
|
+
Rake::Task["db:_dump"].invoke # write schema.rb
|
172
169
|
end
|
173
170
|
end
|
174
171
|
|
175
|
-
desc
|
172
|
+
desc "migrate core cards"
|
176
173
|
task core_cards: :environment do
|
177
|
-
require
|
174
|
+
require "card/migration/core"
|
178
175
|
run_card_migration :core_cards
|
179
176
|
end
|
180
177
|
|
181
|
-
desc
|
178
|
+
desc "migrate deck cards"
|
182
179
|
task deck_cards: :environment do
|
183
|
-
require
|
180
|
+
require "card/migration"
|
184
181
|
run_card_migration :deck_cards
|
185
182
|
end
|
186
183
|
|
187
184
|
desc 'Runs the "up" for a given deck cards migration VERSION.'
|
188
185
|
task up: :environment do
|
189
|
-
version = ENV[
|
190
|
-
verbose = ENV[
|
191
|
-
raise
|
186
|
+
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
187
|
+
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
188
|
+
raise "VERSION is required" unless version
|
192
189
|
ActiveRecord::Migration.verbose = verbose
|
193
190
|
ActiveRecord::Migrator.run :up, Cardio.migration_paths(:deck_cards),
|
194
191
|
version
|
195
192
|
end
|
196
193
|
|
197
194
|
# maybe we should move this to a method?
|
198
|
-
desc
|
195
|
+
desc "write the version to a file (not usually called directly)"
|
199
196
|
task :stamp, :type do |_t, args|
|
200
|
-
ENV[
|
197
|
+
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
201
198
|
Cardio.config.action_mailer.perform_deliveries = false
|
202
199
|
|
203
200
|
stamp_file = Cardio.schema_stamp_path(args[:type])
|
204
201
|
|
205
202
|
Cardio.schema_mode args[:type] do
|
206
203
|
version = ActiveRecord::Migrator.current_version
|
207
|
-
if version.to_i > 0 && (file = open(stamp_file,
|
204
|
+
if version.to_i > 0 && (file = open(stamp_file, "w"))
|
208
205
|
puts ">> writing version: #{version} to #{stamp_file}"
|
209
206
|
file.puts version
|
210
207
|
end
|
@@ -216,7 +213,7 @@ namespace :wagn do
|
|
216
213
|
task rescue_watchers: :environment do
|
217
214
|
follower_hash = Hash.new { |h, v| h[v] = [] }
|
218
215
|
|
219
|
-
Card.where(
|
216
|
+
Card.where("right_id" => 219).each do |watcher_list|
|
220
217
|
watcher_list.include_set_modules
|
221
218
|
next unless watcher_list.left
|
222
219
|
watching = watcher_list.left.name
|
@@ -225,16 +222,16 @@ namespace :wagn do
|
|
225
222
|
end
|
226
223
|
end
|
227
224
|
|
228
|
-
Card.search(right: { codename:
|
225
|
+
Card.search(right: { codename: "following" }).each do |following|
|
229
226
|
Card::Auth.as_bot do
|
230
|
-
following.update_attributes! content:
|
227
|
+
following.update_attributes! content: ""
|
231
228
|
end
|
232
229
|
end
|
233
230
|
|
234
231
|
follower_hash.each do |user, items|
|
235
232
|
next unless (card = Card.fetch(user)) && card.account
|
236
233
|
Card::Auth.as(user) do
|
237
|
-
following = card.fetch trait:
|
234
|
+
following = card.fetch trait: "following", new: {}
|
238
235
|
following.items = items
|
239
236
|
end
|
240
237
|
end
|
@@ -242,7 +239,7 @@ namespace :wagn do
|
|
242
239
|
end
|
243
240
|
|
244
241
|
namespace :bootstrap do
|
245
|
-
desc
|
242
|
+
desc "rid template of unneeded cards, acts, actions, changes, and references"
|
246
243
|
task clean: :environment do
|
247
244
|
Card::Cache.reset_all
|
248
245
|
clear_history
|
@@ -252,28 +249,28 @@ namespace :wagn do
|
|
252
249
|
Card::Cache.reset_all
|
253
250
|
end
|
254
251
|
|
255
|
-
desc
|
252
|
+
desc "dump db to bootstrap fixtures"
|
256
253
|
task dump: :environment do
|
257
254
|
Card::Cache.reset_all
|
258
255
|
|
259
256
|
# FIXME: temporarily taking this out!!
|
260
|
-
Rake::Task[
|
257
|
+
Rake::Task["wagn:bootstrap:copy_mod_files"].invoke
|
261
258
|
|
262
|
-
YAML::ENGINE.yamler =
|
259
|
+
YAML::ENGINE.yamler = "syck" if RUBY_VERSION !~ /^(2|1\.9)/
|
263
260
|
# use old engine while we're supporting ruby 1.8.7 because it can't
|
264
261
|
# support Psych, which dumps with slashes that syck can't understand
|
265
262
|
|
266
263
|
WAGN_SEED_TABLES.each do |table|
|
267
|
-
i =
|
268
|
-
File.open(File.join(WAGN_SEED_PATH, "#{table}.yml"),
|
264
|
+
i = "000"
|
265
|
+
File.open(File.join(WAGN_SEED_PATH, "#{table}.yml"), "w") do |file|
|
269
266
|
data = ActiveRecord::Base.connection.select_all(
|
270
267
|
"select * from #{table}"
|
271
268
|
)
|
272
269
|
file.write YAML.dump(data.each_with_object({}) do |record, hash|
|
273
|
-
record[
|
274
|
-
record[
|
275
|
-
if record.key?
|
276
|
-
record[
|
270
|
+
record["trash"] = false if record.key? "trash"
|
271
|
+
record["draft"] = false if record.key? "draft"
|
272
|
+
if record.key? "content"
|
273
|
+
record["content"] = record["content"].gsub(/\u00A0/, " ")
|
277
274
|
# sych was handling nonbreaking spaces oddly.
|
278
275
|
# would not be needed with psych.
|
279
276
|
end
|
@@ -283,22 +280,22 @@ namespace :wagn do
|
|
283
280
|
end
|
284
281
|
end
|
285
282
|
|
286
|
-
desc
|
283
|
+
desc "copy files from template database to standard mod and update cards"
|
287
284
|
task copy_mod_files: :environment do
|
288
285
|
source_files_dir = "#{Wagn.root}/files"
|
289
286
|
|
290
287
|
# mark mod files as mod files
|
291
288
|
Card::Auth.as_bot do
|
292
|
-
Card.search(type: %w(in Image File), ne:
|
293
|
-
if card.mod_file? || card.codename ==
|
294
|
-
card.codename ==
|
289
|
+
Card.search(type: %w(in Image File), ne: "").each do |card|
|
290
|
+
if card.mod_file? || card.codename == "new_file" ||
|
291
|
+
card.codename == "new_image"
|
295
292
|
puts "skipping #{card.name}: already in code"
|
296
293
|
next
|
297
294
|
else
|
298
295
|
puts "working on #{card.name}"
|
299
296
|
end
|
300
297
|
|
301
|
-
raise
|
298
|
+
raise "need codename for file" unless card.codename.present?
|
302
299
|
|
303
300
|
files = { original: card.attachment.path }
|
304
301
|
card.attachment.versions.each_key do |version|
|
@@ -307,13 +304,13 @@ namespace :wagn do
|
|
307
304
|
|
308
305
|
# make card a mod file card
|
309
306
|
mod_name = if (l = card.left) && l.type_id == Card::SkinID
|
310
|
-
|
307
|
+
"bootstrap"
|
311
308
|
else
|
312
|
-
|
309
|
+
"standard"
|
313
310
|
end
|
314
311
|
card.update_column :db_content,
|
315
312
|
card.attachment.db_content(mod: mod_name)
|
316
|
-
card.last_action.
|
313
|
+
card.last_action.change(:content)
|
317
314
|
.update_column :value, card.attachment.db_content(mod: mod_name)
|
318
315
|
card.expire
|
319
316
|
card = Card.fetch card.name
|
@@ -327,12 +324,12 @@ namespace :wagn do
|
|
327
324
|
end
|
328
325
|
end
|
329
326
|
|
330
|
-
desc
|
327
|
+
desc "load bootstrap fixtures into db"
|
331
328
|
task load: :environment do
|
332
329
|
# FIXME: shouldn't we be more standard and use seed.rb for this code?
|
333
330
|
Rake.application.options.trace = true
|
334
331
|
puts "bootstrap load starting #{WAGN_SEED_PATH}"
|
335
|
-
require
|
332
|
+
require "active_record/fixtures"
|
336
333
|
ActiveRecord::FixtureSet.create_fixtures WAGN_SEED_PATH, WAGN_SEED_TABLES
|
337
334
|
end
|
338
335
|
end
|
@@ -348,14 +345,14 @@ end
|
|
348
345
|
|
349
346
|
def delete_unwanted_cards
|
350
347
|
Card::Auth.as_bot do
|
351
|
-
if (ignoramus = Card[
|
348
|
+
if (ignoramus = Card["*ignore"])
|
352
349
|
ignoramus.item_cards.each(&:delete!)
|
353
350
|
end
|
354
351
|
Card::Cache.reset_all
|
355
352
|
# FIXME: can this be associated with the machine module somehow?
|
356
|
-
%w(
|
353
|
+
%w(machine_input machine_output).each do |codename|
|
357
354
|
Card.search(right: { codename: codename }).each do |card|
|
358
|
-
FileUtils.rm_rf File.join(
|
355
|
+
FileUtils.rm_rf File.join("files", card.id.to_s), secure: true
|
359
356
|
card.delete!
|
360
357
|
end
|
361
358
|
end
|
@@ -367,8 +364,8 @@ def clear_history
|
|
367
364
|
Card::Change.delete_actionless
|
368
365
|
|
369
366
|
conn = ActiveRecord::Base.connection
|
370
|
-
conn.execute(
|
371
|
-
conn.execute(
|
367
|
+
conn.execute("truncate card_acts")
|
368
|
+
conn.execute("truncate sessions")
|
372
369
|
act = Card::Act.create! actor_id: Card::WagnBotID,
|
373
370
|
card_id: Card::WagnBotID
|
374
371
|
Card::Action.find_each do |action|
|
@@ -377,5 +374,5 @@ def clear_history
|
|
377
374
|
end
|
378
375
|
|
379
376
|
def version
|
380
|
-
ENV[
|
377
|
+
ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
381
378
|
end
|