card 1.108.1 → 1.109.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/VERSION +1 -1
- data/config/environments/development.rb +1 -1
- data/config/environments/production.rb +5 -2
- data/config/initializers/01_core_extensions/array.rb +1 -0
- data/config/initializers/01_core_extensions/hash.rb +4 -0
- data/config/initializers/02_patches/active_record.rb +1 -1
- data/config/initializers/core_extensions.rb +0 -1
- data/config/initializers/deck_config.rb +3 -3
- data/config/initializers/patches.rb +6 -6
- data/lib/card/auth/current.rb +8 -6
- data/lib/card/auth.rb +7 -6
- data/lib/card/cache/class_methods.rb +2 -4
- data/lib/card/cache/shared.rb +1 -1
- data/lib/card/cache/temporary.rb +2 -2
- data/lib/card/codename.rb +0 -1
- data/lib/card/content/chunk/abstract.rb +1 -0
- data/lib/card/content/chunk.rb +0 -1
- data/lib/card/content/clean.rb +4 -2
- data/lib/card/content/diff/l_c_s.rb +1 -2
- data/lib/card/content/diff/result.rb +2 -1
- data/lib/card/content/diff.rb +2 -1
- data/lib/card/content/parser.rb +8 -7
- data/lib/card/content.rb +1 -1
- data/lib/card/director/subdirector_array.rb +1 -0
- data/lib/card/director.rb +1 -1
- data/lib/card/dirty/method_factory.rb +1 -0
- data/lib/card/env/location.rb +3 -3
- data/lib/card/env/location_history.rb +12 -11
- data/lib/card/env/success/target.rb +4 -4
- data/lib/card/env/support.rb +24 -2
- data/lib/card/error.rb +1 -0
- data/lib/card/fetch/store.rb +1 -1
- data/lib/card/format/error.rb +1 -0
- data/lib/card/format/method_delegation.rb +6 -4
- data/lib/card/format/registration.rb +5 -3
- data/lib/card/format/wrapper.rb +1 -0
- data/lib/card/mailer.rb +1 -14
- data/lib/card/name/all/parts.rb +1 -1
- data/lib/card/name/all.rb +1 -0
- data/lib/card/name/name_variants.rb +1 -0
- data/lib/card/query/abstract_query/query_helper.rb +1 -2
- data/lib/card/query/abstract_query/tie.rb +1 -1
- data/lib/card/query/abstract_query.rb +3 -3
- data/lib/card/query/card_class.rb +1 -0
- data/lib/card/query/clause.rb +1 -0
- data/lib/card/query/join.rb +3 -3
- data/lib/card/reference/all.rb +6 -7
- data/lib/card/rule/cache.rb +1 -0
- data/lib/card/rule/preference_cache.rb +2 -0
- data/lib/card/rule/read_rule_cache.rb +3 -0
- data/lib/card/set/event/all.rb +6 -4
- data/lib/card/set/event/callbacks.rb +1 -0
- data/lib/card/set/event/options.rb +3 -2
- data/lib/card/set/event/skip_and_trigger.rb +1 -1
- data/lib/card/set/event.rb +2 -2
- data/lib/card/set/format/abstract_format/view_definition.rb +1 -1
- data/lib/card/set/format/haml_paths.rb +1 -1
- data/lib/card/set/format.rb +4 -4
- data/lib/card/set/helpers.rb +4 -4
- data/lib/card/set/i18n_scanner.rb +23 -22
- data/lib/card/set/i18n_scope.rb +4 -3
- data/lib/card/set/pattern/all.rb +1 -1
- data/lib/card/set/pattern/base.rb +6 -3
- data/lib/card/set/pattern/class_methods.rb +1 -1
- data/lib/card/set/pattern.rb +1 -1
- data/lib/card/set/required_field.rb +3 -0
- data/lib/card/set/trait.rb +6 -1
- data/lib/card/subcards/all.rb +12 -4
- data/lib/card/view/cache/cache_action.rb +1 -1
- data/lib/card/view/cache.rb +1 -1
- data/lib/card/view/classy.rb +5 -5
- data/lib/card/view/options/key_lists.rb +1 -0
- data/lib/card/view/options/voo_api.rb +1 -1
- data/lib/cardio/command/application.rb +1 -1
- data/lib/cardio/command/custom.rb +7 -6
- data/lib/cardio/command/rake_command.rb +3 -2
- data/lib/cardio/command/rspec_command.rb +1 -0
- data/lib/cardio/generators/deck_generator_loader.rb +1 -1
- data/lib/cardio/generators.rb +4 -3
- data/lib/cardio/migration/port.rb +2 -0
- data/lib/cardio/migration/stamp.rb +1 -0
- data/lib/cardio/migration/transform.rb +1 -0
- data/lib/cardio/migration.rb +2 -0
- data/lib/cardio/mod/class_methods.rb +1 -2
- data/lib/cardio/mod/dirs.rb +2 -4
- data/lib/cardio/mod/eat/edibles.rb +8 -6
- data/lib/cardio/mod/eat.rb +6 -5
- data/lib/cardio/mod/load_strategy/set_binding_magic.rb +1 -1
- data/lib/cardio/mod/load_strategy/tmp_files.rb +3 -2
- data/lib/cardio/mod/load_strategy.rb +1 -0
- data/lib/cardio/mod/loader/set_pattern_loader.rb +4 -0
- data/lib/cardio/mod/loader/set_template.rb +14 -4
- data/lib/cardio/mod/loader.rb +2 -2
- data/lib/cardio/mod/sow/card_source.rb +1 -1
- data/lib/cardio/mod/sow/remote_source.rb +32 -0
- data/lib/cardio/mod/sow.rb +10 -10
- data/lib/cardio/railtie.rb +1 -0
- data/lib/cardio/script_loader.rb +1 -1
- data/lib/cardio/seed.rb +1 -1
- data/lib/cardio/utils.rb +1 -1
- data/lib/cardio/version.rb +2 -1
- data/lib/cardio.rb +3 -0
- data/lib/generators/deck/templates/config.ru.erb +1 -1
- data/mod/core/config/locales/en.yml +1 -0
- data/mod/core/data/schema/20141001105348_move_revisions_to_actions.rb +2 -2
- data/mod/core/data/schema/20241017160402_unique_codename.rb +8 -0
- data/mod/core/data/transform/20150724123438_update_file_and_image_cards.rb +1 -1
- data/mod/core/lib/tasks/card/export.rake +28 -0
- data/mod/core/lib/tasks/card/migrate.rake +3 -3
- data/mod/core/lib/tasks/card/seed.rake +2 -1
- data/mod/core/lib/tasks/card.rake +47 -16
- data/mod/core/set/all/admin.rb +1 -2
- data/mod/core/set/all/assign_attributes.rb +3 -2
- data/mod/core/set/all/codename.rb +7 -0
- data/mod/core/set/all/debug.rb +3 -3
- data/mod/core/set/all/initialize.rb +1 -0
- data/mod/core/set/all/states.rb +7 -6
- data/mod/core/set/all/type.rb +2 -0
- data/mod/core/set/all/utils.rb +0 -1
- data/mod/core/set/self/admin.rb +2 -1
- data/mod/core/set/self/autoname.rb +1 -1
- data/mod/core/set/self/mod.rb +4 -4
- data/mod/core/set/self/trash.rb +1 -1
- data/mod/core/set/type/mod.rb +18 -15
- data/mod/core/set_pattern/09_self.rb +4 -0
- data/mod/core/spec/set/all/trash_spec.rb +7 -7
- metadata +42 -29
@@ -6,6 +6,7 @@ module Cardio
|
|
6
6
|
# enhance standard rake command with some decko/card -specific options
|
7
7
|
class RakeCommand < CommandBase
|
8
8
|
def initialize gem, command, args=[]
|
9
|
+
super()
|
9
10
|
@command = command
|
10
11
|
@task = "#{gem}:#{command}"
|
11
12
|
@args = [args].flatten
|
@@ -33,8 +34,8 @@ module Cardio
|
|
33
34
|
def commands
|
34
35
|
task_cmd = "bundle exec rake #{@task}"
|
35
36
|
task_cmd += " -- #{escape_args(@args).join ' '}" unless @args.empty?
|
36
|
-
puts task_cmd
|
37
|
-
|
37
|
+
puts task_cmd.yellow
|
38
|
+
[task_cmd] if !@envs || @envs.empty?
|
38
39
|
|
39
40
|
# @envs.map do |env|
|
40
41
|
# "env RAILS_ENV=#{env} #{task_cmd}"
|
@@ -1,2 +1,2 @@
|
|
1
1
|
require "cardio/generators"
|
2
|
-
require File.expand_path("
|
2
|
+
require File.expand_path("../../generators/deck/deck_generator", __dir__)
|
data/lib/cardio/generators.rb
CHANGED
@@ -11,9 +11,9 @@ module Cardio
|
|
11
11
|
module ClassMethods
|
12
12
|
def source_root path=nil
|
13
13
|
if path
|
14
|
-
@
|
14
|
+
@source_root = path
|
15
15
|
else
|
16
|
-
@
|
16
|
+
@source_root ||= File.expand_path(
|
17
17
|
"../../generators/#{generator_name}/templates", __FILE__
|
18
18
|
)
|
19
19
|
end
|
@@ -33,7 +33,8 @@ module Cardio
|
|
33
33
|
# Override Rails namespace handling so we can put generators in `module Cardio`
|
34
34
|
def namespace name=nil
|
35
35
|
return super if name
|
36
|
-
|
36
|
+
|
37
|
+
@namespace ||= super.sub("cardio:", "")
|
37
38
|
end
|
38
39
|
end
|
39
40
|
delegate :banner_command, to: :class
|
@@ -10,6 +10,7 @@ module Cardio
|
|
10
10
|
|
11
11
|
def port
|
12
12
|
return unless lease_connection.table_exists? old_deck_table
|
13
|
+
|
13
14
|
rename_old_tables
|
14
15
|
lease_connection.execute "INSERT INTO #{table} (#{select_nonduplicate_versions})"
|
15
16
|
lease_connection.drop_table old_deck_table
|
@@ -25,6 +26,7 @@ module Cardio
|
|
25
26
|
def rename_old_tables
|
26
27
|
old_tables.each do |old_table_name|
|
27
28
|
next unless lease_connection.table_exists? old_table_name
|
29
|
+
|
28
30
|
lease_connection.rename_table old_table_name, table
|
29
31
|
end
|
30
32
|
end
|
data/lib/cardio/migration.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
module Cardio
|
4
|
+
# Base class for both schema and transform card migrations,
|
5
|
+
# which are found in <mod>/data/schema and <mod>/data/transform respectively
|
4
6
|
class Migration < ActiveRecord::Migration[6.1]
|
5
7
|
include Assumption
|
6
8
|
include Stamp
|
@@ -42,7 +42,6 @@ module Cardio
|
|
42
42
|
def ensure_installed
|
43
43
|
Card::Auth.as_bot do
|
44
44
|
Card::Cache.reset_all
|
45
|
-
puts "installing card mods".green
|
46
45
|
ensure_asset_lists do |hash|
|
47
46
|
puts "ensuring mod and asset cards"
|
48
47
|
Cardio.mods.each { |mod| ensure_asset_cards mod.ensure_card, hash }
|
@@ -108,7 +107,7 @@ module Cardio
|
|
108
107
|
|
109
108
|
# @return [True/False]
|
110
109
|
def gem_spec? spec
|
111
|
-
return unless spec
|
110
|
+
return false unless spec
|
112
111
|
|
113
112
|
spec.name.match?(/^card-mod-/) || spec.metadata["card-mod"].present?
|
114
113
|
end
|
data/lib/cardio/mod/dirs.rb
CHANGED
@@ -129,10 +129,8 @@ module Cardio
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
def each_subpath *subdirs
|
133
|
-
subpaths(*subdirs).each
|
134
|
-
yield mod_name, subpath
|
135
|
-
end
|
132
|
+
def each_subpath *subdirs, &block
|
133
|
+
subpaths(*subdirs).each(&block)
|
136
134
|
end
|
137
135
|
|
138
136
|
private
|
@@ -15,7 +15,7 @@ module Cardio
|
|
15
15
|
return yield unless @name
|
16
16
|
|
17
17
|
yield.select do |edible|
|
18
|
-
if @name.match?(
|
18
|
+
if @name.match?(/^:/)
|
19
19
|
explicit_codename_match? edible[:codename]
|
20
20
|
else
|
21
21
|
explicit_name_match? edible[:name]
|
@@ -24,7 +24,7 @@ module Cardio
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def explicit_codename_match? codename
|
27
|
-
codename && (codename == @name[1
|
27
|
+
codename && (codename == @name[1..])
|
28
28
|
end
|
29
29
|
|
30
30
|
def explicit_name_match? name
|
@@ -98,7 +98,7 @@ module Cardio
|
|
98
98
|
|
99
99
|
def mod_file mod, filename
|
100
100
|
unless (mod_file_path = mod.subpath "data/files", filename)
|
101
|
-
raise StandardError, "#{filename} not found. "\
|
101
|
+
raise StandardError, "#{filename} not found. " \
|
102
102
|
"Should be in data/files in #{mod.name} mod."
|
103
103
|
end
|
104
104
|
File.open mod_file_path
|
@@ -109,16 +109,18 @@ module Cardio
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def pod_types
|
112
|
-
if
|
112
|
+
if all_pod_types?
|
113
113
|
%i[real test]
|
114
114
|
elsif @pod_type
|
115
115
|
[@pod_type]
|
116
|
-
elsif Rails.env.test?
|
117
|
-
%i[real test]
|
118
116
|
else
|
119
117
|
[:real]
|
120
118
|
end
|
121
119
|
end
|
120
|
+
|
121
|
+
def all_pod_types?
|
122
|
+
@pod_type == :all || (Rails.env.test? && !@pod_type)
|
123
|
+
end
|
122
124
|
end
|
123
125
|
end
|
124
126
|
end
|
data/lib/cardio/mod/eat.rb
CHANGED
@@ -19,13 +19,13 @@ module Cardio
|
|
19
19
|
@verbose = !verbose.nil?
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def run
|
23
23
|
handle_up do
|
24
24
|
edibles.each do |edible|
|
25
25
|
track edible do
|
26
26
|
current_user edible.delete(:user)
|
27
27
|
time_machine edible.delete(:time) do
|
28
|
-
Card.ensure edible
|
28
|
+
Card.ensure! edible
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -35,10 +35,10 @@ module Cardio
|
|
35
35
|
private
|
36
36
|
|
37
37
|
# if output mod given,
|
38
|
-
def handle_up
|
38
|
+
def handle_up &block
|
39
39
|
Card::Cache.reset_all
|
40
40
|
Card::Mailer.perform_deliveries = false
|
41
|
-
Card::Auth.as_bot
|
41
|
+
Card::Auth.as_bot(&block)
|
42
42
|
:success
|
43
43
|
rescue StandardError => e
|
44
44
|
e.message
|
@@ -76,7 +76,8 @@ module Cardio
|
|
76
76
|
case value
|
77
77
|
when /^[+-]\d+$/
|
78
78
|
# plus or minus an integer (safe to eval)
|
79
|
-
eval "#{Time.now.to_i} #{value}",
|
79
|
+
eval "#{Time.now.to_i} #{value}", # 1741296981 +1 (e.g.)
|
80
|
+
binding, __FILE__, __LINE__ - 1
|
80
81
|
when Integer
|
81
82
|
value
|
82
83
|
else
|
@@ -24,9 +24,10 @@ module Cardio
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def rewrite_tmp_files?
|
27
|
-
return @
|
27
|
+
return @rewrite_tmp_files if defined? @rewrite_tmp_files
|
28
28
|
|
29
|
-
@
|
29
|
+
@rewrite_tmp_files =
|
30
|
+
!(Rails.env.production? && Card.paths["tmp/set"].existent.first)
|
30
31
|
end
|
31
32
|
|
32
33
|
def write_tmp_file from_file, to_file, const_parts
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module Cardio
|
2
2
|
class Mod
|
3
3
|
class Loader
|
4
|
+
# arguably overkill, the set pattern loader makes set patterns use
|
5
|
+
# directory/file-aware loading much as set patterns do. Since they are so
|
6
|
+
# rarely added, this optimization should probably be deprecated
|
4
7
|
class SetPatternLoader < Loader
|
5
8
|
def template_class
|
6
9
|
SetPatternTemplate
|
@@ -17,6 +20,7 @@ module Cardio
|
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
23
|
+
# templates for set pattern modules
|
20
24
|
class SetPatternTemplate < ModuleTemplate
|
21
25
|
def to_const
|
22
26
|
return Object if simple_load?
|
@@ -28,9 +28,9 @@ module Cardio
|
|
28
28
|
format_name = Regexp.last_match(1)
|
29
29
|
format_name = format_name.blank? ? nil : format_name.to_sym
|
30
30
|
"module #{module_name format_name}; " \
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
"module_parent.send :register_set_format, " \
|
32
|
+
"#{format_class format_name}, self; " \
|
33
|
+
"extend Card::Set::AbstractFormat"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -92,7 +92,7 @@ module Cardio
|
|
92
92
|
def pattern_label *anchors
|
93
93
|
anchor_count = pattern_class.anchor_parts_count
|
94
94
|
label = pattern_class.label(pattern_anchor(*anchors, anchor_count))
|
95
|
-
remainder = anchors[anchor_count
|
95
|
+
remainder = anchors[anchor_count..]
|
96
96
|
label += " (#{remainder.join ', '})" if remainder.any?
|
97
97
|
label
|
98
98
|
end
|
@@ -125,6 +125,16 @@ module Cardio
|
|
125
125
|
def postamble
|
126
126
|
"end;" * (@modules.size + 3)
|
127
127
|
end
|
128
|
+
|
129
|
+
# [set_registration, ends].compact.join "\n"
|
130
|
+
# end
|
131
|
+
#
|
132
|
+
# def set_registration
|
133
|
+
# "Card::Set.register_set self" unless helper_module?
|
134
|
+
# end
|
135
|
+
#
|
136
|
+
# def ends
|
137
|
+
# end
|
128
138
|
end
|
129
139
|
end
|
130
140
|
end
|
data/lib/cardio/mod/loader.rb
CHANGED
@@ -28,7 +28,7 @@ module Cardio
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def load_initializers
|
31
|
-
Cardio.config.paths["late/initializers"].existent.
|
31
|
+
Cardio.config.paths["late/initializers"].existent.each do |init|
|
32
32
|
load init
|
33
33
|
end
|
34
34
|
end
|
@@ -60,7 +60,7 @@ module Cardio
|
|
60
60
|
|
61
61
|
def parts_from_path path
|
62
62
|
# remove file extension and number prefixes
|
63
|
-
parts = path.gsub(/\.rb
|
63
|
+
parts = path.gsub(/\.rb$/, "").gsub(%r{(?<=\A|/)\d+_}, "").split(File::SEPARATOR)
|
64
64
|
parts.map(&:camelize)
|
65
65
|
end
|
66
66
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Cardio
|
2
|
+
class Mod
|
3
|
+
class Sow
|
4
|
+
# Fetch sow data from remote
|
5
|
+
module RemoteSource
|
6
|
+
def remote_source
|
7
|
+
@remote_source ||=
|
8
|
+
if @remote
|
9
|
+
raise Card::Error::NotFound, "must specify name (-n)" unless @name
|
10
|
+
|
11
|
+
URI.join(@remote, "/#{@name.cardname.url_key}/", "pod.yml")
|
12
|
+
else
|
13
|
+
@url
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def pod_from_url
|
18
|
+
parsed_yaml = parse_pod_yaml yaml_from_url
|
19
|
+
Array.wrap(parsed_yaml)
|
20
|
+
rescue Psych::SyntaxError
|
21
|
+
raise "Url #{@remote_source} provided invalid yaml"
|
22
|
+
end
|
23
|
+
|
24
|
+
def yaml_from_url
|
25
|
+
@yaml_from_url ||= URI.open(@remote_source).read
|
26
|
+
rescue OpenURI::HTTPError => e
|
27
|
+
raise "#{@remote_source} not available\n#{e}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/cardio/mod/sow.rb
CHANGED
@@ -7,25 +7,25 @@ module Cardio
|
|
7
7
|
class Sow
|
8
8
|
include YamlDump
|
9
9
|
include CardSource
|
10
|
+
include RemoteSource
|
10
11
|
|
11
12
|
def initialize **args
|
12
13
|
@mod = args[:mod]
|
13
14
|
@name = args[:name]
|
14
15
|
@cql = args[:cql]
|
15
16
|
@url = args[:url]
|
17
|
+
@remote = args[:remote]
|
16
18
|
@podtype = args[:podtype] || (Rails.env.test? ? :test : :real)
|
17
19
|
@items = args[:items]
|
18
20
|
@field_tags = args[:field_tags]
|
19
21
|
end
|
20
22
|
|
21
23
|
# if output mod given,
|
22
|
-
def
|
24
|
+
def run
|
23
25
|
Card::Cache.reset_all
|
24
26
|
@mod ? dump(output_hash) : puts(new_data.to_yaml.yellow)
|
25
27
|
:success
|
26
|
-
rescue Card::Error::NotFound => e
|
27
|
-
e.message
|
28
|
-
rescue JSON::ParserError => e
|
28
|
+
rescue Card::Error::NotFound, JSON::ParserError => e
|
29
29
|
e.message
|
30
30
|
end
|
31
31
|
|
@@ -42,8 +42,11 @@ module Cardio
|
|
42
42
|
|
43
43
|
# @return [Array <Hash>]
|
44
44
|
def new_data
|
45
|
-
@new_data ||=
|
46
|
-
|
45
|
+
@new_data ||= fetch_new_data
|
46
|
+
end
|
47
|
+
|
48
|
+
def fetch_new_data
|
49
|
+
remote_source ? pod_from_url : new_data_from_cards
|
47
50
|
end
|
48
51
|
|
49
52
|
def merge_data
|
@@ -72,11 +75,8 @@ module Cardio
|
|
72
75
|
|
73
76
|
def old_data
|
74
77
|
return unless File.exist? filename
|
75
|
-
parse_pod_yaml File.read(filename)
|
76
|
-
end
|
77
78
|
|
78
|
-
|
79
|
-
parse_pod_yaml URI.open(@url).read
|
79
|
+
parse_pod_yaml File.read(filename)
|
80
80
|
end
|
81
81
|
|
82
82
|
def parse_pod_yaml pod_yaml
|
data/lib/cardio/railtie.rb
CHANGED
data/lib/cardio/script_loader.rb
CHANGED
@@ -46,7 +46,7 @@ module Cardio
|
|
46
46
|
|
47
47
|
def in_application_subdirectory? path=Pathname.new(Dir.pwd)
|
48
48
|
File.exist?(File.join(path, script)) ||
|
49
|
-
!path.root? && in_application_subdirectory?(path.parent)
|
49
|
+
(!path.root? && in_application_subdirectory?(path.parent))
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
data/lib/cardio/seed.rb
CHANGED
data/lib/cardio/utils.rb
CHANGED
data/lib/cardio/version.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
module Cardio
|
4
|
+
# handle version numbers for releases
|
4
5
|
module Version
|
5
6
|
class << self
|
6
7
|
CARD_MINOR = { 0 => 90, 1 => 1000 }.freeze # can remove and hardcode after 1.0
|
7
8
|
|
8
9
|
def release
|
9
|
-
@
|
10
|
+
@release ||= File.read(File.expand_path("../../VERSION", __dir__)).strip
|
10
11
|
end
|
11
12
|
|
12
13
|
def card_release
|
data/lib/cardio.rb
CHANGED
@@ -8,6 +8,9 @@ ActiveSupport.on_load :after_card do
|
|
8
8
|
Cardio::Mod.load
|
9
9
|
end
|
10
10
|
|
11
|
+
# Cardio is a quick loading module and is at the heart (get it?) of
|
12
|
+
# card loading and configuration because it is useful long before the Card class is
|
13
|
+
# (or card objects are)
|
11
14
|
module Cardio
|
12
15
|
extend Delaying
|
13
16
|
|
@@ -8,6 +8,7 @@ en:
|
|
8
8
|
core_error_cant_alter: can't alter this type; %{name} cards still exist
|
9
9
|
core_error_cant_change_errors: "of %{name} can't be changed; errors creating new %{type_id}: %{error_messages}"
|
10
10
|
core_error_code_in_use: codename %{codename} already in use
|
11
|
+
core_codename_must_be_simple: only simple cards can have codenames
|
11
12
|
core_error_hard_templated: can't be changed because %{name} is hard templated to %{type_name}
|
12
13
|
core_error_indestructible: "%{name} is an indestructible rule"
|
13
14
|
core_error_invalid_character_in_cardtype: "may not contain any of the following characters: %{banned}"
|
@@ -3,7 +3,7 @@ class MoveRevisionsToActions < Cardio::Migration::Schema
|
|
3
3
|
belongs_to :tmp_card, foreign_key: :card_id
|
4
4
|
self.table_name = "card_revisions"
|
5
5
|
def self.delete_cardless
|
6
|
-
left_join = "LEFT JOIN cards "\
|
6
|
+
left_join = "LEFT JOIN cards " \
|
7
7
|
"ON card_revisions.card_id = cards.id"
|
8
8
|
TmpRevision.joins(left_join).where("cards.id IS NULL").delete_all
|
9
9
|
end
|
@@ -55,7 +55,7 @@ class MoveRevisionsToActions < Cardio::Migration::Schema
|
|
55
55
|
|
56
56
|
def create_create_action rev
|
57
57
|
TmpAction.connection.execute(
|
58
|
-
"INSERT INTO card_actions (id, card_id, card_act_id, action_type) VALUES "\
|
58
|
+
"INSERT INTO card_actions (id, card_id, card_act_id, action_type) VALUES " \
|
59
59
|
"('#{rev.id}', '#{rev.card_id}', '#{rev.id}', 0)")
|
60
60
|
if (tmp_card = rev.tmp_card)
|
61
61
|
TmpChange.connection.execute "INSERT INTO card_changes (card_action_id, field, value) VALUES
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
class UniqueCodename < Cardio::Migration::Schema
|
4
4
|
def up
|
5
|
+
remove_blank_codenames
|
5
6
|
remove_index :cards, name: "cards_codename_index"
|
6
7
|
add_index :cards, :codename, name: "cards_codename_index", unique: true
|
7
8
|
end
|
@@ -10,4 +11,11 @@ class UniqueCodename < Cardio::Migration::Schema
|
|
10
11
|
remove_index :cards, name: "cards_codename_index"
|
11
12
|
add_index :cards, :codename, name: "cards_codename_index"
|
12
13
|
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def remove_blank_codenames
|
18
|
+
Cardio::Record.connection
|
19
|
+
.execute "UPDATE cards SET codename = null where codename = ''"
|
20
|
+
end
|
13
21
|
end
|
@@ -88,7 +88,7 @@ class UpdateFileAndImageCards < Cardio::Migration::Transform
|
|
88
88
|
def get_new_file_name filename
|
89
89
|
original_filename = filename
|
90
90
|
if filename =~ /^(icon|small|medium|large|original)-([^.]+).(.+)$/
|
91
|
-
filename = "#{Regexp.last_match(2)}-#{Regexp.last_match(1)}."\
|
91
|
+
filename = "#{Regexp.last_match(2)}-#{Regexp.last_match(1)}." \
|
92
92
|
"#{Regexp.last_match(3)}"
|
93
93
|
end
|
94
94
|
filename = filename.downcase
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "csv"
|
2
|
+
|
3
|
+
namespace :card do
|
4
|
+
namespace :export do
|
5
|
+
desc "export all cards to csv"
|
6
|
+
task csv: :environment do
|
7
|
+
parse_options :csv do
|
8
|
+
add_opt :f, :file, "file name"
|
9
|
+
end
|
10
|
+
filename = options[:file] || "cards.csv"
|
11
|
+
puts "Exporting all card data to #{filename}..."
|
12
|
+
File.write(filename) { |f| f.write to_csv }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def to_csv
|
20
|
+
attributes = %w[id name codename type content]
|
21
|
+
|
22
|
+
CSV.generate(headers: true) do |csv|
|
23
|
+
csv << attributes
|
24
|
+
Card.all.each do |card|
|
25
|
+
csv << attributes.map { |attr| card.send(attr) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
namespace :card do
|
3
2
|
desc "migrate structure and cards"
|
4
3
|
task migrate: :environment do
|
@@ -47,6 +46,7 @@ namespace :card do
|
|
47
46
|
|
48
47
|
task port: :environment do
|
49
48
|
puts "porting"
|
49
|
+
ENV["NO_CARD_LOAD"] = "true"
|
50
50
|
Cardio::Migration.port_all
|
51
51
|
end
|
52
52
|
|
@@ -60,7 +60,7 @@ namespace :card do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def version
|
63
|
-
ENV["VERSION"]
|
63
|
+
ENV["VERSION"]&.to_i
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -109,7 +109,7 @@ end
|
|
109
109
|
# FIXME: too general
|
110
110
|
# intent is to find Record classes; this gets a lot more.
|
111
111
|
def load_mod_lib
|
112
|
-
Dir.glob(Cardio.root.join("mod/*/lib/*.rb")).
|
112
|
+
Dir.glob(Cardio.root.join("mod/*/lib/*.rb")).each { |x| require x }
|
113
113
|
end
|
114
114
|
|
115
115
|
def without_dumping
|
@@ -34,6 +34,7 @@ namespace :card do
|
|
34
34
|
|
35
35
|
# desc "dump db to fixtures"
|
36
36
|
task dump: :environment do
|
37
|
+
puts "dumping".green
|
37
38
|
Card::Cache.reset_all
|
38
39
|
Cardio::Seed.dump
|
39
40
|
end
|
@@ -54,7 +55,7 @@ namespace :card do
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def invoke_card_task task
|
57
|
-
puts "invoking: #{task}"
|
58
|
+
puts "invoking: #{task}"
|
58
59
|
Rake::Task["card:#{task}"].invoke
|
59
60
|
end
|
60
61
|
end
|