wagn 1.19.6 → 1.20.0
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/features/history.feature +10 -7
- data/features/paging.feature +1 -1
- data/features/step_definitions/history_steps.rb +1 -1
- data/features/step_definitions/wagn_steps.rb +1 -1
- data/features/step_definitions/web_steps.rb +20 -7
- data/features/support/paths.rb +3 -1
- data/features/support/scopes.rb +3 -0
- data/lib/wagn/commands.rb +47 -84
- data/lib/wagn/commands/command.rb +15 -0
- data/lib/wagn/commands/cucumber_command.rb +41 -0
- data/lib/wagn/commands/rake_command.rb +35 -0
- data/lib/wagn/commands/rake_command/parser.rb +34 -0
- data/lib/wagn/commands/rspec_command.rb +50 -0
- data/lib/wagn/commands/rspec_command/parser.rb +84 -0
- data/lib/wagn/generators/wagn/templates/Gemfile +3 -1
- data/lib/wagn/tasks/wagn.rake +0 -196
- data/lib/wagn/tasks/wagn/bootstrap.rake +121 -0
- data/lib/wagn/tasks/wagn/migrate.rake +77 -0
- data/rails/controllers/card_controller.rb +0 -1
- data/rails/engine-routes.rb +2 -2
- data/spec/controllers/card_controller_spec.rb +11 -11
- metadata +12 -5
- data/lib/wagn/parser.rb +0 -93
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd1e828fb6c8ee33f6cc48e17c3b5a102eb90483
|
4
|
+
data.tar.gz: 376b28cbee4e38ca2abe10591c0150e44145f156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df71a97b7d1ba6320557ca14a5e7d0d94bec48c62e8e064fb9c62b4507c10eea52308bbc5965fac9b11d7ca9f8d3afcb736ae642b41d15cf7c20378907ae8e31
|
7
|
+
data.tar.gz: 61c053e4f2f1854ad40d9303bce379910e0afef3744aabeffa1551314ab2aad23a601b995fc583f99f4c613b812cacdfcb9c54d53f38a41d6ce014d3219739eb
|
data/features/history.feature
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
@javascript
|
2
2
|
Feature: History
|
3
3
|
As an editor
|
4
|
-
I want to be able to browse through the history and save an old version as
|
4
|
+
I want to be able to browse through the history and save an old version as
|
5
|
+
current.
|
5
6
|
|
6
7
|
Background:
|
7
8
|
Given I am signed in as Joe Admin
|
@@ -9,14 +10,16 @@ Feature: History
|
|
9
10
|
|
10
11
|
Scenario: view history and rollback
|
11
12
|
When I go to url "/First?view=history"
|
12
|
-
Then In the main card content I should see a del with content "egg"
|
13
|
+
# Then In the main card content I should see a del with content "egg"
|
13
14
|
|
14
15
|
When I expand act 2
|
15
|
-
And In the main card content I click "Hide changes"
|
16
|
-
Then In the main card content I should not see a del with content "egg"
|
16
|
+
# And In the main card content I click "Hide changes"
|
17
|
+
# Then In the main card content I should not see a del with content "egg"
|
18
|
+
When In the main card body I click "Save as current"
|
19
|
+
And I wait until ajax response
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
Then
|
21
|
+
Then In the main card content I should see "chicken"
|
22
|
+
|
23
|
+
#Then the card First should contain "chicken"
|
21
24
|
|
22
25
|
|
data/features/paging.feature
CHANGED
@@ -6,7 +6,7 @@ Feature: paging
|
|
6
6
|
|
7
7
|
Background:
|
8
8
|
Given I am signed in as Joe Admin
|
9
|
-
And I create Search card "basic card search" with content "{\"type\":\"basic\"
|
9
|
+
And I create Search card "basic card search" with content "{\"type\":\"basic\"}"
|
10
10
|
|
11
11
|
Scenario: jump to pages should keep the item structure
|
12
12
|
When I create HTML card "basic item structure" with content "{{_|name}}"
|
@@ -357,7 +357,7 @@ Then /^"([^"]*)" should be selected for "([^"]*)"$/ do |value, field|
|
|
357
357
|
end
|
358
358
|
|
359
359
|
Then /^"([^"]*)" should be signed in$/ do |user| # "
|
360
|
-
has_css?("
|
360
|
+
has_css?(".my-card-link", text: user)
|
361
361
|
end
|
362
362
|
|
363
363
|
When /^I press enter to search$/ do
|
@@ -3,12 +3,14 @@
|
|
3
3
|
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
4
4
|
# It is recommended to regenerate this file in the future when you upgrade to a
|
5
5
|
# newer version of cucumber-rails. Consider adding your own code to a new file
|
6
|
-
# instead of editing this one. Cucumber will automatically load all
|
7
|
-
# files.
|
6
|
+
# instead of editing this one. Cucumber will automatically load all
|
7
|
+
# features/**/*.rb files.
|
8
8
|
|
9
9
|
require "uri"
|
10
10
|
require "cgi"
|
11
|
-
require File.expand_path(
|
11
|
+
require File.expand_path(
|
12
|
+
File.join(File.dirname(__FILE__), "..", "support", "paths")
|
13
|
+
)
|
12
14
|
|
13
15
|
# Commonly used webrat steps
|
14
16
|
# http://github.com/brynary/webrat
|
@@ -29,6 +31,10 @@ When /^(?:|I )follow "([^"]*)"$/ do |link|
|
|
29
31
|
click_link(link)
|
30
32
|
end
|
31
33
|
|
34
|
+
When /^(?:|I )click on "([^"]*)"$/ do |link|
|
35
|
+
click_link_or_button(link)
|
36
|
+
end
|
37
|
+
|
32
38
|
When /^(?:|I )follow "([^"]*)" within "([^"]*)"$/ do |link, parent|
|
33
39
|
click_link_within(parent, link)
|
34
40
|
end
|
@@ -45,6 +51,11 @@ When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
|
45
51
|
select(value, from: field)
|
46
52
|
end
|
47
53
|
|
54
|
+
When /^(?:|I )single-select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
55
|
+
find("label", text: field).parent.find("a.chosen-single").click
|
56
|
+
find("li", text: value).click
|
57
|
+
end
|
58
|
+
|
48
59
|
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
49
60
|
# When I select "December 25, 2008 10:00" as the date and time
|
50
61
|
When /^(?:|I )select "([^"]*)" as the date and time$/ do |time|
|
@@ -66,8 +77,8 @@ end
|
|
66
77
|
|
67
78
|
# Use this step in conjunction with Rail's time_select helper. For example:
|
68
79
|
# When I select "2:20PM" as the time
|
69
|
-
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time.
|
70
|
-
# will convert the 2:20PM to 14:20 and then select it.
|
80
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time.
|
81
|
+
# Webrat will convert the 2:20PM to 14:20 and then select it.
|
71
82
|
When /^(?:|I )select "([^"]*)" as the time$/ do |time|
|
72
83
|
select_time(time)
|
73
84
|
end
|
@@ -104,8 +115,9 @@ When /^(?:|I )choose "([^"]*)"$/ do |field|
|
|
104
115
|
choose(field)
|
105
116
|
end
|
106
117
|
|
107
|
-
# Adds support for validates_attachment_content_type.
|
108
|
-
# passed to attach_file() you will get a
|
118
|
+
# Adds support for validates_attachment_content_type.
|
119
|
+
# Without the mime-type getting passed to attach_file() you will get a
|
120
|
+
# "Photo file is not one of the allowed file types."
|
109
121
|
# error message
|
110
122
|
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
111
123
|
type = path.split(".")[1]
|
@@ -133,4 +145,5 @@ Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
|
133
145
|
end
|
134
146
|
|
135
147
|
Then /^show me the page$/ do
|
148
|
+
save_and_open_page
|
136
149
|
end
|
data/features/support/paths.rb
CHANGED
@@ -25,7 +25,9 @@ module NavigationHelpers
|
|
25
25
|
"/#{Regexp.last_match(1).to_name.url_key}"
|
26
26
|
|
27
27
|
when /new (.*) presetting name to "(.*)" and author to "(.*)"/
|
28
|
-
|
28
|
+
"/new/#{Regexp.last_match(1)}" \
|
29
|
+
"?card[name]=#{Regexp.last_match(2).to_name.url_key}" \
|
30
|
+
"&_author=#{CGI.escape(Regexp.last_match(3))}"
|
29
31
|
|
30
32
|
when /new card named (.*)$/
|
31
33
|
"/card/new?card[name]=#{CGI.escape(Regexp.last_match(1))}"
|
data/features/support/scopes.rb
CHANGED
@@ -21,6 +21,9 @@ module ScopeHelpers
|
|
21
21
|
when /main card frame/
|
22
22
|
"#main > .card-slot > .card-frame"
|
23
23
|
|
24
|
+
when /main card body/
|
25
|
+
"#main > .card-slot > .card-frame > .card-body"
|
26
|
+
|
24
27
|
else
|
25
28
|
raise "Can't find mapping from \"#{section}\" to a scope.\n" \
|
26
29
|
"Now, go and add a mapping in #{__FILE__}"
|
data/lib/wagn/commands.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
require "optparse"
|
2
|
-
|
3
1
|
# add method in? to Object class
|
4
2
|
require "active_support/core_ext/object/inclusion"
|
5
|
-
require "wagn/parser"
|
6
3
|
|
7
4
|
def load_rake_tasks
|
8
5
|
require "./config/environment"
|
@@ -12,6 +9,9 @@ end
|
|
12
9
|
|
13
10
|
RAILS_COMMANDS = %w( generate destroy plugin benchmarker profiler console
|
14
11
|
server dbconsole application runner ).freeze
|
12
|
+
WAGN_COMMANDS = %w(new cucumber rspec jasmine).freeze
|
13
|
+
WAGN_DB_COMMANDS = %w(seed reseed load update).freeze
|
14
|
+
|
15
15
|
ALIAS = {
|
16
16
|
"rs" => "rspec",
|
17
17
|
"cc" => "cucumber",
|
@@ -24,103 +24,66 @@ ALIAS = {
|
|
24
24
|
"r" => "runner"
|
25
25
|
}.freeze
|
26
26
|
|
27
|
-
ARGV << "--help" if ARGV.empty?
|
28
|
-
|
29
27
|
def supported_rails_command? arg
|
30
28
|
arg.in?(RAILS_COMMANDS) || ALIAS[arg].in?(RAILS_COMMANDS)
|
31
29
|
end
|
32
30
|
|
33
|
-
|
34
|
-
file, line = filename.split(":")
|
35
|
-
if file.include?("_spec.rb") && File.exist?(file)
|
36
|
-
filename
|
37
|
-
else
|
38
|
-
file = File.basename(file, ".rb").sub(/_spec$/, "")
|
39
|
-
Dir.glob("#{base_dir}/**/#{file}_spec.rb").flatten.map do |spec_file|
|
40
|
-
line ? "#{spec_file}:#{line}" : file
|
41
|
-
end.join(" ")
|
42
|
-
end
|
43
|
-
end
|
31
|
+
ARGV << "--help" if ARGV.empty?
|
44
32
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
33
|
+
module Wagn
|
34
|
+
module Commands
|
35
|
+
class << self
|
36
|
+
def run_new
|
37
|
+
if ARGV.first.in?(["-h", "--help"])
|
38
|
+
require "wagn/commands/application"
|
39
|
+
else
|
40
|
+
puts "Can't initialize a new deck within the directory of another, " \
|
41
|
+
"please change to a non-deck directory first.\n"
|
42
|
+
puts "Type 'wagn' for help."
|
43
|
+
exit(1)
|
44
|
+
end
|
45
|
+
end
|
49
46
|
|
50
|
-
|
47
|
+
def run_rspec
|
48
|
+
require "wagn/commands/rspec_command"
|
49
|
+
RspecCommand.new(ARGV).run
|
50
|
+
end
|
51
51
|
|
52
|
-
|
52
|
+
def run_cucumber
|
53
|
+
require "wagn/commands/cucumber_command"
|
54
|
+
CucumberCommand.new(ARGV).run
|
55
|
+
end
|
56
|
+
|
57
|
+
def run_db_task command
|
58
|
+
require "wagn/commands/rake_command"
|
59
|
+
RakeCommand.new("wagn:#{command}", ARGV).run
|
60
|
+
end
|
61
|
+
|
62
|
+
def run_jasmine
|
63
|
+
require "wagn/commands/rake_command"
|
64
|
+
RakeCommand.new("spec:javascript", envs: "test").run
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
command = ARGV.first
|
71
|
+
command = ALIAS[command] || command
|
72
|
+
if supported_rails_command? command
|
53
73
|
ENV["PRY_RESCUE_RAILS"] = "1" if ARGV.delete("--rescue")
|
54
|
-
command = ARGV.first
|
55
|
-
command = ALIAS[command] || command
|
56
74
|
|
57
75
|
# without this, the card generators don't list with: wagn g --help
|
58
76
|
require "generators/card" if command == "generate"
|
59
77
|
require "rails/commands"
|
60
78
|
else
|
61
|
-
|
62
|
-
command = ALIAS[command] || command
|
63
|
-
|
79
|
+
ARGV.shift
|
64
80
|
case command
|
65
|
-
when "cucumber"
|
66
|
-
require "wagn"
|
67
|
-
require "./config/environment"
|
68
|
-
feature_paths = Card::Mod::Loader.mod_dirs.map do |p|
|
69
|
-
Dir.glob "#{p}/features"
|
70
|
-
end.flatten
|
71
|
-
require_args = "-r #{Wagn.gem_root}/features "
|
72
|
-
require_args += feature_paths.map { |path| "-r #{path}" }.join(" ")
|
73
|
-
feature_args = ARGV.empty? ? feature_paths.join(" ") : ARGV.shelljoin
|
74
|
-
exit_with_child_status "RAILS_ROOT=. bundle exec cucumber " \
|
75
|
-
"#{require_args} #{feature_args}"
|
76
|
-
when "jasmine"
|
77
|
-
exit_with_child_status "RAILS_ENV=test bundle exec rake spec:javascript"
|
78
|
-
when "rspec"
|
79
|
-
require "rspec/core"
|
80
|
-
require "wagn/application"
|
81
|
-
|
82
|
-
before_split = true
|
83
|
-
wagn_args, rspec_args =
|
84
|
-
ARGV.partition do |a|
|
85
|
-
before_split = (a == "--" ? false : before_split)
|
86
|
-
end
|
87
|
-
rspec_args.shift
|
88
|
-
opts = {}
|
89
|
-
Wagn::Parser.rspec(opts).parse!(wagn_args)
|
90
|
-
# no coverage if rspec was started with file argument
|
91
|
-
if (opts[:files] || rspec_args.present?) && !opts[:simplecov]
|
92
|
-
opts[:simplecov] = "COVERAGE=false"
|
93
|
-
end
|
94
|
-
rspec_command =
|
95
|
-
"RAILS_ROOT=. #{opts[:simplecov]} #{opts[:executer]} " \
|
96
|
-
" #{opts[:rescue]} rspec #{rspec_args.shelljoin} #{opts[:files]} "\
|
97
|
-
" --exclude-pattern \"./card/vendor/**/*\""
|
98
|
-
exit_with_child_status rspec_command
|
99
81
|
when "--version", "-v"
|
100
82
|
puts "Wagn #{Card::Version.release}"
|
101
|
-
when
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
puts "Can't initialize a new deck within the directory of another, " \
|
106
|
-
"please change to a non-deck directory first.\n"
|
107
|
-
puts "Type 'wagn' for help."
|
108
|
-
exit(1)
|
109
|
-
end
|
110
|
-
when *WAGN_DB_TASKS
|
111
|
-
opts = {}
|
112
|
-
Wagn::Parser.db_task(command, opts).parse!(ARGV)
|
113
|
-
task_cmd = "bundle exec rake wagn:#{command}"
|
114
|
-
if !opts[:envs] || opts[:envs].empty?
|
115
|
-
puts task_cmd
|
116
|
-
puts `#{task_cmd}`
|
117
|
-
else
|
118
|
-
opts[:envs].each do |env|
|
119
|
-
puts "env RAILS_ENV=#{env} #{task_cmd}"
|
120
|
-
puts `env RAILS_ENV=#{env} #{task_cmd}`
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
83
|
+
when *WAGN_COMMANDS
|
84
|
+
Wagn::Commands.send("run_#{command}")
|
85
|
+
when *WAGN_DB_COMMANDS
|
86
|
+
Wagn::Commands.run_db_task command
|
124
87
|
else
|
125
88
|
puts "Error: Command not recognized" unless command.in?(["-h", "--help"])
|
126
89
|
puts <<-EOT
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Wagn
|
2
|
+
module Commands
|
3
|
+
class Command
|
4
|
+
def run
|
5
|
+
puts command
|
6
|
+
exit_with_child_status command
|
7
|
+
end
|
8
|
+
|
9
|
+
def exit_with_child_status command
|
10
|
+
command += " 2>&1"
|
11
|
+
exit $CHILD_STATUS.exitstatus unless system command
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path("../command", __FILE__)
|
2
|
+
|
3
|
+
module Wagn
|
4
|
+
module Commands
|
5
|
+
class CucumberCommand < Command
|
6
|
+
def initialize args
|
7
|
+
require "wagn"
|
8
|
+
require "./config/environment"
|
9
|
+
@args = args
|
10
|
+
end
|
11
|
+
|
12
|
+
def command
|
13
|
+
@cmd ||=
|
14
|
+
"#{env_args} bundle exec cucumber #{require_args} #{feature_args}"
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def env_args
|
20
|
+
env_args = "RAILS_ROOT=."
|
21
|
+
env_args << " COVERAGE=false" if @args.present?
|
22
|
+
env_args
|
23
|
+
end
|
24
|
+
|
25
|
+
def feature_args
|
26
|
+
@args.empty? ? feature_paths.join(" ") : @args.shelljoin
|
27
|
+
end
|
28
|
+
|
29
|
+
def require_args
|
30
|
+
"-r #{Wagn.gem_root}/features " +
|
31
|
+
feature_paths.map { |path| "-r #{path}" }.join(" ")
|
32
|
+
end
|
33
|
+
|
34
|
+
def feature_paths
|
35
|
+
Card::Mod::Loader.mod_dirs.map do |p|
|
36
|
+
Dir.glob "#{p}/features"
|
37
|
+
end.flatten
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path("../command", __FILE__)
|
2
|
+
|
3
|
+
module Wagn
|
4
|
+
module Commands
|
5
|
+
class RakeCommand < Command
|
6
|
+
def initialize rake_task, args={}
|
7
|
+
@task = rake_task
|
8
|
+
opts = {}
|
9
|
+
if args.is_a? Array
|
10
|
+
Parser.new(rake_task, opts).parse!(args)
|
11
|
+
else
|
12
|
+
opts = args
|
13
|
+
end
|
14
|
+
@envs = Array(opts[:envs])
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
command.each do |cmd|
|
19
|
+
puts cmd
|
20
|
+
puts `#{cmd}`
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def command
|
25
|
+
task_cmd = "bundle exec rake #{@task}"
|
26
|
+
return [task_cmd] if !@envs || @envs.empty?
|
27
|
+
@envs.map do |env|
|
28
|
+
"env RAILS_ENV=#{env} #{task_cmd}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
require File.expand_path("../rake_command/parser", __FILE__)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require "optparse"
|
3
|
+
|
4
|
+
module Wagn
|
5
|
+
module Commands
|
6
|
+
class RakeCommand
|
7
|
+
class Parser < OptionParser
|
8
|
+
def initialize command, opts
|
9
|
+
super() do |parser|
|
10
|
+
parser.banner = "Usage: wagn #{command} [options]\n\n" \
|
11
|
+
"Run wagn:#{command} task on the production "\
|
12
|
+
" database specified in config/database.yml\n\n"
|
13
|
+
parser.on("--production", "-p",
|
14
|
+
"#{command} production database (default)") do
|
15
|
+
opts[:envs] = ["production"]
|
16
|
+
end
|
17
|
+
parser.on("--test", "-t",
|
18
|
+
"#{command} test database") do
|
19
|
+
opts[:envs] = ["test"]
|
20
|
+
end
|
21
|
+
parser.on("--development", "-d",
|
22
|
+
"#{command} development database") do
|
23
|
+
opts[:envs] = ["development"]
|
24
|
+
end
|
25
|
+
parser.on("--all", "-a",
|
26
|
+
"#{command} production, test, and development database") do
|
27
|
+
opts[:envs] = %w(production development test)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path("../command", __FILE__)
|
2
|
+
|
3
|
+
module Wagn
|
4
|
+
module Commands
|
5
|
+
class RspecCommand < Command
|
6
|
+
def initialize args
|
7
|
+
require "rspec/core"
|
8
|
+
require "wagn/application"
|
9
|
+
|
10
|
+
@wagn_args, @rspec_args = split_wagn_and_rspec_args args
|
11
|
+
@opts = {}
|
12
|
+
Parser.new(@opts).parse!(@wagn_args)
|
13
|
+
end
|
14
|
+
|
15
|
+
def command
|
16
|
+
"#{env_args} #{@opts[:executer]} " \
|
17
|
+
" #{@opts[:rescue]} rspec #{@rspec_args.shelljoin} #{@opts[:files]} "\
|
18
|
+
" --exclude-pattern \"./card/vendor/**/*\""
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def env_args
|
24
|
+
["RAILS_ROOT=.", coverage].compact.join " "
|
25
|
+
end
|
26
|
+
|
27
|
+
def coverage
|
28
|
+
# no coverage if rspec was started with file argument
|
29
|
+
if (@opts[:files] || @rspec_args.present?) && !@opts[:simplecov]
|
30
|
+
@opts[:simplecov] = "COVERAGE=false"
|
31
|
+
end
|
32
|
+
@opts[:simplecov]
|
33
|
+
end
|
34
|
+
|
35
|
+
def split_wagn_and_rspec_args args
|
36
|
+
before_split = true
|
37
|
+
wagn, rspec =
|
38
|
+
args.partition do |a|
|
39
|
+
before_split = (a == "--" ? false : before_split)
|
40
|
+
end
|
41
|
+
rspec.shift
|
42
|
+
[wagn, rspec]
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
require File.expand_path("../rspec_command/parser", __FILE__)
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require "optparse"
|
3
|
+
|
4
|
+
module Wagn
|
5
|
+
module Commands
|
6
|
+
class RspecCommand
|
7
|
+
class Parser < OptionParser
|
8
|
+
def initialize opts
|
9
|
+
super() do |parser|
|
10
|
+
parser.banner = "Usage: wagn rspec [WAGN ARGS] -- [RSPEC ARGS]\n\n" \
|
11
|
+
"RSPEC ARGS"
|
12
|
+
parser.separator <<-EOT
|
13
|
+
|
14
|
+
WAGN ARGS
|
15
|
+
|
16
|
+
You don't have to give a full path for FILENAME, the basename is enough
|
17
|
+
If FILENAME does not include '_spec' rspec searches for the
|
18
|
+
corresponding spec file.
|
19
|
+
The line number always referes to example in the (corresponding) spec
|
20
|
+
file.
|
21
|
+
|
22
|
+
EOT
|
23
|
+
|
24
|
+
parser.on("-d", "--spec FILENAME(:LINE)",
|
25
|
+
"Run spec for a Wagn deck file") do |file|
|
26
|
+
opts[:files] = find_spec_file(file, "#{Wagn.root}/mod")
|
27
|
+
end
|
28
|
+
parser.on("-c", "--core-spec FILENAME(:LINE)",
|
29
|
+
"Run spec for a Wagn core file") do |file|
|
30
|
+
opts[:files] = find_spec_file(file, Cardio.gem_root)
|
31
|
+
end
|
32
|
+
parser.on("-m", "--mod MODNAME",
|
33
|
+
"Run all specs for a mod or matching a mod") do |file|
|
34
|
+
opts[:files] =
|
35
|
+
if File.exist?("mod/#{file}")
|
36
|
+
"#{Cardio.gem_root}/mod/#{file}"
|
37
|
+
elsif File.exist?("#{Cardio.gem_root}/mod/#{file}")
|
38
|
+
"#{Cardio.gem_root}/mod/#{file}"
|
39
|
+
elsif (files = find_spec_file(file, "mod")) && files.present?
|
40
|
+
files
|
41
|
+
else
|
42
|
+
find_spec_file(file, "#{Cardio.gem_root}/mod")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
parser.on("-s", "--[no-]simplecov", "Run with simplecov") do |s|
|
46
|
+
opts[:simplecov] = s ? "" : "COVERAGE=false"
|
47
|
+
end
|
48
|
+
parser.on("--rescue", "Run with pry-rescue") do
|
49
|
+
if opts[:executer] == "spring"
|
50
|
+
puts "Disabled pry-rescue. Not compatible with spring."
|
51
|
+
else
|
52
|
+
opts[:rescue] = "rescue "
|
53
|
+
end
|
54
|
+
end
|
55
|
+
parser.on("--[no-]spring", "Run with spring") do |spring|
|
56
|
+
if spring
|
57
|
+
opts[:executer] = "spring"
|
58
|
+
if opts[:rescue]
|
59
|
+
opts[:rescue] = ""
|
60
|
+
puts "Disabled pry-rescue. Not compatible with spring."
|
61
|
+
end
|
62
|
+
else
|
63
|
+
opts[:executer] = "bundle exec"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
parser.separator "\n"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def find_spec_file filename, base_dir
|
71
|
+
file, line = filename.split(":")
|
72
|
+
if file.include?("_spec.rb") && File.exist?(file)
|
73
|
+
filename
|
74
|
+
else
|
75
|
+
file = File.basename(file, ".rb").sub(/_spec$/, "")
|
76
|
+
Dir.glob("#{base_dir}/**/#{file}_spec.rb").flatten.map do |spec_file|
|
77
|
+
line ? "#{spec_file}:#{line}" : file
|
78
|
+
end.join(" ")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -27,6 +27,8 @@ group :test do
|
|
27
27
|
gem 'rspec', '~> 3.4'
|
28
28
|
gem 'rspec-rails' # behavior-driven-development suite
|
29
29
|
gem 'spork', '>=0.9'
|
30
|
+
gem 'rubocop'
|
31
|
+
gem 'rubocop-decko'
|
30
32
|
end
|
31
33
|
|
32
34
|
group :test, :development do
|
@@ -111,7 +113,7 @@ end
|
|
111
113
|
gem 'ruby-prof', :group=>:profile # profiling
|
112
114
|
|
113
115
|
group :debug do
|
114
|
-
gem 'better_errors'
|
116
|
+
gem 'better_errors'
|
115
117
|
gem 'binding_of_caller'
|
116
118
|
end
|
117
119
|
<% end %>
|
data/lib/wagn/tasks/wagn.rake
CHANGED
@@ -6,27 +6,6 @@ WAGN_SEED_PATH = File.join(
|
|
6
6
|
ENV["DECKO_SEED_REPO_PATH"] || [Cardio.gem_root, "db", "seed"], "new"
|
7
7
|
)
|
8
8
|
|
9
|
-
def run_card_migration core_or_deck
|
10
|
-
prepare_migration
|
11
|
-
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
12
|
-
Cardio.schema_mode(core_or_deck) do |paths|
|
13
|
-
ActiveRecord::Migrator.migrations_paths = paths
|
14
|
-
ActiveRecord::Migration.verbose = verbose
|
15
|
-
ActiveRecord::Migrator.migrate paths, version
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def prepare_migration
|
20
|
-
Card::Cache.reset_all
|
21
|
-
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
22
|
-
Card::Cache.reset_all
|
23
|
-
Card.config.action_mailer.perform_deliveries = false
|
24
|
-
Card.reset_column_information
|
25
|
-
# this is needed in production mode to insure core db
|
26
|
-
Card::Reference.reset_column_information
|
27
|
-
# structures are loaded before schema_mode is set
|
28
|
-
end
|
29
|
-
|
30
9
|
namespace :wagn do
|
31
10
|
desc "create a wagn database from scratch, load initial data"
|
32
11
|
task :seed do
|
@@ -155,61 +134,6 @@ namespace :wagn do
|
|
155
134
|
Cardio.assume_migrated_upto_version :core_cards
|
156
135
|
end
|
157
136
|
|
158
|
-
namespace :migrate do
|
159
|
-
desc "migrate cards"
|
160
|
-
task cards: [:core_cards, :deck_cards]
|
161
|
-
|
162
|
-
desc "migrate structure"
|
163
|
-
task structure: :environment do
|
164
|
-
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
165
|
-
Cardio.schema_mode(:structure) do |paths|
|
166
|
-
ActiveRecord::Migrator.migrations_paths = paths
|
167
|
-
ActiveRecord::Migrator.migrate paths, version
|
168
|
-
Rake::Task["db:_dump"].invoke # write schema.rb
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
desc "migrate core cards"
|
173
|
-
task core_cards: :environment do
|
174
|
-
require "card/migration/core"
|
175
|
-
run_card_migration :core_cards
|
176
|
-
end
|
177
|
-
|
178
|
-
desc "migrate deck cards"
|
179
|
-
task deck_cards: :environment do
|
180
|
-
require "card/migration"
|
181
|
-
run_card_migration :deck_cards
|
182
|
-
end
|
183
|
-
|
184
|
-
desc 'Redo the deck cards migration given by VERSION.'
|
185
|
-
task redo: :environment do
|
186
|
-
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
187
|
-
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
188
|
-
raise "VERSION is required" unless version
|
189
|
-
ActiveRecord::Migration.verbose = verbose
|
190
|
-
ActiveRecord::SchemaMigration.where(:version => version.to_s).delete_all
|
191
|
-
ActiveRecord::Migrator.run :up, Cardio.migration_paths(:deck_cards),
|
192
|
-
version
|
193
|
-
end
|
194
|
-
|
195
|
-
# maybe we should move this to a method?
|
196
|
-
desc "write the version to a file (not usually called directly)"
|
197
|
-
task :stamp, :type do |_t, args|
|
198
|
-
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
199
|
-
Cardio.config.action_mailer.perform_deliveries = false
|
200
|
-
|
201
|
-
stamp_file = Cardio.schema_stamp_path(args[:type])
|
202
|
-
|
203
|
-
Cardio.schema_mode args[:type] do
|
204
|
-
version = ActiveRecord::Migrator.current_version
|
205
|
-
if version.to_i > 0 && (file = open(stamp_file, "w"))
|
206
|
-
puts ">> writing version: #{version} to #{stamp_file}"
|
207
|
-
file.puts version
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
137
|
namespace :emergency do
|
214
138
|
task rescue_watchers: :environment do
|
215
139
|
follower_hash = Hash.new { |h, v| h[v] = [] }
|
@@ -238,126 +162,6 @@ namespace :wagn do
|
|
238
162
|
end
|
239
163
|
end
|
240
164
|
end
|
241
|
-
|
242
|
-
namespace :bootstrap do
|
243
|
-
desc "rid template of unneeded cards, acts, actions, changes, and references"
|
244
|
-
task clean: :environment do
|
245
|
-
Card::Cache.reset_all
|
246
|
-
clear_history
|
247
|
-
delete_unwanted_cards
|
248
|
-
Card.empty_trash
|
249
|
-
correct_time_and_user_stamps
|
250
|
-
Card::Cache.reset_all
|
251
|
-
end
|
252
|
-
|
253
|
-
desc "dump db to bootstrap fixtures"
|
254
|
-
task dump: :environment do
|
255
|
-
Card::Cache.reset_all
|
256
|
-
|
257
|
-
# FIXME: temporarily taking this out!!
|
258
|
-
Rake::Task["wagn:bootstrap:copy_mod_files"].invoke
|
259
|
-
Card[:all, :script].make_machine_output_coded
|
260
|
-
Card[:all, :style].make_machine_output_coded
|
261
|
-
Card[:script_html5shiv_printshiv].make_machine_output_coded
|
262
|
-
|
263
|
-
YAML::ENGINE.yamler = "syck" if RUBY_VERSION !~ /^(2|1\.9)/
|
264
|
-
# use old engine while we're supporting ruby 1.8.7 because it can't
|
265
|
-
# support Psych, which dumps with slashes that syck can't understand
|
266
|
-
|
267
|
-
WAGN_SEED_TABLES.each do |table|
|
268
|
-
i = "000"
|
269
|
-
File.open(File.join(WAGN_SEED_PATH, "#{table}.yml"), "w") do |file|
|
270
|
-
data = ActiveRecord::Base.connection.select_all(
|
271
|
-
"select * from #{table}"
|
272
|
-
)
|
273
|
-
file.write YAML.dump(data.each_with_object({}) do |record, hash|
|
274
|
-
record["trash"] = false if record.key? "trash"
|
275
|
-
record["draft"] = false if record.key? "draft"
|
276
|
-
if record.key? "content"
|
277
|
-
record["content"] = record["content"].gsub(/\u00A0/, " ")
|
278
|
-
# sych was handling nonbreaking spaces oddly.
|
279
|
-
# would not be needed with psych.
|
280
|
-
end
|
281
|
-
hash["#{table}_#{i.succ!}"] = record
|
282
|
-
end)
|
283
|
-
end
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
desc "copy files from template database to standard mod and update cards"
|
288
|
-
task copy_mod_files: :environment do
|
289
|
-
source_files_dir = "#{Wagn.root}/files"
|
290
|
-
|
291
|
-
# mark mod files as mod files
|
292
|
-
Card::Auth.as_bot do
|
293
|
-
Card.search(type: %w(in Image File), ne: "").each do |card|
|
294
|
-
if card.coded? || card.codename == "new_file" ||
|
295
|
-
card.codename == "new_image"
|
296
|
-
puts "skipping #{card.name}: already in code"
|
297
|
-
next
|
298
|
-
else
|
299
|
-
puts "working on #{card.name}"
|
300
|
-
end
|
301
|
-
|
302
|
-
# make card a mod file card
|
303
|
-
mod_name = if (l = card.left) && l.type_id == Card::SkinID
|
304
|
-
"bootstrap"
|
305
|
-
else
|
306
|
-
"standard"
|
307
|
-
end
|
308
|
-
card.update_attributes! storage_type: :coded,
|
309
|
-
mod: mod_name,
|
310
|
-
empty_ok: true
|
311
|
-
end
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
desc "load bootstrap fixtures into db"
|
316
|
-
task load: :environment do
|
317
|
-
# FIXME: shouldn't we be more standard and use seed.rb for this code?
|
318
|
-
Rake.application.options.trace = true
|
319
|
-
puts "bootstrap load starting #{WAGN_SEED_PATH}"
|
320
|
-
Rake::Task["db:seed"].invoke
|
321
|
-
end
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
def correct_time_and_user_stamps
|
326
|
-
conn = ActiveRecord::Base.connection
|
327
|
-
who_and_when = [Card::WagnBotID, Time.now.utc.to_s(:db)]
|
328
|
-
card_sql = "update cards set creator_id=%1$s, created_at='%2$s', updater_id=%1$s, updated_at='%2$s'"
|
329
|
-
conn.update(card_sql % who_and_when)
|
330
|
-
conn.update("update card_acts set actor_id=%s, acted_at='%s'" % who_and_when)
|
331
|
-
end
|
332
|
-
|
333
|
-
def delete_unwanted_cards
|
334
|
-
Card::Auth.as_bot do
|
335
|
-
if (ignoramus = Card["*ignore"])
|
336
|
-
ignoramus.item_cards.each(&:delete!)
|
337
|
-
end
|
338
|
-
Card::Cache.reset_all
|
339
|
-
# FIXME: can this be associated with the machine module somehow?
|
340
|
-
%w(machine_input machine_output).each do |codename|
|
341
|
-
Card.search(right: { codename: codename }).each do |card|
|
342
|
-
FileUtils.rm_rf File.join("files", card.id.to_s), secure: true
|
343
|
-
card.delete!
|
344
|
-
end
|
345
|
-
end
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
def clear_history
|
350
|
-
Card::Action.delete_old
|
351
|
-
Card::Change.delete_actionless
|
352
|
-
|
353
|
-
conn = ActiveRecord::Base.connection
|
354
|
-
conn.execute("truncate card_acts")
|
355
|
-
conn.execute("truncate sessions")
|
356
|
-
act = Card::Act.create! actor_id: Card::WagnBotID,
|
357
|
-
card_id: Card::WagnBotID
|
358
|
-
Card::Action.find_each do |action|
|
359
|
-
action.update_attributes!(card_act_id: act.id)
|
360
|
-
end
|
361
165
|
end
|
362
166
|
|
363
167
|
def version
|
@@ -0,0 +1,121 @@
|
|
1
|
+
namespace :wagn do
|
2
|
+
namespace :bootstrap do
|
3
|
+
desc "rid template of unneeded cards, acts, actions, changes, " \
|
4
|
+
"and references"
|
5
|
+
task clean: :environment do
|
6
|
+
Card::Cache.reset_all
|
7
|
+
clear_history
|
8
|
+
delete_unwanted_cards
|
9
|
+
Card.empty_trash
|
10
|
+
correct_time_and_user_stamps
|
11
|
+
Card::Cache.reset_all
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "dump db to bootstrap fixtures"
|
15
|
+
task dump: :environment do
|
16
|
+
Card::Cache.reset_all
|
17
|
+
|
18
|
+
# FIXME: temporarily taking this out!!
|
19
|
+
Rake::Task["wagn:bootstrap:copy_mod_files"].invoke
|
20
|
+
Card[:all, :script].make_machine_output_coded
|
21
|
+
Card[:all, :style].make_machine_output_coded
|
22
|
+
Card[:script_html5shiv_printshiv].make_machine_output_coded
|
23
|
+
|
24
|
+
YAML::ENGINE.yamler = "syck" if RUBY_VERSION !~ /^(2|1\.9)/
|
25
|
+
# use old engine while we're supporting ruby 1.8.7 because it can't
|
26
|
+
# support Psych, which dumps with slashes that syck can't understand
|
27
|
+
|
28
|
+
WAGN_SEED_TABLES.each do |table|
|
29
|
+
i = "000"
|
30
|
+
File.open(File.join(WAGN_SEED_PATH, "#{table}.yml"), "w") do |file|
|
31
|
+
data = ActiveRecord::Base.connection.select_all(
|
32
|
+
"select * from #{table}"
|
33
|
+
)
|
34
|
+
file.write YAML.dump(data.each_with_object({}) do |record, hash|
|
35
|
+
record["trash"] = false if record.key? "trash"
|
36
|
+
record["draft"] = false if record.key? "draft"
|
37
|
+
if record.key? "content"
|
38
|
+
record["content"] = record["content"].gsub(/\u00A0/, " ")
|
39
|
+
# sych was handling nonbreaking spaces oddly.
|
40
|
+
# would not be needed with psych.
|
41
|
+
end
|
42
|
+
hash["#{table}_#{i.succ!}"] = record
|
43
|
+
end)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "copy files from template database to standard mod and update cards"
|
49
|
+
task copy_mod_files: :environment do
|
50
|
+
# mark mod files as mod files
|
51
|
+
Card::Auth.as_bot do
|
52
|
+
Card.search(type: %w(in Image File), ne: "").each do |card|
|
53
|
+
if card.coded? || card.codename == "new_file" ||
|
54
|
+
card.codename == "new_image"
|
55
|
+
puts "skipping #{card.name}: already in code"
|
56
|
+
next
|
57
|
+
else
|
58
|
+
puts "working on #{card.name}"
|
59
|
+
end
|
60
|
+
|
61
|
+
# make card a mod file card
|
62
|
+
mod_name = if (l = card.left) && l.type_id == Card::SkinID
|
63
|
+
"bootstrap"
|
64
|
+
else
|
65
|
+
"standard"
|
66
|
+
end
|
67
|
+
card.update_attributes! storage_type: :coded,
|
68
|
+
mod: mod_name,
|
69
|
+
empty_ok: true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "load bootstrap fixtures into db"
|
75
|
+
task load: :environment do
|
76
|
+
# FIXME: shouldn't we be more standard and use seed.rb for this code?
|
77
|
+
Rake.application.options.trace = true
|
78
|
+
puts "bootstrap load starting #{WAGN_SEED_PATH}"
|
79
|
+
Rake::Task["db:seed"].invoke
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def correct_time_and_user_stamps
|
85
|
+
conn = ActiveRecord::Base.connection
|
86
|
+
who_and_when = [Card::WagnBotID, Time.now.utc.to_s(:db)]
|
87
|
+
card_sql = "update cards set creator_id=%1$s, created_at='%2$s', " \
|
88
|
+
"updater_id=%1$s, updated_at='%2$s'"
|
89
|
+
conn.update(card_sql % who_and_when)
|
90
|
+
conn.update("update card_acts set actor_id=%s, acted_at='%s'" % who_and_when)
|
91
|
+
end
|
92
|
+
|
93
|
+
def delete_unwanted_cards
|
94
|
+
Card::Auth.as_bot do
|
95
|
+
if (ignoramus = Card["*ignore"])
|
96
|
+
ignoramus.item_cards.each(&:delete!)
|
97
|
+
end
|
98
|
+
Card::Cache.reset_all
|
99
|
+
# FIXME: can this be associated with the machine module somehow?
|
100
|
+
%w(machine_input machine_output).each do |codename|
|
101
|
+
Card.search(right: { codename: codename }).each do |card|
|
102
|
+
FileUtils.rm_rf File.join("files", card.id.to_s), secure: true
|
103
|
+
card.delete!
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def clear_history
|
110
|
+
Card::Action.delete_old
|
111
|
+
Card::Change.delete_actionless
|
112
|
+
|
113
|
+
conn = ActiveRecord::Base.connection
|
114
|
+
conn.execute("truncate card_acts")
|
115
|
+
conn.execute("truncate sessions")
|
116
|
+
act = Card::Act.create! actor_id: Card::WagnBotID,
|
117
|
+
card_id: Card::WagnBotID
|
118
|
+
Card::Action.find_each do |action|
|
119
|
+
action.update_attributes!(card_act_id: act.id)
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
def run_card_migration core_or_deck
|
2
|
+
prepare_migration
|
3
|
+
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
4
|
+
Cardio.schema_mode(core_or_deck) do |paths|
|
5
|
+
ActiveRecord::Migrator.migrations_paths = paths
|
6
|
+
ActiveRecord::Migration.verbose = verbose
|
7
|
+
ActiveRecord::Migrator.migrate paths, version
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def prepare_migration
|
12
|
+
Card::Cache.reset_all
|
13
|
+
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
14
|
+
Card::Cache.reset_all
|
15
|
+
Card.config.action_mailer.perform_deliveries = false
|
16
|
+
Card.reset_column_information
|
17
|
+
# this is needed in production mode to insure core db
|
18
|
+
Card::Reference.reset_column_information
|
19
|
+
# structures are loaded before schema_mode is set
|
20
|
+
end
|
21
|
+
|
22
|
+
namespace :wagn do
|
23
|
+
namespace :migrate do
|
24
|
+
desc "migrate cards"
|
25
|
+
task cards: [:core_cards, :deck_cards]
|
26
|
+
|
27
|
+
desc "migrate structure"
|
28
|
+
task structure: :environment do
|
29
|
+
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
30
|
+
Cardio.schema_mode(:structure) do |paths|
|
31
|
+
ActiveRecord::Migrator.migrations_paths = paths
|
32
|
+
ActiveRecord::Migrator.migrate paths, version
|
33
|
+
Rake::Task["db:_dump"].invoke # write schema.rb
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "migrate core cards"
|
38
|
+
task core_cards: :environment do
|
39
|
+
require "card/migration/core"
|
40
|
+
run_card_migration :core_cards
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "migrate deck cards"
|
44
|
+
task deck_cards: :environment do
|
45
|
+
require "card/migration"
|
46
|
+
run_card_migration :deck_cards
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Redo the deck cards migration given by VERSION."
|
50
|
+
task redo: :environment do
|
51
|
+
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
52
|
+
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
53
|
+
raise "VERSION is required" unless version
|
54
|
+
ActiveRecord::Migration.verbose = verbose
|
55
|
+
ActiveRecord::SchemaMigration.where(version: version.to_s).delete_all
|
56
|
+
ActiveRecord::Migrator.run :up, Cardio.migration_paths(:deck_cards),
|
57
|
+
version
|
58
|
+
end
|
59
|
+
|
60
|
+
# maybe we should move this to a method?
|
61
|
+
desc "write the version to a file (not usually called directly)"
|
62
|
+
task :stamp, :type do |_t, args|
|
63
|
+
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
64
|
+
Cardio.config.action_mailer.perform_deliveries = false
|
65
|
+
|
66
|
+
stamp_file = Cardio.schema_stamp_path(args[:type])
|
67
|
+
|
68
|
+
Cardio.schema_mode args[:type] do
|
69
|
+
version = ActiveRecord::Migrator.current_version
|
70
|
+
if version.to_i > 0 && (file = open(stamp_file, "w"))
|
71
|
+
puts ">> writing version: #{version} to #{stamp_file}"
|
72
|
+
file.puts version
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -127,7 +127,6 @@ class CardController < ActionController::Base
|
|
127
127
|
rescue_from StandardError do |exception|
|
128
128
|
Rails.logger.info "exception = #{exception.class}: #{exception.message}"
|
129
129
|
@card ||= Card.new
|
130
|
-
Card::Error.current = exception
|
131
130
|
show Card::Error.exception_view(@card, exception)
|
132
131
|
end
|
133
132
|
end
|
data/rails/engine-routes.rb
CHANGED
@@ -4,9 +4,9 @@ Decko::Engine.routes.draw do
|
|
4
4
|
# most common
|
5
5
|
root "card#read"
|
6
6
|
get "#{Decko::Engine.config.files_web_path}/:id/:rev_id(-:size).:format" =>
|
7
|
-
|
7
|
+
"card#read", id: /[^-]+/, rev_id: /[^-]+/, explicit_file: true
|
8
8
|
get "#{Decko::Engine.config.files_web_path}/:id(-:size)-:rev_id.:format" =>
|
9
|
-
|
9
|
+
"card#read", id: /[^-]+/, explicit_file: true # deprecated
|
10
10
|
get "assets/*filename" => "card#asset"
|
11
11
|
get "javascripts/*filename" => "card#asset"
|
12
12
|
get "jasmine/*filename" => "card#asset"
|
@@ -9,7 +9,7 @@ describe CardController do
|
|
9
9
|
route_to opts.merge(controller: "card")
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "recognizes type" do
|
13
13
|
# all_routes = Rails.application.routes.routes
|
14
14
|
# require 'rails/application/route_inspector'
|
15
15
|
# warn "rountes#{ENV['CONTROLLER']}:\n" + Rails::Application::RouteInspector.new.format(all_routes, ENV['CONTROLLER'])* "\n"
|
@@ -18,12 +18,12 @@ describe CardController do
|
|
18
18
|
.to card_route_to(action: "read", type: "Phrase", view: "new")
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
21
|
+
it "recognizes .rss on /recent" do
|
22
22
|
expect(get: "/recent.rss")
|
23
23
|
.to card_route_to(action: "read", id: ":recent", format: "rss")
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "handles RESTful posts" do
|
27
27
|
expect(put: "/mycard").to card_route_to(action: "update", id: "mycard")
|
28
28
|
expect(put: "/").to card_route_to(action: "update")
|
29
29
|
end
|
@@ -35,17 +35,17 @@ describe CardController do
|
|
35
35
|
|
36
36
|
["/wagn", ""].each do |prefix|
|
37
37
|
describe "routes prefixed with '#{prefix}'" do
|
38
|
-
it "
|
38
|
+
it "recognizes .rss format" do
|
39
39
|
expect(get: "#{prefix}/*recent.rss")
|
40
40
|
.to card_route_to(action: "read", id: "*recent", format: "rss")
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
43
|
+
it "recognizes .xml format" do
|
44
44
|
expect(get: "#{prefix}/*recent.xml")
|
45
45
|
.to card_route_to(action: "read", id: "*recent", format: "xml")
|
46
46
|
end
|
47
47
|
|
48
|
-
it "
|
48
|
+
it "accepts cards without dots" do
|
49
49
|
expect(get: "#{prefix}/random")
|
50
50
|
.to card_route_to(action: "read", id: "random")
|
51
51
|
end
|
@@ -207,7 +207,7 @@ describe CardController do
|
|
207
207
|
login_as "joe_user"
|
208
208
|
end
|
209
209
|
|
210
|
-
it "
|
210
|
+
it "works on index" do
|
211
211
|
get :read, view: "new"
|
212
212
|
expect(assigns["card"].name).to eq("")
|
213
213
|
assert_response :success, "response should succeed"
|
@@ -241,7 +241,7 @@ describe CardController do
|
|
241
241
|
assert_response :success
|
242
242
|
end
|
243
243
|
|
244
|
-
it "
|
244
|
+
it "uses card params name over id in new cards" do
|
245
245
|
get :read, id: "my_life", card: { name: "My LIFE" }, view: "new"
|
246
246
|
expect(assigns["card"].name).to eq("My LIFE")
|
247
247
|
end
|
@@ -276,9 +276,9 @@ describe CardController do
|
|
276
276
|
|
277
277
|
it "handles image with no read permission" do
|
278
278
|
get :read, id: "mao2"
|
279
|
-
assert_response 403, "
|
279
|
+
assert_response 403, "denies html card view"
|
280
280
|
get :read, id: "mao2", format: "jpg"
|
281
|
-
assert_response 403, "
|
281
|
+
assert_response 403, "denies simple file view"
|
282
282
|
end
|
283
283
|
|
284
284
|
it "handles image with read permission" do
|
@@ -373,7 +373,7 @@ describe CardController do
|
|
373
373
|
end
|
374
374
|
end
|
375
375
|
|
376
|
-
it "
|
376
|
+
it "comments" do
|
377
377
|
Card::Auth.as_bot do
|
378
378
|
Card.create name: "basicname+*self+*comment",
|
379
379
|
content: "[[Anyone Signed In]]"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wagn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2017-01-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -33,14 +33,14 @@ dependencies:
|
|
33
33
|
requirements:
|
34
34
|
- - '='
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.
|
36
|
+
version: 1.20.0
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - '='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.
|
43
|
+
version: 1.20.0
|
44
44
|
description: a wiki approach to stuctured data, dynamic interaction, and web design
|
45
45
|
email:
|
46
46
|
- info@wagn.org
|
@@ -112,6 +112,12 @@ files:
|
|
112
112
|
- lib/wagn/cli.rb
|
113
113
|
- lib/wagn/commands.rb
|
114
114
|
- lib/wagn/commands/application.rb
|
115
|
+
- lib/wagn/commands/command.rb
|
116
|
+
- lib/wagn/commands/cucumber_command.rb
|
117
|
+
- lib/wagn/commands/rake_command.rb
|
118
|
+
- lib/wagn/commands/rake_command/parser.rb
|
119
|
+
- lib/wagn/commands/rspec_command.rb
|
120
|
+
- lib/wagn/commands/rspec_command/parser.rb
|
115
121
|
- lib/wagn/config/environments/cucumber.rb
|
116
122
|
- lib/wagn/config/environments/development.rb
|
117
123
|
- lib/wagn/config/environments/production.rb
|
@@ -153,7 +159,6 @@ files:
|
|
153
159
|
- lib/wagn/generators/wagn/wagn_generator.rb
|
154
160
|
- lib/wagn/generators/wagn/wagn_generator/interactive.rb
|
155
161
|
- lib/wagn/mods_spec_helper.rb
|
156
|
-
- lib/wagn/parser.rb
|
157
162
|
- lib/wagn/response.rb
|
158
163
|
- lib/wagn/script_wagn_loader.rb
|
159
164
|
- lib/wagn/tasks/.gitkeep
|
@@ -161,6 +166,8 @@ files:
|
|
161
166
|
- lib/wagn/tasks/db.rake
|
162
167
|
- lib/wagn/tasks/test.rake
|
163
168
|
- lib/wagn/tasks/wagn.rake
|
169
|
+
- lib/wagn/tasks/wagn/bootstrap.rake
|
170
|
+
- lib/wagn/tasks/wagn/migrate.rake
|
164
171
|
- rails/application-routes.rb
|
165
172
|
- rails/assets/ace/ext-searchbox.js
|
166
173
|
- rails/assets/ace/mode-coffee.js
|
data/lib/wagn/parser.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
module Wagn
|
4
|
-
class Parser
|
5
|
-
class << self
|
6
|
-
def db_task command, opts
|
7
|
-
OptionParser.new do |parser|
|
8
|
-
parser.banner = "Usage: wagn #{command} [options]\n\n" \
|
9
|
-
"Run wagn:#{command} task on the production "\
|
10
|
-
" database specified in config/database.yml\n\n"
|
11
|
-
parser.on("--production", "-p",
|
12
|
-
"#{command} production database (default)") do
|
13
|
-
opts[:envs] = ["production"]
|
14
|
-
end
|
15
|
-
parser.on("--test", "-t",
|
16
|
-
"#{command} test database") do
|
17
|
-
opts[:envs] = ["test"]
|
18
|
-
end
|
19
|
-
parser.on("--development", "-d",
|
20
|
-
"#{command} development database") do
|
21
|
-
opts[:envs] = ["development"]
|
22
|
-
end
|
23
|
-
parser.on("--all", "-a",
|
24
|
-
"#{command} production, test, and development database") do
|
25
|
-
opts[:envs] = %w(production development test)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def rspec opts
|
31
|
-
OptionParser.new do |parser|
|
32
|
-
parser.banner = "Usage: wagn rspec [WAGN ARGS] -- [RSPEC ARGS]\n\n" \
|
33
|
-
"RSPEC ARGS"
|
34
|
-
parser.separator <<-WAGN
|
35
|
-
|
36
|
-
WAGN ARGS
|
37
|
-
|
38
|
-
You don't have to give a full path for FILENAME, the basename is enough
|
39
|
-
If FILENAME does not include '_spec' rspec searches for the
|
40
|
-
corresponding spec file.
|
41
|
-
The line number always referes to example in the (corresponding) spec
|
42
|
-
file.
|
43
|
-
|
44
|
-
WAGN
|
45
|
-
|
46
|
-
parser.on("-d", "--spec FILENAME(:LINE)",
|
47
|
-
"Run spec for a Wagn deck file") do |file|
|
48
|
-
opts[:files] = find_spec_file(file, "#{Wagn.root}/mod")
|
49
|
-
end
|
50
|
-
parser.on("-c", "--core-spec FILENAME(:LINE)",
|
51
|
-
"Run spec for a Wagn core file") do |file|
|
52
|
-
opts[:files] = find_spec_file(file, Cardio.gem_root)
|
53
|
-
end
|
54
|
-
parser.on("-m", "--mod MODNAME",
|
55
|
-
"Run all specs for a mod or matching a mod") do |file|
|
56
|
-
opts[:files] =
|
57
|
-
if File.exist?("mod/#{file}")
|
58
|
-
"#{Cardio.gem_root}/mod/#{file}"
|
59
|
-
elsif File.exist?("#{Cardio.gem_root}/mod/#{file}")
|
60
|
-
"#{Cardio.gem_root}/mod/#{file}"
|
61
|
-
elsif (files = find_spec_file(file, "mod")) && files.present?
|
62
|
-
files
|
63
|
-
else
|
64
|
-
find_spec_file(file, "#{Cardio.gem_root}/mod")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
parser.on("-s", "--[no-]simplecov", "Run with simplecov") do |s|
|
68
|
-
opts[:simplecov] = s ? "" : "COVERAGE=false"
|
69
|
-
end
|
70
|
-
parser.on("--rescue", "Run with pry-rescue") do
|
71
|
-
if opts[:executer] == "spring"
|
72
|
-
puts "Disabled pry-rescue. Not compatible with spring."
|
73
|
-
else
|
74
|
-
opts[:rescue] = "rescue "
|
75
|
-
end
|
76
|
-
end
|
77
|
-
parser.on("--[no-]spring", "Run with spring") do |spring|
|
78
|
-
if spring
|
79
|
-
opts[:executer] = "spring"
|
80
|
-
if opts[:rescue]
|
81
|
-
opts[:rescue] = ""
|
82
|
-
puts "Disabled pry-rescue. Not compatible with spring."
|
83
|
-
end
|
84
|
-
else
|
85
|
-
opts[:executer] = "bundle exec"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
parser.separator "\n"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|