Module: Card::Loader
- Defined in:
- lib/card/loader.rb
Class Method Summary collapse
- .load_chunks ⇒ Object
- .load_layouts ⇒ Object
- .load_mods ⇒ Object
- .mod_dirs ⇒ Object
- .update_machine_output_hack ⇒ Object
- .update_script_output ⇒ Object
- .update_style_output ⇒ Object
Class Method Details
.load_chunks ⇒ Object
65 66 67 68 69 |
# File 'lib/card/loader.rb', line 65 def load_chunks mod_dirs.each do |mod| load_dir "#{mod}/chunk/*.rb" end end |
.load_layouts ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/card/loader.rb', line 71 def load_layouts mod_dirs.inject({}) do |hash, mod| dirname = "#{mod}/layout" if File.exist? dirname Dir.foreach(dirname) do |filename| next if filename =~ /^\./ hash[filename.gsub /\.html$/, ''] = File.read([dirname, filename].join('/')) end end hash end end |
.load_mods ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/card/loader.rb', line 19 def load_mods load_set_patterns load_formats load_sets update_machine_output_hack if ENV['RAILS_ENV'] == 'development' end |
.mod_dirs ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/card/loader.rb', line 85 def mod_dirs @@mod_dirs ||= begin Card.paths['mod'].existent.map do |dirname| Dir.entries(dirname).sort.map do |filename| "#{dirname}/#{filename}" if filename !~ /^\./ end.compact end.flatten.compact end end |
.update_machine_output_hack ⇒ Object
27 28 29 30 |
# File 'lib/card/loader.rb', line 27 def update_machine_output_hack update_script_output update_style_output end |
.update_script_output ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/card/loader.rb', line 32 def update_script_output script = Card['*all+*script'] return unless (mtime_output = script.machine_output_card.updated_at) ['wagn_mod.js.coffee', 'wagn.js.coffee', 'script_card_menu.js.coffee'].each do |name| mtime_file = File.mtime( "#{Cardio.gem_root}/mod/03_machines/lib/javascript/#{name}" ) if mtime_file > mtime_output script.update_machine_output break end end end |
.update_style_output ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/card/loader.rb', line 47 def update_style_output style = Card['*all+*style'] return unless (mtime_output = style.machine_output_card.updated_at) style.machine_input_card.item_cards.each do |i_card| next unless i_card.codename %w(03_machines 06_bootstrap).each do |mod| style_dir = "#{Cardio.gem_root}/mod/#{mod}/lib/stylesheets" file_path = "#{style_dir}/#{i_card.codename}.scss" next unless File.exist? file_path mtime_file = File.mtime file_path if mtime_file > mtime_output style.update_machine_output break end end end end |