decko 0.11.4 → 0.11.5
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/bin/decko +2 -2
- data/lib/card_controller.rb +25 -0
- data/{rails/controllers → lib}/card_controller/errors.rb +1 -0
- data/lib/card_controller/mark.rb +66 -0
- data/lib/{decko → card_controller}/response.rb +5 -55
- data/lib/card_controller/rest.rb +105 -0
- data/lib/decko.rb +1 -2
- data/lib/decko/application.rb +1 -0
- data/lib/decko/commands.rb +9 -9
- data/lib/decko/commands/application.rb +1 -1
- data/lib/decko/commands/cucumber_command.rb +2 -2
- data/lib/decko/commands/cucumber_command/parser.rb +28 -24
- data/lib/decko/commands/rake_command.rb +3 -2
- data/lib/decko/commands/rake_command/parser.rb +2 -1
- data/lib/decko/commands/rspec_command.rb +2 -2
- data/lib/decko/commands/rspec_command/parser.rb +1 -0
- data/lib/decko/config/environments/cucumber.rb +1 -0
- data/lib/decko/config/environments/development.rb +1 -1
- data/lib/decko/config/environments/production.rb +3 -1
- data/lib/decko/config/environments/profile.rb +1 -0
- data/lib/decko/config/environments/test.rb +1 -0
- data/lib/decko/config/initializers/secret_token.rb +1 -0
- data/lib/decko/config/initializers/sedate_parser.rb +3 -2
- data/lib/decko/engine.rb +0 -2
- data/lib/decko/generators/deck/deck_generator.rb +2 -1
- data/lib/decko/generators/deck/deck_generator/interactive.rb +4 -4
- data/lib/decko/script_decko_loader.rb +1 -0
- data/lib/decko/tasks/alias.rb +4 -5
- data/lib/decko/tasks/cucumber.rake +52 -44
- data/lib/decko/tasks/db.rake +9 -2
- data/lib/decko/tasks/decko.rake +6 -4
- data/lib/decko/tasks/decko/seed.rake +3 -0
- data/rails/engine-routes.rb +1 -1
- data/script/decko +2 -2
- data/script/rails +4 -4
- metadata +11 -11
- data/rails/controllers/application_controller.rb +0 -2
- data/rails/controllers/card_controller.rb +0 -122
- data/script/test_filter +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c726ee70f0d8daba2891b23aab64090c43d088cc3300290a52eddee922dc7d0
|
4
|
+
data.tar.gz: c3e610b82510c510d2dfb16ecd1c408fe0be17c7e0b1d1209ce92432d52513e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c18ed07879923d174cea1cc75a860406a5f6548dfbc56dfe4d27610ee64d29ce0df3cbfdd500362b2ce2780948d48f2e54aac487d437141e0b91c29a78d9935
|
7
|
+
data.tar.gz: a76d39182e7d95ac2192a4a90017dd337f07d786379379dc3a5166765a2f7241b3abc8b025ae8a7210aa0dd7431552dab7c1ce877acc4c394801d4cd410e2250
|
data/bin/decko
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
git_path = File.expand_path("
|
3
|
+
git_path = File.expand_path("../../.git", __dir__)
|
4
4
|
|
5
5
|
if File.exist?(git_path)
|
6
|
-
railties_path = File.expand_path("
|
6
|
+
railties_path = File.expand_path("../lib", __dir__)
|
7
7
|
$LOAD_PATH.unshift(railties_path)
|
8
8
|
end
|
9
9
|
require "decko/cli"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
# Decko's only controller.
|
4
|
+
class CardController < ActionController::Base
|
5
|
+
include Mark
|
6
|
+
include Rest
|
7
|
+
include Response
|
8
|
+
include Errors
|
9
|
+
|
10
|
+
# NOTE: including Card::Env::Location triggers card loading, which triggers mod loading,
|
11
|
+
# which can include initializers that add to the CardController class.
|
12
|
+
# It's important that it come *after* the modules above, so that mod modules
|
13
|
+
# can override them.
|
14
|
+
include ::Card::Env::Location
|
15
|
+
|
16
|
+
layout nil
|
17
|
+
attr_reader :card
|
18
|
+
|
19
|
+
before_action :setup, except: [:asset]
|
20
|
+
before_action :authenticate, except: [:asset]
|
21
|
+
before_action :load_mark, only: [:read]
|
22
|
+
before_action :load_card, except: [:asset]
|
23
|
+
before_action :load_action, only: [:read]
|
24
|
+
before_action :refresh_card, only: %i[create update delete]
|
25
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class CardController
|
2
|
+
# methods for interpretation of card marks requested
|
3
|
+
module Mark
|
4
|
+
private
|
5
|
+
|
6
|
+
def load_mark
|
7
|
+
params[:mark] = interpret_mark params[:mark]
|
8
|
+
end
|
9
|
+
|
10
|
+
def interpret_mark mark
|
11
|
+
case mark
|
12
|
+
when "*previous"
|
13
|
+
# Why support this? It's only needed in Success, right? Deprecate?
|
14
|
+
hard_redirect Card::Env.previous_location
|
15
|
+
when nil
|
16
|
+
implicit_mark
|
17
|
+
else
|
18
|
+
explicit_mark mark
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def explicit_mark mark
|
23
|
+
# we should find the place where we produce these bad urls
|
24
|
+
mark.valid_encoding? ? mark : mark.force_encoding("ISO-8859-1").encode("UTF-8")
|
25
|
+
end
|
26
|
+
|
27
|
+
def implicit_mark
|
28
|
+
case
|
29
|
+
when initial_setup
|
30
|
+
""
|
31
|
+
when (name = mark_from_card_hash)
|
32
|
+
name
|
33
|
+
when view_does_not_require_name?
|
34
|
+
""
|
35
|
+
else
|
36
|
+
home_mark
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def home_mark
|
41
|
+
Card::Rule.global_setting(:home) || "Home"
|
42
|
+
end
|
43
|
+
|
44
|
+
def view_does_not_require_name?
|
45
|
+
return false unless (view = params[:view]&.to_sym)
|
46
|
+
|
47
|
+
Card::Set::Format::AbstractFormat::ViewOpts.unknown_ok[view]
|
48
|
+
end
|
49
|
+
|
50
|
+
def mark_from_card_hash
|
51
|
+
params.dig :card, :name
|
52
|
+
end
|
53
|
+
|
54
|
+
# alters params
|
55
|
+
def initial_setup
|
56
|
+
return unless Card::Auth.needs_setup? && Card::Env.html?
|
57
|
+
|
58
|
+
prepare_setup_card!
|
59
|
+
end
|
60
|
+
|
61
|
+
def prepare_setup_card!
|
62
|
+
params[:card] = { type_id: Card.default_accounted_type_id }
|
63
|
+
params[:view] = "setup"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
class CardController
|
2
2
|
# methods for managing decko responses
|
3
3
|
module Response
|
4
4
|
def response_format
|
@@ -72,6 +72,7 @@ module Decko
|
|
72
72
|
|
73
73
|
def require_card_for_soft_redirect!
|
74
74
|
return if card.is_a? Card
|
75
|
+
|
75
76
|
raise Card::Error, "tried to do soft redirect without a card"
|
76
77
|
end
|
77
78
|
|
@@ -101,64 +102,13 @@ module Decko
|
|
101
102
|
end
|
102
103
|
|
103
104
|
def format_name_from_params
|
104
|
-
if explicit_file_format?
|
105
|
-
|
106
|
-
|
107
|
-
end
|
105
|
+
return :file if explicit_file_format?
|
106
|
+
|
107
|
+
(params[:format].present? ? params[:format] : request.format).to_sym
|
108
108
|
end
|
109
109
|
|
110
110
|
def explicit_file_format?
|
111
111
|
params[:explicit_file] || !Card::Format.registered.member?(request.format)
|
112
112
|
end
|
113
|
-
|
114
|
-
def interpret_mark mark
|
115
|
-
case mark
|
116
|
-
when "*previous"
|
117
|
-
# Why support this? It's only needed in Success, right? Deprecate?
|
118
|
-
return hard_redirect(Card::Env.previous_location)
|
119
|
-
when nil
|
120
|
-
implicit_mark
|
121
|
-
else
|
122
|
-
explicit_mark mark
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def explicit_mark mark
|
127
|
-
# we should find the place where we produce these bad urls
|
128
|
-
mark.valid_encoding? ? mark : mark.force_encoding("ISO-8859-1").encode("UTF-8")
|
129
|
-
end
|
130
|
-
|
131
|
-
def implicit_mark
|
132
|
-
case
|
133
|
-
when initial_setup then ""
|
134
|
-
when (name = params.dig :card, :name) then name
|
135
|
-
when view_does_not_require_name? then ""
|
136
|
-
else home_mark
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def home_mark
|
141
|
-
Card::Rule.global_setting(:home) || "Home"
|
142
|
-
end
|
143
|
-
|
144
|
-
def view_does_not_require_name?
|
145
|
-
return false unless (view = params[:view]&.to_sym)
|
146
|
-
Card::Set::Format::AbstractFormat::ViewOpts.unknown_ok[view]
|
147
|
-
end
|
148
|
-
|
149
|
-
# alters params
|
150
|
-
def initial_setup
|
151
|
-
return unless initial_setup?
|
152
|
-
prepare_setup_card!
|
153
|
-
end
|
154
|
-
|
155
|
-
def initial_setup?
|
156
|
-
Card::Auth.needs_setup? && Card::Env.html?
|
157
|
-
end
|
158
|
-
|
159
|
-
def prepare_setup_card!
|
160
|
-
params[:card] = { type_id: Card.default_accounted_type_id }
|
161
|
-
params[:view] = "setup"
|
162
|
-
end
|
163
113
|
end
|
164
114
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
class CardController
|
2
|
+
# RESTful action methods for card
|
3
|
+
module Rest
|
4
|
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
# PUBLIC METHODS
|
6
|
+
|
7
|
+
def create
|
8
|
+
handle { card.save! }
|
9
|
+
end
|
10
|
+
|
11
|
+
def read
|
12
|
+
show
|
13
|
+
end
|
14
|
+
|
15
|
+
def update
|
16
|
+
card.new_card? ? create : handle { card.update! params[:card]&.to_unsafe_h }
|
17
|
+
end
|
18
|
+
|
19
|
+
def delete
|
20
|
+
handle { card.delete! }
|
21
|
+
end
|
22
|
+
|
23
|
+
# @deprecated
|
24
|
+
def asset
|
25
|
+
body = "Decko installation error: missing asset symlinks"
|
26
|
+
Rails.logger.info "#{body}.\n >>> Try `rake decko:update_assets_symlink`"
|
27
|
+
render body: body, status: 404
|
28
|
+
end
|
29
|
+
|
30
|
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
31
|
+
# PRIVATE METHODS
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def setup
|
36
|
+
Card::Machine.refresh_script_and_style unless params[:explicit_file]
|
37
|
+
Card::Cache.renew
|
38
|
+
Card::Env.reset controller: self
|
39
|
+
end
|
40
|
+
|
41
|
+
def authenticate
|
42
|
+
Card::Auth.signin_with params
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_card
|
46
|
+
@card = Card.uri_fetch params
|
47
|
+
raise Card::Error::NotFound unless card
|
48
|
+
|
49
|
+
record_as_main
|
50
|
+
end
|
51
|
+
|
52
|
+
def load_action
|
53
|
+
card.select_action_by_params params
|
54
|
+
return unless params[:edit_draft] && card.drafts.present?
|
55
|
+
|
56
|
+
card.content = card.last_draft_content
|
57
|
+
end
|
58
|
+
|
59
|
+
# TODO: refactor this away this when new layout handling is ready
|
60
|
+
def record_as_main
|
61
|
+
Card::Env[:main_name] = params[:main] || card&.name || ""
|
62
|
+
end
|
63
|
+
|
64
|
+
def refresh_card
|
65
|
+
@card = card.refresh
|
66
|
+
end
|
67
|
+
|
68
|
+
# ----------( HELPER METHODS ) -------------
|
69
|
+
|
70
|
+
def handle
|
71
|
+
Card::Env.success card.name
|
72
|
+
yield ? cud_success : raise(Card::Error::UserError)
|
73
|
+
end
|
74
|
+
|
75
|
+
# successful create, update, or delete act
|
76
|
+
def cud_success
|
77
|
+
success = Card::Env.success.in_context card.name
|
78
|
+
if success.reload?
|
79
|
+
reload # instruct JSON to reload
|
80
|
+
else
|
81
|
+
redirect_cud_success success
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def show view=nil, status=200
|
86
|
+
card.action = :read
|
87
|
+
format = load_format status
|
88
|
+
result = render_page format, view
|
89
|
+
status = format.error_status || status
|
90
|
+
respond format, result, status
|
91
|
+
end
|
92
|
+
|
93
|
+
def render_page format, view
|
94
|
+
view ||= view_from_params
|
95
|
+
card.act do
|
96
|
+
format.page self, view, Card::Env.slot_opts
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def view_from_params
|
101
|
+
%i[view v].each { |k| return params[k] if params[k].present? }
|
102
|
+
nil
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/decko.rb
CHANGED
data/lib/decko/application.rb
CHANGED
data/lib/decko/commands.rb
CHANGED
@@ -7,21 +7,21 @@ def load_rake_tasks
|
|
7
7
|
Decko::Application.load_tasks
|
8
8
|
end
|
9
9
|
|
10
|
-
RAILS_COMMANDS = %w
|
11
|
-
server dbconsole application runner
|
12
|
-
DECKO_COMMANDS = %w
|
13
|
-
DECKO_DB_COMMANDS = %w
|
10
|
+
RAILS_COMMANDS = %w[ generate destroy plugin benchmarker profiler console
|
11
|
+
server dbconsole application runner ].freeze
|
12
|
+
DECKO_COMMANDS = %w[new cucumber rspec jasmine].freeze
|
13
|
+
DECKO_DB_COMMANDS = %w[seed reseed load update].freeze
|
14
14
|
|
15
15
|
ALIAS = {
|
16
16
|
"rs" => "rspec",
|
17
17
|
"cc" => "cucumber",
|
18
18
|
"jm" => "jasmine",
|
19
|
-
"g"
|
20
|
-
"d"
|
21
|
-
"c"
|
22
|
-
"s"
|
19
|
+
"g" => "generate",
|
20
|
+
"d" => "destroy",
|
21
|
+
"c" => "console",
|
22
|
+
"s" => "server",
|
23
23
|
"db" => "dbconsole",
|
24
|
-
"r"
|
24
|
+
"r" => "runner"
|
25
25
|
}.freeze
|
26
26
|
|
27
27
|
def supported_rails_command? arg
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path("
|
1
|
+
require File.expand_path("command", __dir__)
|
2
2
|
|
3
3
|
module Decko
|
4
4
|
module Commands
|
@@ -45,4 +45,4 @@ module Decko
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
require File.expand_path("
|
48
|
+
require File.expand_path("cucumber_command/parser", __dir__)
|
@@ -1,38 +1,42 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
|
2
3
|
require "optparse"
|
3
4
|
|
4
5
|
module Decko
|
5
6
|
module Commands
|
6
7
|
class CucumberCommand
|
7
8
|
class Parser < OptionParser
|
9
|
+
class Flagger
|
10
|
+
def initialize parser, opts
|
11
|
+
@parser = parser
|
12
|
+
@opts = opts
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_flags
|
16
|
+
add_flag "DEBUG", "-d", "--debug", "Drop into debugger on failure"
|
17
|
+
add_flag "FAST", "-f", "--fast", "Stop on first failure"
|
18
|
+
add_flag "LAUNCH", "-l", "--launchy", "Open page on failure"
|
19
|
+
add_flag "STEP", "-s", "--step", "Pause after each step"
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_flag flag, *args
|
23
|
+
@parser.on(*args) { |a| @opts[:env] << "#{flag}=1" if a }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_spring parser, opts
|
28
|
+
parser.on("--[no-]spring", "Run with spring") do |spring|
|
29
|
+
opts[:executer] = spring ? "spring" : "bundle exec"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
8
33
|
def initialize opts
|
9
34
|
super() do |parser|
|
10
35
|
parser.banner = "Usage: decko cucumber [DECKO ARGS] -- [CUCUMBER ARGS]\n\n"
|
11
|
-
parser.separator
|
12
|
-
|
13
|
-
DECKO ARGS
|
14
|
-
EOT
|
36
|
+
parser.separator "\nDECKO ARGS"
|
15
37
|
opts[:env] = ["RAILS_ROOT=."]
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
parser.on("-f", "--fast", "Stop on first failure") do |a|
|
20
|
-
opts[:env] << "FAST=1" if a
|
21
|
-
end
|
22
|
-
parser.on("-l", "--launchy", "Open page on failure") do |a|
|
23
|
-
opts[:env] << "LAUNCHY=1" if a
|
24
|
-
end
|
25
|
-
parser.on("-s", "--step", "Pause after each step") do |a|
|
26
|
-
opts[:env] << "STEP=1" if a
|
27
|
-
end
|
28
|
-
parser.on("--[no-]spring", "Run with spring") do |spring|
|
29
|
-
opts[:executer] =
|
30
|
-
if spring
|
31
|
-
"spring"
|
32
|
-
else
|
33
|
-
"bundle exec"
|
34
|
-
end
|
35
|
-
end
|
38
|
+
Flagger.new(parser, opts).add_flags
|
39
|
+
parse_spring parser, opts
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path("
|
1
|
+
require File.expand_path("command", __dir__)
|
2
2
|
# require "pry"
|
3
3
|
|
4
4
|
module Decko
|
@@ -30,6 +30,7 @@ module Decko
|
|
30
30
|
def commands
|
31
31
|
task_cmd = "bundle exec rake #{@task}"
|
32
32
|
return [task_cmd] if !@envs || @envs.empty?
|
33
|
+
|
33
34
|
@envs.map do |env|
|
34
35
|
"env RAILS_ENV=#{env} #{task_cmd}"
|
35
36
|
end
|
@@ -38,4 +39,4 @@ module Decko
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
|
-
require File.expand_path("
|
42
|
+
require File.expand_path("rake_command/parser", __dir__)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
|
2
3
|
require "optparse"
|
3
4
|
|
4
5
|
module Decko
|
@@ -24,7 +25,7 @@ module Decko
|
|
24
25
|
end
|
25
26
|
parser.on("--all", "-a",
|
26
27
|
"#{command} production, test, and development database") do
|
27
|
-
opts[:envs] = %w
|
28
|
+
opts[:envs] = %w[production development test]
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path("
|
1
|
+
require File.expand_path("command", __dir__)
|
2
2
|
|
3
3
|
module Decko
|
4
4
|
module Commands
|
@@ -33,4 +33,4 @@ module Decko
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
require File.expand_path("
|
36
|
+
require File.expand_path("rspec_command/parser", __dir__)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
|
2
3
|
Decko.application.class.configure do
|
3
4
|
# Settings specified here will take precedence over those in config/application.rb
|
4
5
|
|
@@ -50,7 +51,8 @@ Decko.application.class.configure do
|
|
50
51
|
# config.action_controller.asset_host = "http://assets.example.com"
|
51
52
|
|
52
53
|
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
53
|
-
config.assets.precompile += %w
|
54
|
+
config.assets.precompile += %w[application-all.css application-print.css barebones.css
|
55
|
+
html5shiv-printshiv.js]
|
54
56
|
|
55
57
|
# Disable delivery errors, bad email addresses will be ignored
|
56
58
|
# config.action_mailer.raise_delivery_errors = false
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# Hack to get rid of annoying parser warnings
|
2
2
|
module Parser
|
3
3
|
def self.warn msg
|
4
|
-
|
5
|
-
|
4
|
+
super unless msg.match?(
|
5
|
+
%r{^warning: (?:parser/current|[\d.]+-compliant syntax|please see)}
|
6
|
+
)
|
6
7
|
end
|
7
8
|
end
|
data/lib/decko/engine.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
require "rails/all"
|
3
2
|
require "cardio"
|
4
3
|
|
@@ -15,7 +14,6 @@ require "decko"
|
|
15
14
|
|
16
15
|
module Decko
|
17
16
|
class Engine < ::Rails::Engine
|
18
|
-
paths.add "app/controllers", with: "rails/controllers", eager_load: true
|
19
17
|
paths.add "gem-assets", with: "rails/assets"
|
20
18
|
paths.add "config/routes.rb", with: "rails/engine-routes.rb"
|
21
19
|
paths.add "lib/tasks", with: "#{::Decko.gem_root}/lib/decko/tasks",
|
@@ -11,7 +11,7 @@ module Decko
|
|
11
11
|
include RailsOverrides
|
12
12
|
include DeckHelper
|
13
13
|
|
14
|
-
source_root File.expand_path("
|
14
|
+
source_root File.expand_path("templates", __dir__)
|
15
15
|
|
16
16
|
# All but the first aliases should be considered deprecated
|
17
17
|
class_option "monkey",
|
@@ -123,6 +123,7 @@ module Decko
|
|
123
123
|
|
124
124
|
def database_gemfile_entry
|
125
125
|
return [] if options[:skip_active_record]
|
126
|
+
|
126
127
|
gem_name, gem_version = gem_for_database
|
127
128
|
msg = "Use #{options[:database]} as the database for Active Record"
|
128
129
|
GemfileEntry.version gem_name, gem_version, msg
|
@@ -52,8 +52,8 @@ module Decko
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def build_option key, desc, command
|
55
|
-
command &&= "
|
56
|
-
" #{key} - #{desc}#{command
|
55
|
+
command &&= "#{' ' * (65 - desc.size)}[#{command}]"
|
56
|
+
" #{key} - #{desc}#{command}"
|
57
57
|
end
|
58
58
|
|
59
59
|
def add_config_options
|
@@ -108,9 +108,9 @@ module Decko
|
|
108
108
|
def add_after_seed_options
|
109
109
|
@menu["x"][:desc] = "exit"
|
110
110
|
@menu["r"] = {
|
111
|
-
desc:
|
111
|
+
desc: "run decko server",
|
112
112
|
command: "decko server",
|
113
|
-
code:
|
113
|
+
code: proc { bundle_exec "decko server" }
|
114
114
|
}
|
115
115
|
end
|
116
116
|
end
|
data/lib/decko/tasks/alias.rb
CHANGED
@@ -16,16 +16,15 @@ def link_task task, from: nil, to: nil, namespace: nil
|
|
16
16
|
case task
|
17
17
|
when Hash
|
18
18
|
task.each do |key, val|
|
19
|
-
link_task val, from: from, to: to
|
20
|
-
|
21
|
-
|
19
|
+
link_task val, from: from, to: to,
|
20
|
+
namespace: append_to_namespace(namespace, key)
|
22
21
|
end
|
23
22
|
when Array
|
24
23
|
task.each do |t|
|
25
|
-
|
24
|
+
link_task t, from: from, to: to, namespace: namespace
|
26
25
|
end
|
27
26
|
else
|
28
27
|
shared_part = append_to_namespace namespace, task
|
29
28
|
alias_task "#{from}:#{shared_part}", "#{to}:#{shared_part}"
|
30
29
|
end
|
31
|
-
end
|
30
|
+
end
|
@@ -5,61 +5,69 @@
|
|
5
5
|
# files.
|
6
6
|
|
7
7
|
unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gems:* tasks
|
8
|
+
vendored_cucumber_bin =
|
9
|
+
Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
10
|
+
unless vendored_cucumber_bin.nil?
|
11
|
+
$LOAD_PATH.unshift("#{File.dirname(vendored_cucumber_bin)}/../lib")
|
12
|
+
end
|
8
13
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
begin
|
13
|
-
require "cucumber/rake/task"
|
14
|
+
begin
|
15
|
+
require "cucumber/rake/task"
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
namespace :cucumber do
|
18
|
+
Cucumber::Rake::Task.new({ ok: "db:test:prepare" },
|
19
|
+
"Run features that should pass") do |t|
|
20
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
21
|
+
t.fork = true # You may get faster startup if you set this to false
|
22
|
+
t.profile = "default"
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
Cucumber::Rake::Task.new({ wip: "db:test:prepare" },
|
26
|
+
"Run features that are being worked on") do |t|
|
27
|
+
t.binary = vendored_cucumber_bin
|
28
|
+
t.fork = true # You may get faster startup if you set this to false
|
29
|
+
t.profile = "wip"
|
30
|
+
end
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
Cucumber::Rake::Task.new(
|
33
|
+
{ rerun: "db:test:prepare" },
|
34
|
+
"Record failing features and run only them if any exist"
|
35
|
+
) do |t|
|
36
|
+
t.binary = vendored_cucumber_bin
|
37
|
+
t.fork = true # You may get faster startup if you set this to false
|
38
|
+
t.profile = "rerun"
|
39
|
+
end
|
33
40
|
|
34
|
-
|
35
|
-
|
41
|
+
desc "Run all features"
|
42
|
+
task all: %i[ok wip]
|
36
43
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
task :statsetup do
|
45
|
+
require "rails/code_statistics"
|
46
|
+
::STATS_DIRECTORIES << %w[Cucumber\ features features] if File.exist?("features")
|
47
|
+
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?("features")
|
48
|
+
::STATS_DIRECTORIES << %w[Mods mods] if File.exist?("mods")
|
49
|
+
end
|
42
50
|
end
|
43
|
-
|
44
|
-
|
45
|
-
task cucumber: "cucumber:ok"
|
51
|
+
desc "Alias for cucumber:ok"
|
52
|
+
task cucumber: "cucumber:ok"
|
46
53
|
|
47
|
-
|
54
|
+
task default: :cucumber
|
48
55
|
|
49
|
-
|
50
|
-
|
51
|
-
|
56
|
+
task features: :cucumber do
|
57
|
+
warn "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
58
|
+
end
|
52
59
|
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
|
61
|
+
task "db:test:prepare" do
|
62
|
+
end
|
56
63
|
|
57
|
-
|
58
|
-
rescue LoadError
|
59
|
-
|
60
|
-
|
61
|
-
|
64
|
+
task stats: "cucumber:statsetup"
|
65
|
+
rescue LoadError
|
66
|
+
desc "cucumber rake task not available (cucumber not installed)"
|
67
|
+
task :cucumber do
|
68
|
+
abort "Cucumber rake task is not available. " \
|
69
|
+
"Be sure to install cucumber as a gem or plugin"
|
70
|
+
end
|
62
71
|
end
|
63
|
-
end
|
64
72
|
|
65
73
|
end
|
data/lib/decko/tasks/db.rake
CHANGED
@@ -19,6 +19,7 @@ unless Rake::TaskManager.methods.include?(:redefine_task)
|
|
19
19
|
task
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
22
23
|
class Task
|
23
24
|
class << self
|
24
25
|
def redefine_task args, &block
|
@@ -36,8 +37,14 @@ namespace :db do
|
|
36
37
|
require "active_record/fixtures"
|
37
38
|
fixture_path = File.join(Cardio.gem_root, "db", "seed", "test", "fixtures")
|
38
39
|
ActiveRecord::Base.establish_connection(::Rails.env.to_sym)
|
39
|
-
(
|
40
|
-
|
40
|
+
(if ENV["FIXTURES"]
|
41
|
+
ENV["FIXTURES"].split(/,/)
|
42
|
+
else
|
43
|
+
Dir.glob(File.join(fixture_path,
|
44
|
+
"*.{yml,csv}"))
|
45
|
+
end).each do |fixture_file|
|
46
|
+
ActiveRecord::FixtureSet.create_fixtures(fixture_path,
|
47
|
+
File.basename(fixture_file, ".*"))
|
41
48
|
end
|
42
49
|
end
|
43
50
|
end
|
data/lib/decko/tasks/decko.rake
CHANGED
@@ -5,9 +5,9 @@ require "card/seed_consts"
|
|
5
5
|
CARD_TASKS =
|
6
6
|
[
|
7
7
|
:migrate,
|
8
|
-
{ migrate: [
|
8
|
+
{ migrate: %i[cards structure core_cards deck_cards redo stamp] },
|
9
9
|
:reset_cache
|
10
|
-
]
|
10
|
+
].freeze
|
11
11
|
|
12
12
|
link_task CARD_TASKS, from: :decko, to: :card
|
13
13
|
|
@@ -80,6 +80,7 @@ decko_namespace = namespace :decko do
|
|
80
80
|
if Decko.paths["tmp"].existent
|
81
81
|
Dir.foreach(tmp_dir) do |filename|
|
82
82
|
next if filename.starts_with? "."
|
83
|
+
|
83
84
|
FileUtils.rm_rf File.join(tmp_dir, filename), secure: true
|
84
85
|
end
|
85
86
|
else
|
@@ -111,6 +112,7 @@ decko_namespace = namespace :decko do
|
|
111
112
|
|
112
113
|
def prepped_asset_path
|
113
114
|
return if Rails.root.to_s == Decko.gem_root # inside decko gem
|
115
|
+
|
114
116
|
assets_path = File.join Rails.public_path, "assets"
|
115
117
|
if File.symlink?(assets_path) || !File.directory?(assets_path)
|
116
118
|
FileUtils.rm_rf assets_path
|
@@ -133,7 +135,7 @@ decko_namespace = namespace :decko do
|
|
133
135
|
# creates!
|
134
136
|
begin
|
135
137
|
Rake::Task["db:drop"].invoke
|
136
|
-
rescue
|
138
|
+
rescue StandardError
|
137
139
|
puts "not dropped"
|
138
140
|
end
|
139
141
|
|
@@ -152,7 +154,7 @@ end
|
|
152
154
|
|
153
155
|
def failing_loudly task
|
154
156
|
yield
|
155
|
-
rescue
|
157
|
+
rescue StandardError
|
156
158
|
# TODO: fix this so that message appears *after* the errors.
|
157
159
|
# Solution should ensure that rake still exits with error code 1!
|
158
160
|
raise "\n>>>>>> FAILURE! #{task} did not complete successfully." \
|
@@ -33,6 +33,7 @@ namespace :decko do
|
|
33
33
|
|
34
34
|
def delete_ignored_cards
|
35
35
|
return unless (ignore = Card["*ignore"])
|
36
|
+
|
36
37
|
Card::Auth.as_bot do
|
37
38
|
ignore.item_cards.each(&:delete!)
|
38
39
|
end
|
@@ -62,6 +63,7 @@ namespace :decko do
|
|
62
63
|
Card.search(right: { codename: codename }).each do |card|
|
63
64
|
FileUtils.rm_rf File.join("files", card.id.to_s), secure: true
|
64
65
|
next if reserved_output? card.name
|
66
|
+
|
65
67
|
card.delete!
|
66
68
|
end
|
67
69
|
end
|
@@ -116,6 +118,7 @@ namespace :decko do
|
|
116
118
|
|
117
119
|
def add_test_data
|
118
120
|
return unless Rails.env == "test"
|
121
|
+
|
119
122
|
load CARD_TEST_SEED_SCRIPT_PATH
|
120
123
|
SharedData.add_test_data
|
121
124
|
end
|
data/rails/engine-routes.rb
CHANGED
@@ -37,7 +37,7 @@ Decko::Engine.routes.draw do
|
|
37
37
|
|
38
38
|
# explicit GET alternatives for transactions
|
39
39
|
%w[create read update delete asset].each do |action|
|
40
|
-
get "(card)/#{action}(/:mark(.:format))"
|
40
|
+
get "(card)/#{action}(/:mark(.:format))" => "card", action: action
|
41
41
|
end
|
42
42
|
|
43
43
|
# for super-explicit over-achievers
|
data/script/decko
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
3
|
|
4
|
-
APP_PATH = File.expand_path("
|
5
|
-
require File.expand_path("
|
4
|
+
APP_PATH = File.expand_path("../config/application", __dir__)
|
5
|
+
require File.expand_path("../config/boot", __dir__)
|
6
6
|
require "decko/commands"
|
data/script/rails
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails"
|
2
|
+
# This command will automatically be run when you run "rails"
|
3
3
|
|
4
|
-
APP_PATH = File.expand_path("
|
5
|
-
require File.expand_path("
|
6
|
-
require "rails/commands"
|
4
|
+
# APP_PATH = File.expand_path("../config/application", __dir__)
|
5
|
+
# require File.expand_path("../config/boot", __dir__)
|
6
|
+
# require "rails/commands"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-05-
|
13
|
+
date: 2021-05-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: card
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.101.
|
21
|
+
version: 1.101.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.101.
|
28
|
+
version: 1.101.5
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: card-mod-defaults
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.11.
|
35
|
+
version: 0.11.5
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.11.
|
42
|
+
version: 0.11.5
|
43
43
|
description: a wiki approach to structured data, dynamic interaction, and web design
|
44
44
|
email:
|
45
45
|
- info@decko.org
|
@@ -66,6 +66,11 @@ files:
|
|
66
66
|
- app/assets/images/smoothness/ui-icons_888888_256x240.png
|
67
67
|
- app/assets/images/smoothness/ui-icons_cd0a0a_256x240.png
|
68
68
|
- bin/decko
|
69
|
+
- lib/card_controller.rb
|
70
|
+
- lib/card_controller/errors.rb
|
71
|
+
- lib/card_controller/mark.rb
|
72
|
+
- lib/card_controller/response.rb
|
73
|
+
- lib/card_controller/rest.rb
|
69
74
|
- lib/decko.rb
|
70
75
|
- lib/decko/all.rb
|
71
76
|
- lib/decko/application.rb
|
@@ -131,7 +136,6 @@ files:
|
|
131
136
|
- lib/decko/generators/deck/templates/spec/javascripts/support/decko_jasmine.yml.erb
|
132
137
|
- lib/decko/generators/deck/templates/spec/spec_helper.rb
|
133
138
|
- lib/decko/mods_spec_helper.rb
|
134
|
-
- lib/decko/response.rb
|
135
139
|
- lib/decko/rest_spec_helper.rb
|
136
140
|
- lib/decko/script_decko_loader.rb
|
137
141
|
- lib/decko/swagger.rb
|
@@ -150,14 +154,10 @@ files:
|
|
150
154
|
- rails/assets/jasmine/500.html
|
151
155
|
- rails/assets/jasmine/card_form.html
|
152
156
|
- rails/assets/jquery.min.map
|
153
|
-
- rails/controllers/application_controller.rb
|
154
|
-
- rails/controllers/card_controller.rb
|
155
|
-
- rails/controllers/card_controller/errors.rb
|
156
157
|
- rails/engine-routes.rb
|
157
158
|
- script/autospec
|
158
159
|
- script/decko
|
159
160
|
- script/rails
|
160
|
-
- script/test_filter
|
161
161
|
homepage: https://decko.org
|
162
162
|
licenses:
|
163
163
|
- GPL-3.0
|
@@ -1,122 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
# Decko's only controller.
|
4
|
-
class CardController < ApplicationController
|
5
|
-
include ::Card::Env::Location
|
6
|
-
include ::Recaptcha::Verify
|
7
|
-
include ::Decko::Response
|
8
|
-
include Errors
|
9
|
-
|
10
|
-
layout nil
|
11
|
-
attr_reader :card
|
12
|
-
|
13
|
-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
14
|
-
# PUBLIC METHODS
|
15
|
-
|
16
|
-
def create
|
17
|
-
handle { card.save! }
|
18
|
-
end
|
19
|
-
|
20
|
-
def read
|
21
|
-
show
|
22
|
-
end
|
23
|
-
|
24
|
-
def update
|
25
|
-
card.new_card? ? create : handle { card.update! params[:card]&.to_unsafe_h }
|
26
|
-
end
|
27
|
-
|
28
|
-
def delete
|
29
|
-
handle { card.delete! }
|
30
|
-
end
|
31
|
-
|
32
|
-
def asset
|
33
|
-
body = "Decko installation error: missing asset symlinks"
|
34
|
-
Rails.logger.info "#{body}.\n >>> Try `rake decko:update_assets_symlink`"
|
35
|
-
render body: body, status: 404
|
36
|
-
end
|
37
|
-
|
38
|
-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
39
|
-
# PRIVATE METHODS
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
#-------( FILTERS )
|
44
|
-
|
45
|
-
before_action :setup, except: [:asset]
|
46
|
-
before_action :authenticate, except: [:asset]
|
47
|
-
before_action :load_mark, only: [:read]
|
48
|
-
before_action :load_card, except: [:asset]
|
49
|
-
before_action :load_action, only: [:read]
|
50
|
-
before_action :refresh_card, only: [:create, :update, :delete]
|
51
|
-
|
52
|
-
def setup
|
53
|
-
Card::Machine.refresh_script_and_style unless params[:explicit_file]
|
54
|
-
Card::Cache.renew
|
55
|
-
Card::Env.reset controller: self
|
56
|
-
end
|
57
|
-
|
58
|
-
def authenticate
|
59
|
-
Card::Auth.signin_with params
|
60
|
-
end
|
61
|
-
|
62
|
-
def load_mark
|
63
|
-
params[:mark] = interpret_mark params[:mark]
|
64
|
-
end
|
65
|
-
|
66
|
-
def load_card
|
67
|
-
@card = Card.controller_fetch params
|
68
|
-
raise Card::Error::NotFound unless card
|
69
|
-
record_as_main
|
70
|
-
end
|
71
|
-
|
72
|
-
def load_action
|
73
|
-
card.select_action_by_params params
|
74
|
-
card.content = card.last_draft_content if params[:edit_draft] && card.drafts.present?
|
75
|
-
end
|
76
|
-
|
77
|
-
# TODO: refactor this away this when new layout handling is ready
|
78
|
-
def record_as_main
|
79
|
-
Card::Env[:main_name] = params[:main] || card&.name || ""
|
80
|
-
end
|
81
|
-
|
82
|
-
def refresh_card
|
83
|
-
@card = card.refresh
|
84
|
-
end
|
85
|
-
|
86
|
-
# ----------( HELPER METHODS ) -------------
|
87
|
-
|
88
|
-
def handle
|
89
|
-
Card::Env.success card.name
|
90
|
-
yield ? cud_success : raise(Card::Error::UserError)
|
91
|
-
end
|
92
|
-
|
93
|
-
# successful create, update, or delete act
|
94
|
-
def cud_success
|
95
|
-
success = Card::Env.success.in_context card.name
|
96
|
-
if success.reload?
|
97
|
-
reload # instruct JSON to reload
|
98
|
-
else
|
99
|
-
redirect_cud_success success
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def show view=nil, status=200
|
104
|
-
card.action = :read
|
105
|
-
format = load_format status
|
106
|
-
result = render_page format, view
|
107
|
-
status = format.error_status || status
|
108
|
-
respond format, result, status
|
109
|
-
end
|
110
|
-
|
111
|
-
def render_page format, view
|
112
|
-
view ||= view_from_params
|
113
|
-
card.act do
|
114
|
-
format.page self, view, Card::Env.slot_opts
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def view_from_params
|
119
|
-
%i[view v].each { |k| return params[k] if params[k].present? }
|
120
|
-
nil
|
121
|
-
end
|
122
|
-
end
|
data/script/test_filter
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#!/usr/local/bin/ruby
|
2
|
-
|
3
|
-
STDOUT.sync = true
|
4
|
-
errors_filename = "./log/err.out"
|
5
|
-
err_out = File.new(errors_filename, "a")
|
6
|
-
|
7
|
-
ARGF.each_line do |l|
|
8
|
-
error_section = false
|
9
|
-
if error_section
|
10
|
-
error_section = false if l =~ /^\s*$/
|
11
|
-
elsif l =~ /^\s*\d+\)\s*$/
|
12
|
-
error_section = true
|
13
|
-
elsif l =~ /^\*{40,}$/ ||
|
14
|
-
l =~ /^be removed from a future version of RSpec\.$/ ||
|
15
|
-
l =~ /^\* simple_matcher is deprecated\.$/ ||
|
16
|
-
l =~ /^\* please use Matcher DSL \(http\:\/\/rspec\.rubyforge\.org\/rspec\/1\.3.0\/classes\/Spec\/Matchers\.html\) instead\.$/
|
17
|
-
err_out << l if err_out
|
18
|
-
next
|
19
|
-
elsif l =~ /^([\.\[\]F\*\s]*)((\/| \(called from create_or_update_thumbnail|DEPRECATION WARN|The \{\{key\}\} interpolation syntax in|from \/).*\n?$)/
|
20
|
-
STDOUT << Regexp.last_match(1)
|
21
|
-
err_out << Regexp.last_match(2) if err_out
|
22
|
-
next
|
23
|
-
end
|
24
|
-
STDOUT << l
|
25
|
-
end
|