Module: Card::Set::Abstract::ModAssets

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb

Overview

Set: Abstract (ModAssets)

Defined Under Namespace

Modules: HtmlFormat

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset

Methods included from I18nScope

#scope

Methods included from Registrar

#extended, #finalize_load, #process_base_modules, #register_set

Methods included from Helpers

#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name

Methods included from Card::Set::AdvancedApi

#assign_type, #attachment, #define_set_from_error, #ensure_set, #setting_opts, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/mod/assets/set/abstract/mod_assets.rb"; end

Instance Method Details

#asset_input_needs_refresh?Boolean

Returns:

  • (Boolean)


141
142
143
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 141

def asset_input_needs_refresh?
  !asset_input_updated_at || source_changed?(since: asset_input_updated_at)
end

#asset_input_updated_atObject



145
146
147
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 145

def asset_input_updated_at
  asset_input_card&.updated_at
end

#assets_pathObject



64
65
66
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 64

def assets_path
  @assets_path ||= mod&.subpath "assets", subpath
end

#content?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 47

def content?
  assets_path
end

#folder_group_cardObject



31
32
33
34
35
36
37
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 31

def folder_group_card
  return unless assets_path

  card = new_assets_group_card local_group_name, folder_group_type_id
  card.assets_path = assets_path
  card
end

#group_card_args(field, type_id, name) ⇒ Object



112
113
114
115
116
117
118
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 112

def group_card_args field, type_id, name
  {
    type_id: type_id,
    codename: "#{mod_name}_group__#{field}",
    name: name
  }
end

#item_cards(_args = {}) ⇒ Object



13
14
15
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 13

def item_cards _args={}
  local_group_cards
end

#item_names(_args = {}) ⇒ Object



17
18
19
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 17

def item_names _args={}
  local_group_cards.map(&:name)
end

#load_manifestObject



93
94
95
96
97
98
99
100
101
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 93

def load_manifest
  return unless manifest_exists?

  manifest = YAML.load_file manifest_path
  return {} unless manifest # blank manifest

  validate_manifest manifest
  manifest
end

#local_group_cardsObject

group cards that don’t refer to remote sources



22
23
24
25
26
27
28
29
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 22

def local_group_cards
  @local_group_cards ||=
    if manifest_exists?
      local_manifest_group_cards
    else
      [folder_group_card].compact
    end
end

#local_group_nameObject



72
73
74
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 72

def local_group_name
  "local"
end

#local_manifest_group_cardsObject



39
40
41
42
43
44
45
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 39

def local_manifest_group_cards
  manifest.map do |group_name, _config|
    next if remote_group? group_name

    new_local_manifest_group_card group_name
  end.compact
end

#manifestObject



88
89
90
91
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 88

def manifest
  # FIXME: sometimes this needs to get cleared!
  @manifest ||= load_manifest
end

#manifest_exists?Boolean

Returns:

  • (Boolean)


59
60
61
62
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 59

def manifest_exists?
  @manifest_exists = !manifest_path.nil? if @manifest_exists.nil?
  @manifest_exists
end

#manifest_group_items(group_name) ⇒ Object



80
81
82
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 80

def manifest_group_items group_name
  manifest&.dig(group_name, "items") || []
end

#manifest_group_minimize?(group_name) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 84

def manifest_group_minimize? group_name
  manifest.dig group_name, "minimize"
end

#manifest_pathObject



68
69
70
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 68

def manifest_path
  @manifest_path ||= mod&.subpath "assets", subpath, "manifest.yml"
end

#manifest_updated_atObject



131
132
133
134
135
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 131

def manifest_updated_at
  return unless manifest_exists?

  File.mtime(manifest_path)
end

#modObject



55
56
57
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 55

def mod
  @mod ||= Cardio::Mod.fetch mod_name
end

#mod_nameObject



51
52
53
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 51

def mod_name
  left&.codename.to_s.sub(/^mod_/, "")
end

#no_action?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 137

def no_action?
  new? && !assets_path
end

#remote_group?(name) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 76

def remote_group? name
  name == "remote"
end

#source_changed?(since:) ⇒ Boolean

Returns:

  • (Boolean)


120
121
122
123
124
125
126
127
128
129
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 120

def source_changed? since:
  source_updates =
    if manifest_exists?
      [manifest_updated_at, local_manifest_group_cards.map(&:last_file_change)].flatten
    else
      folder_group_card&.paths&.map { |path| File.mtime(path) }
    end

  source_updates.present? && (source_updates.max > since)
end

#validate_manifest(manifest) ⇒ Object



103
104
105
106
107
108
109
110
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 103

def validate_manifest manifest
  if (remote_index = manifest.keys.find_index("remote")) && remote_index.positive?
    raise_manifest_error "only the first group can be a remote group"
  end
  manifest.each do |name, config|
    validate_manifest_item name, config
  end
end