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

#assets_pathObject



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

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

#content?Boolean

Returns:

  • (Boolean)


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

def content?
  assets_path
end

#folder_group_cardObject



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

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



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

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

#item_cards(_args = {}) ⇒ Object



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

def item_cards _args={}
  local_group_cards
end

#item_names(_args = {}) ⇒ Object



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

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

#load_manifestObject



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

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



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

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

#local_group_nameObject



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

def local_group_name
  "local"
end

#local_manifest_group_cardsObject



36
37
38
39
40
41
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/mod_assets.rb', line 36

def local_manifest_group_cards
  manifest.map do |group_name, config|
    next if remote_group?(group_name, config)
    new_local_manifest_group_card group_name
  end.compact
end

#manifestObject



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

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

#manifest_exists?Boolean

Returns:

  • (Boolean)


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

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

#manifest_group_items(group_name) ⇒ Object



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

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

#manifest_group_minimize?(group_name) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#manifest_pathObject



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

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

#manifest_updated_atObject



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

def manifest_updated_at
  return unless manifest_exists?

  File.mtime(manifest_path)
end

#modObject



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

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

#mod_nameObject



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

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

#no_action?Boolean

Returns:

  • (Boolean)


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

def no_action?
  new? && !assets_path
end

#remote_group?(name, _config) ⇒ Boolean

Returns:

  • (Boolean)


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

def remote_group? name, _config
  name == "remote" # || config["remote"]
end

#remote_group_urlsObject



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

def remote_group_urls
  return unless manifest_exists?
  manifest_group_items "remote"
end

#source_changed?(since:) ⇒ Boolean

Returns:

  • (Boolean)


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

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



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

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