card 1.103.4 → 1.104.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/environments/development.rb +4 -2
- data/config/environments/test.rb +1 -1
- data/config/initializers/01_core_extensions/array.rb +4 -1
- data/config/initializers/01_core_extensions/object.rb +1 -1
- data/config/initializers/02_patches/active_record.rb +16 -17
- data/config/locales/de.yml +8 -564
- data/config/locales/es.yml +2 -3
- data/db/migrate/20110511221913_require_earlier_migrations.rb +1 -1
- data/db/migrate/20120105203350_require_1_8_migrations.rb +1 -1
- data/db/migrate/20121111025347_require_1_10_migrations.rb +1 -1
- data/db/migrate/20211128040849_virtuals_updated_at.rb +11 -0
- data/db/migrate_core_cards/20190502130029_add_shark_and_help_desk_role.rb +0 -1
- data/db/schema.rb +19 -16
- data/db/seed/new/card_actions.yml +1323 -2091
- data/db/seed/new/card_acts.yml +2 -2
- data/db/seed/new/card_references.yml +629 -741
- data/db/seed/new/cards.yml +2593 -5557
- data/db/seed/new/schema_migrations.yml +2 -0
- data/db/seed/new/schema_migrations_core_cards.yml +8 -0
- data/db/seed/test/fixtures/card_actions.yml +2555 -3395
- data/db/seed/test/fixtures/card_acts.yml +606 -666
- data/db/seed/test/fixtures/card_changes.yml +101 -101
- data/db/seed/test/fixtures/card_references.yml +1609 -1686
- data/db/seed/test/fixtures/cards.yml +4363 -7541
- data/db/seed/test/fixtures/schema_migrations.yml +2 -0
- data/db/seed/test/fixtures/schema_migrations_core_cards.yml +8 -0
- data/db/test_seed.rb +1 -4
- data/db/version.txt +1 -1
- data/db/version_core_cards.txt +1 -1
- data/lib/card/auth/current.rb +1 -1
- data/lib/card/auth/permissions.rb +37 -35
- data/lib/card/content/all.rb +3 -3
- data/lib/card/content/chunk.rb +1 -0
- data/lib/card/director/act_direction.rb +1 -3
- data/lib/card/director/card_methods.rb +0 -1
- data/lib/card/director/phases.rb +1 -0
- data/lib/card/director.rb +1 -0
- data/lib/card/fetch/all.rb +3 -3
- data/lib/card/fetch/card_class.rb +5 -11
- data/lib/card/fetch/results.rb +2 -2
- data/lib/card/model/save_helper.rb +2 -2
- data/lib/card/name/all/descendants.rb +9 -7
- data/lib/card/name/all/parts.rb +1 -1
- data/lib/card/name/all.rb +4 -3
- data/lib/card/name/card_class.rb +1 -0
- data/lib/card/name/fields_and_traits.rb +6 -30
- data/lib/card/name/name_variants.rb +5 -1
- data/lib/card/name.rb +0 -8
- data/lib/card/query/abstract_query/tie.rb +2 -3
- data/lib/card/query/card_query/normalization.rb +1 -1
- data/lib/card/query/sql_statement/order.rb +5 -6
- data/lib/card/query/value.rb +10 -7
- data/lib/card/reference/all.rb +9 -7
- data/lib/card/reference.rb +36 -41
- data/lib/card/rule/all.rb +3 -3
- data/lib/card/set/advanced_api.rb +5 -0
- data/lib/card/set/event/delayed_event.rb +8 -1
- data/lib/card/set/event.rb +1 -0
- data/lib/card/set/helpers.rb +30 -17
- data/lib/card/set/pattern/all.rb +13 -4
- data/lib/card/set/pattern/base.rb +12 -18
- data/lib/card/set/pattern/class_methods.rb +13 -13
- data/lib/card/set/pattern.rb +30 -19
- data/lib/card/set/trait.rb +16 -1
- data/lib/card/set/type.rb +3 -0
- data/lib/card/subcards/add.rb +1 -3
- data/lib/card/subcards/all.rb +30 -56
- data/lib/card/view/options.rb +7 -5
- data/lib/cardio/cli.rb +1 -0
- data/lib/cardio/commands/custom.rb +60 -0
- data/lib/cardio/commands/rake_command/parser.rb +49 -48
- data/lib/cardio/commands/rake_command.rb +17 -15
- data/lib/cardio/commands/rspec_command.rb +2 -0
- data/lib/cardio/commands.rb +69 -69
- data/lib/cardio/generators.rb +56 -3
- data/lib/cardio/migration/deck.rb +0 -0
- data/lib/cardio/migration/deck_structure.rb +2 -0
- data/lib/cardio/migration/import/import_data/card_content.rb +1 -1
- data/lib/cardio/migration/import.rb +2 -2
- data/lib/cardio/migration.rb +26 -2
- data/lib/cardio/mod/class_methods.rb +112 -0
- data/lib/cardio/mod/dirs.rb +15 -11
- data/lib/cardio/mod/eat/edibles.rb +92 -0
- data/lib/cardio/mod/eat.rb +81 -0
- data/lib/cardio/mod/load_strategy/tmp_files.rb +1 -1
- data/lib/cardio/mod/modfile_api.rb +5 -0
- data/lib/cardio/mod/poop.rb +135 -0
- data/lib/cardio/mod.rb +20 -80
- data/lib/cardio/railtie.rb +15 -3
- data/lib/cardio/schema.rb +11 -10
- data/lib/cardio/version.rb +35 -0
- data/lib/cardio.rb +4 -0
- data/lib/generators/deck/templates/Gemfile.erb +0 -4
- data/lib/generators/deck/templates/rspec.erb +1 -1
- data/lib/generators/deck/templates/spec/javascripts/support/decko_jasmine.yml.erb +0 -1
- data/lib/generators/mod/USAGE +1 -0
- data/lib/tasks/card/migrate.rake +41 -1
- data/lib/tasks/card/mod.rake +15 -8
- data/lib/tasks/card.rake +47 -87
- data/mod/admin/locales/de.yml +4 -0
- data/mod/admin/set/self/admin.rb +10 -8
- data/mod/core/data/production.yml +7 -0
- data/mod/core/data/test.yml +30 -0
- data/mod/core/locales/de.yml +28 -0
- data/mod/core/set/all/assign_attributes.rb +1 -33
- data/mod/core/set/all/content.rb +3 -1
- data/mod/core/set/all/initialize.rb +1 -4
- data/mod/core/set/all/name_events.rb +3 -18
- data/mod/core/set/all/reference_events.rb +29 -28
- data/mod/core/set/all/subcards.rb +6 -2
- data/mod/core/set/all/trash.rb +2 -3
- data/mod/core/set/all/type.rb +67 -18
- data/mod/core/set/self/version.rb +1 -1
- data/mod/core/spec/set/self/trash_spec.rb +1 -1
- data/mod/standard/{file → data/files}/favicon/image-icon.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-large.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-medium.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-original.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-small.png +0 -0
- data/mod/standard/{file → data/files}/logo/image-original.svg +0 -0
- metadata +37 -28
- data/db/migrate_core_cards/20150605115802_add_performance_log_card.rb +0 -7
- data/lib/card/set/code_nest.rb +0 -15
- data/lib/card/version.rb +0 -11
- data/lib/cardio/commands/USAGE +0 -28
- data/lib/cardio/generators/class_methods.rb +0 -35
- data/lib/tasks/card/asset.rake +0 -22
- data/mod/core/spec/set/all/clean_me_spec.rb +0 -258
- data/mod/core/spec/set/all/export_spec.rb +0 -71
- data/tmpsets/set_pattern/100-all.rb +0 -22
- data/tmpsets/set_pattern/101-all_plus.rb +0 -24
- data/tmpsets/set_pattern/102-type.rb +0 -40
- data/tmpsets/set_pattern/103-star.rb +0 -26
- data/tmpsets/set_pattern/104-rstar.rb +0 -28
- data/tmpsets/set_pattern/105-rule.rb +0 -28
- data/tmpsets/set_pattern/106-right.rb +0 -35
- data/tmpsets/set_pattern/107-type_plus_right.rb +0 -43
- data/tmpsets/set_pattern/108-self.rb +0 -34
data/lib/card/view/options.rb
CHANGED
@@ -40,6 +40,7 @@ class Card
|
|
40
40
|
heir: [
|
41
41
|
:main, # format object is page's "main" object (Boolean)
|
42
42
|
:home_view, # view for slot to return to when no view specified
|
43
|
+
:buttons_view,
|
43
44
|
:edit_structure, # use a different structure for editing (Array)
|
44
45
|
:cql, # contextual cql alterations for search cards (Hash)
|
45
46
|
:action_id, # a Card::Action id (Integer)
|
@@ -50,20 +51,21 @@ class Card
|
|
50
51
|
:help, # cue text when editing
|
51
52
|
:structure, # overrides the content of the card
|
52
53
|
:title, # overrides the name of the card
|
53
|
-
:variant, # override the
|
54
|
-
# variant
|
54
|
+
:variant, # override the standard name with a different variant
|
55
55
|
:input_type, # inline_nests makes a form within standard content (Symbol)
|
56
56
|
:type, # set the default type of new cards
|
57
57
|
:size, # set an image size
|
58
|
-
#
|
59
|
-
:params, # parameters for add button. deprecated!
|
58
|
+
# (also used for character limit in one_line_content)
|
60
59
|
:items, # options for items (Hash)
|
61
60
|
:cache, # change view cache behaviour
|
62
61
|
# (Symbol<:always, :standard, :never>)
|
63
62
|
:edit, # edit mode
|
64
63
|
# (Symbol<:inline, :standard, :full>)
|
65
64
|
:separator, # item separator in certain lists
|
66
|
-
:filter
|
65
|
+
:filter,
|
66
|
+
|
67
|
+
# DEPRECATED
|
68
|
+
:params # parameters for add button
|
67
69
|
],
|
68
70
|
none: [
|
69
71
|
:skip_perms, # do not check permissions for this view (Boolean)
|
data/lib/cardio/cli.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
require "optparse"
|
2
|
+
require "cardio/version"
|
3
|
+
|
4
|
+
module Cardio
|
5
|
+
class Commands
|
6
|
+
module Custom
|
7
|
+
private
|
8
|
+
|
9
|
+
def run_new
|
10
|
+
if !["-h", "--help"].intersection(args).empty?
|
11
|
+
require "cardio/commands/application"
|
12
|
+
else
|
13
|
+
puts "Can't initialize a new deck within the directory of another, " \
|
14
|
+
"please change to a non-deck directory first.\n"
|
15
|
+
puts "Type '#{gem}' for help."
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def run_version
|
21
|
+
puts "Card #{Version.card_release}".light_cyan
|
22
|
+
end
|
23
|
+
|
24
|
+
def run_rspec
|
25
|
+
require "cardio/commands/rspec_command"
|
26
|
+
RspecCommand.new(args).run
|
27
|
+
end
|
28
|
+
|
29
|
+
# def run_jasmine
|
30
|
+
# require "cardio/commands/rake_command"
|
31
|
+
# RakeCommand.new("spec:javascript", envs: "test").run
|
32
|
+
# end
|
33
|
+
|
34
|
+
def run_help
|
35
|
+
puts "Usage:"
|
36
|
+
puts " #{gem} COMMAND [OPTIONS]".green
|
37
|
+
puts
|
38
|
+
puts "Run commands with -h (or --help) for more info."
|
39
|
+
|
40
|
+
%i[shark monkey].each do |group|
|
41
|
+
puts
|
42
|
+
puts "For " + "#{group}s".yellow + ":"
|
43
|
+
map.each do |command, conf|
|
44
|
+
next unless conf[:group] == group
|
45
|
+
puts command_help(command, conf)
|
46
|
+
end
|
47
|
+
puts
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# formats command string for help text
|
54
|
+
def command_help command, conf
|
55
|
+
alt = conf[:alias] ? "(or #{conf[:alias]})" : ""
|
56
|
+
" " + command.to_s.ljust(12).light_cyan + alt.ljust(10) + conf[:desc]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -1,50 +1,51 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
require "optparse"
|
4
|
-
|
5
|
-
module Cardio
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
3
|
+
# require "optparse"
|
4
|
+
#
|
5
|
+
# module Cardio
|
6
|
+
# class Commands
|
7
|
+
# class RakeCommand
|
8
|
+
# # parse decko/card -specific options for rake
|
9
|
+
# class Parser < OptionParser
|
10
|
+
# ONS = {
|
11
|
+
# production: {
|
12
|
+
# desc: "production database (default)"
|
13
|
+
# },
|
14
|
+
# test: {},
|
15
|
+
# development: {},
|
16
|
+
# all: {
|
17
|
+
# desc: "production, test, and development database",
|
18
|
+
# envs: %w[production development test]
|
19
|
+
# }
|
20
|
+
# }.freeze
|
21
|
+
#
|
22
|
+
# def initialize command, opts
|
23
|
+
# super() do |parser|
|
24
|
+
# parser.banner =
|
25
|
+
# "Usage:\n" +
|
26
|
+
# " #{Commands.gem} #{command} [options]".green +
|
27
|
+
# "\n\nRuns `rake #{Commands.gem}:#{command}` task."
|
28
|
+
# parser_ons parser, command do |env_array|
|
29
|
+
# opts[:envs] = env_array
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# def parser_ons parser, command
|
35
|
+
# ONS.each do |env, vals|
|
36
|
+
# parser.on(*parser_on_opts(env, command, vals[:desc])) do
|
37
|
+
# yield (vals[:envs] || [env.to_s])
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# def parser_on_opts env, command, desc
|
43
|
+
# main = "--#{env}"
|
44
|
+
# short = "-#{env.to_s[0]}"
|
45
|
+
# desc ||= "#{env} database"
|
46
|
+
# [main, short, "#{command} #{desc}"]
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
# end
|
@@ -1,24 +1,25 @@
|
|
1
1
|
require File.expand_path("command", __dir__)
|
2
|
-
# require "pry"
|
3
2
|
|
4
3
|
module Cardio
|
5
4
|
class Commands
|
6
5
|
# enhance standard rake command with some decko/card -specific options
|
7
6
|
class RakeCommand < Command
|
8
|
-
def initialize
|
9
|
-
@
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
def initialize gem, command, args={}
|
8
|
+
@command = command
|
9
|
+
@task = "#{gem}:#{command}"
|
10
|
+
@args = [args].flatten
|
11
|
+
# opts = {}
|
12
|
+
# if args.is_a? Array
|
13
|
+
# Parser.new(rake_task, opts).parse!(args)
|
14
|
+
# else
|
15
|
+
# opts = args
|
16
|
+
# end
|
17
|
+
# @envs = Array(opts[:envs])
|
17
18
|
end
|
18
19
|
|
19
20
|
def run
|
20
21
|
commands.each do |cmd|
|
21
|
-
puts cmd
|
22
|
+
# puts cmd
|
22
23
|
# exit_with_child_status cmd
|
23
24
|
|
24
25
|
result = `#{cmd}`
|
@@ -30,14 +31,15 @@ module Cardio
|
|
30
31
|
|
31
32
|
def commands
|
32
33
|
task_cmd = "bundle exec rake #{@task}"
|
34
|
+
task_cmd += " -- #{@args.join ' '}" if !@args.empty?
|
33
35
|
return [task_cmd] if !@envs || @envs.empty?
|
34
36
|
|
35
|
-
@envs.map do |env|
|
36
|
-
|
37
|
-
end
|
37
|
+
# @envs.map do |env|
|
38
|
+
# "env RAILS_ENV=#{env} #{task_cmd}"
|
39
|
+
# end
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
|
-
require File.expand_path("rake_command/parser", __dir__)
|
45
|
+
# require File.expand_path("rake_command/parser", __dir__)
|
data/lib/cardio/commands.rb
CHANGED
@@ -1,53 +1,59 @@
|
|
1
1
|
require "English"
|
2
|
+
require "colorize"
|
3
|
+
require "cardio/commands/custom"
|
2
4
|
|
3
5
|
module Cardio
|
4
|
-
# manage different types of commands that can be run via bin/card and bin/decko
|
6
|
+
# manage different types of commands that can be run via bin/card (and bin/decko)
|
5
7
|
class Commands
|
8
|
+
include Custom
|
9
|
+
|
6
10
|
attr_reader :command, :args
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
module Accessors
|
11
|
-
def aliases
|
12
|
-
@aliases ||= {
|
13
|
-
"rs" => "rspec",
|
14
|
-
"jm" => "jasmine",
|
15
|
-
"g" => "generate",
|
16
|
-
"d" => "destroy",
|
17
|
-
"c" => "console",
|
18
|
-
"db" => "dbconsole",
|
19
|
-
"r" => "runner",
|
20
|
-
"v" => "version",
|
21
|
-
"h" => "help"
|
22
|
-
}
|
23
|
-
end
|
12
|
+
class << self
|
13
|
+
attr_accessor :current
|
24
14
|
|
25
|
-
def
|
26
|
-
|
27
|
-
rails: %w[generate destroy plugin benchmarker profiler
|
28
|
-
console dbconsole application runner],
|
29
|
-
rake: %w[seed reseed load update],
|
30
|
-
custom: %w[new rspec jasmine version help]
|
31
|
-
}
|
15
|
+
def gem
|
16
|
+
current&.gem
|
32
17
|
end
|
33
18
|
end
|
34
19
|
|
35
|
-
|
20
|
+
def map
|
21
|
+
@map ||= {
|
22
|
+
new: { desc: "create a new deck", group: :shark, via: :call },
|
23
|
+
seed: { desc: "populate a database", group: :shark, via: :rake },
|
24
|
+
update: { desc: "run data updates", group: :shark, alias: :u, via: :rake },
|
25
|
+
version: { desc: "#{gem} gem version", group: :shark, alias: :v, via: :call },
|
26
|
+
help: { desc: "show this text", group: :shark, alias: :h, via: :call},
|
27
|
+
|
28
|
+
console: { desc: "start a ruby console", group: :monkey, alias: :c },
|
29
|
+
dbconsole: { desc: "start a database console", group: :monkey, alias: :db },
|
30
|
+
runner: { desc: "run code in app environment", group: :monkey, alias: :r },
|
31
|
+
rspec: { desc: "run rspec tests", group: :monkey, alias: :rs, via: :call },
|
32
|
+
generate: { desc: "generate templated code", group: :monkey, alias: :g },
|
33
|
+
poop: { desc: "export card data to mod yaml", group: :monkey, via: :rake },
|
34
|
+
eat: { desc: "ingest card data from mod yaml", group: :monkey, via: :rake }
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# TODO: review the following. see if any work well enough to include
|
39
|
+
#
|
40
|
+
# application Generate the Rails application code
|
41
|
+
# destroy Undo code generated with "generate" (short-cut alias: "d")
|
42
|
+
# benchmarker See how fast a piece of code runs
|
43
|
+
# profiler Get profile information from a piece of code
|
44
|
+
# plugin Install a plugin
|
45
|
+
# jasmine
|
36
46
|
|
37
47
|
def initialize args
|
38
48
|
@args = args
|
39
|
-
@command =
|
49
|
+
@command = command_for_key args.first&.to_sym
|
40
50
|
ENV["PRY_RESCUE_RAILS"] = "1" if rescue?
|
41
51
|
@args.shift unless handler == :rails
|
52
|
+
Commands.current = self
|
42
53
|
end
|
43
54
|
|
44
|
-
def
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
def handler
|
49
|
-
commands = self.class.commands
|
50
|
-
@handler ||= commands.keys.find { |k| commands[k].include? command }
|
55
|
+
def gem
|
56
|
+
"card"
|
51
57
|
end
|
52
58
|
|
53
59
|
def run
|
@@ -56,65 +62,59 @@ module Cardio
|
|
56
62
|
run_rails
|
57
63
|
when :rake
|
58
64
|
run_rake
|
59
|
-
when :
|
65
|
+
when :call
|
60
66
|
send "run_#{command}"
|
61
|
-
|
62
|
-
|
67
|
+
when :unknown
|
68
|
+
unknown_error
|
63
69
|
end
|
64
70
|
exit 0
|
65
71
|
end
|
66
72
|
|
67
|
-
|
68
|
-
def run_rails
|
69
|
-
require "rails/commands"
|
70
|
-
end
|
73
|
+
private
|
71
74
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
RakeCommand.new("#{rake_prefix}:#{command}", args).run
|
76
|
-
end
|
75
|
+
def command_for_key key
|
76
|
+
return :help unless key
|
77
|
+
return key if map.key? key
|
77
78
|
|
78
|
-
|
79
|
-
|
79
|
+
map.each { |k, v| return k if v[:alias] == key }
|
80
|
+
@unknown = true
|
81
|
+
key
|
80
82
|
end
|
81
83
|
|
82
|
-
|
84
|
+
def rescue?
|
85
|
+
args.delete "--rescue"
|
86
|
+
end
|
83
87
|
|
84
|
-
def
|
85
|
-
|
88
|
+
def config
|
89
|
+
map[command]
|
86
90
|
end
|
87
91
|
|
88
|
-
def
|
89
|
-
|
90
|
-
require "cardio/commands/application"
|
91
|
-
else
|
92
|
-
puts "Can't initialize a new deck within the directory of another, " \
|
93
|
-
"please change to a non-deck directory first.\n"
|
94
|
-
puts "Type 'decko' for help."
|
95
|
-
exit 1
|
96
|
-
end
|
92
|
+
def handler
|
93
|
+
@handler ||= @unknown ? :unknown : (config[:via] || :rails)
|
97
94
|
end
|
98
95
|
|
99
|
-
|
100
|
-
|
101
|
-
|
96
|
+
# runs all commands in "rails" list
|
97
|
+
def run_rails
|
98
|
+
require generator_requirement if command == :generate
|
99
|
+
require "rails/commands"
|
102
100
|
end
|
103
101
|
|
104
|
-
def
|
105
|
-
|
106
|
-
RspecCommand.new(args).run
|
102
|
+
def generator_requirement
|
103
|
+
"cardio/generators"
|
107
104
|
end
|
108
105
|
|
109
|
-
|
106
|
+
# runs all commands in "rake" list
|
107
|
+
def run_rake
|
110
108
|
require "cardio/commands/rake_command"
|
111
|
-
RakeCommand.new(
|
109
|
+
RakeCommand.new(gem, command, args).run
|
112
110
|
end
|
113
111
|
|
114
112
|
# ~~~~~~~~~~~~~~~~~~~~~ catch-all -------------- #
|
115
113
|
|
116
|
-
def
|
117
|
-
puts "
|
114
|
+
def unknown_error
|
115
|
+
puts "----------------------------------------------\n" \
|
116
|
+
"ERROR: Command not recognized: #{command}\n" \
|
117
|
+
"----------------------------------------------\n".red
|
118
118
|
run_help
|
119
119
|
exit 1
|
120
120
|
end
|
data/lib/cardio/generators.rb
CHANGED
@@ -2,19 +2,72 @@
|
|
2
2
|
|
3
3
|
require "rails/generators"
|
4
4
|
require "rails/generators/active_record"
|
5
|
+
require "colorize"
|
5
6
|
|
6
7
|
module Cardio
|
7
8
|
# for now, this just fulfills zeitwerk expectations. File is here for require calls.
|
8
9
|
module Generators
|
9
|
-
#
|
10
|
+
# methods shared across Generator bases (which inherit from Rails generator classes)
|
11
|
+
module ClassMethods
|
12
|
+
def source_root path=nil
|
13
|
+
if path
|
14
|
+
@_card_source_root = path
|
15
|
+
else
|
16
|
+
@_card_source_root ||= File.expand_path(
|
17
|
+
"../../generators/#{generator_name}/templates", __FILE__
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Override Rails default banner (using card/decko for the command name).
|
23
|
+
def banner
|
24
|
+
usage_args = arguments.map(&:usage).join " "
|
25
|
+
text = "\n#{banner_command} generate #{namespace} #{usage_args} [options]".green
|
26
|
+
text.gsub(/\s+/, " ")
|
27
|
+
end
|
28
|
+
|
29
|
+
def banner_command
|
30
|
+
Commands.gem
|
31
|
+
end
|
32
|
+
|
33
|
+
# Override Rails namespace handling so we can put generators in `module Cardio`
|
34
|
+
def namespace name=nil
|
35
|
+
return super if name
|
36
|
+
@namespace ||= super.sub(/cardio:/, "")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
delegate :banner_command, to: :class
|
10
40
|
end
|
11
41
|
end
|
12
42
|
|
13
43
|
module Rails
|
14
44
|
# override to hide all the rails generators that don't apply in a card/decko context
|
15
45
|
module Generators
|
16
|
-
|
17
|
-
|
46
|
+
class << self
|
47
|
+
# TODO: autogenerate
|
48
|
+
def generator_names
|
49
|
+
%i[mod set migration]
|
50
|
+
end
|
51
|
+
|
52
|
+
def help command="generate"
|
53
|
+
caller = Cardio::Commands.gem
|
54
|
+
puts "Usage:"
|
55
|
+
puts " #{caller} #{command} GENERATOR [args] [options]".green
|
56
|
+
puts
|
57
|
+
puts "General options:"
|
58
|
+
puts " -h, [--help] # Print generator's options and usage"
|
59
|
+
puts " -p, [--pretend] # Run but do not make any changes"
|
60
|
+
puts " -f, [--force] # Overwrite files that already exist"
|
61
|
+
puts " -s, [--skip] # Skip files that already exist"
|
62
|
+
puts " -q, [--quiet] # Suppress status output"
|
63
|
+
puts
|
64
|
+
puts "Please choose a generator below."
|
65
|
+
puts
|
66
|
+
generator_names.each do |name|
|
67
|
+
puts " #{name}".light_cyan
|
68
|
+
end
|
69
|
+
puts
|
70
|
+
end
|
18
71
|
end
|
19
72
|
end
|
20
73
|
end
|
File without changes
|
@@ -64,11 +64,11 @@ module Cardio
|
|
64
64
|
private
|
65
65
|
|
66
66
|
def update &block
|
67
|
-
ImportData.update
|
67
|
+
ImportData.update @data_path, &block
|
68
68
|
end
|
69
69
|
|
70
70
|
def importer
|
71
|
-
@importer ||= ImportData.new
|
71
|
+
@importer ||= ImportData.new @data_path
|
72
72
|
end
|
73
73
|
|
74
74
|
# Returns an array of hashes with card attributes
|
data/lib/cardio/migration.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Cardio
|
4
4
|
class Migration < ActiveRecord::Migration[4.2]
|
5
|
-
include Card::Model::SaveHelper
|
5
|
+
include Card::Model::SaveHelper unless ENV["NO_CARD_LOAD"]
|
6
6
|
@type = :deck_cards
|
7
7
|
|
8
8
|
class << self
|
@@ -43,12 +43,36 @@ module Cardio
|
|
43
43
|
Schema.assume_migrated_upto_version type
|
44
44
|
end
|
45
45
|
|
46
|
+
def assume_current
|
47
|
+
migration_context do |mc|
|
48
|
+
versions = mc.migrations.map(&:version)
|
49
|
+
migrated = mc.get_all_versions
|
50
|
+
mark_as_migrated versions - migrated
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
46
54
|
def data_path filename=nil
|
47
55
|
File.join([migration_paths.first, "data", filename].compact)
|
48
56
|
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def mark_as_migrated versions
|
61
|
+
sql = connection.send :insert_versions_sql, versions
|
62
|
+
connection.execute sql
|
63
|
+
end
|
64
|
+
|
65
|
+
def connection
|
66
|
+
ActiveRecord::Base.connection
|
67
|
+
end
|
68
|
+
|
69
|
+
def migration_context &block
|
70
|
+
Schema.migration_context type, &block
|
71
|
+
end
|
49
72
|
end
|
50
73
|
|
51
74
|
def contentedly
|
75
|
+
return yield if ENV["NO_CARD_LOAD"]
|
52
76
|
Card::Cache.reset_all
|
53
77
|
Schema.mode "" do
|
54
78
|
Card::Auth.as_bot do
|
@@ -111,7 +135,7 @@ module Cardio
|
|
111
135
|
end
|
112
136
|
|
113
137
|
# Execute this migration in the named direction
|
114
|
-
# copied from ActiveRecord to wrap 'up' in '
|
138
|
+
# copied from ActiveRecord to wrap 'up' in 'contentedly'
|
115
139
|
def exec_migration conn, direction
|
116
140
|
@connection = conn
|
117
141
|
if respond_to?(:change)
|