Class: Funicular::Plugin::Registry
- Inherits:
-
Object
- Object
- Funicular::Plugin::Registry
- Defined in:
- lib/funicular/plugin.rb
Instance Attribute Summary collapse
-
#rails_root ⇒ Object
readonly
Returns the value of attribute rails_root.
Instance Method Summary collapse
- #asset_entries ⇒ Object
-
#initialize(rails_root) ⇒ Registry
constructor
A new instance of Registry.
- #local_source_files ⇒ Object
- #specs ⇒ Object
- #sync_assets ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(rails_root) ⇒ Registry
Returns a new instance of Registry.
73 74 75 |
# File 'lib/funicular/plugin.rb', line 73 def initialize(rails_root) @rails_root = Pathname(rails_root). end |
Instance Attribute Details
#rails_root ⇒ Object (readonly)
Returns the value of attribute rails_root.
71 72 73 |
# File 'lib/funicular/plugin.rb', line 71 def rails_root @rails_root end |
Instance Method Details
#asset_entries ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/funicular/plugin.rb', line 99 def asset_entries validated_specs.flat_map do |spec| safe_name = Plugin.safe_name(spec.name) css = spec.css_paths.map { |path| File.basename(path) } css.map { |file| { "type" => "css", "logical_path" => "funicular/plugins/#{safe_name}/#{file}" } } end end |
#local_source_files ⇒ Object
95 96 97 |
# File 'lib/funicular/plugin.rb', line 95 def local_source_files validated_specs.flat_map { |spec| spec.project.source_files } end |
#specs ⇒ Object
77 78 79 |
# File 'lib/funicular/plugin.rb', line 77 def specs @specs ||= funicular_specs.map { |spec| Spec.new(spec) } end |
#sync_assets ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/funicular/plugin.rb', line 81 def sync_assets build_root = rails_root.join(BUILD_DIR) FileUtils.mkdir_p(build_root) validated_specs.each do |spec| target_dir = build_root.join(Plugin.safe_name(spec.name)) FileUtils.rm_rf(target_dir) FileUtils.mkdir_p(target_dir) spec.css_paths.each do |path| FileUtils.cp(path, target_dir.join(File.basename(path))) if path.exist? end end end |
#validate! ⇒ Object
107 108 109 |
# File 'lib/funicular/plugin.rb', line 107 def validate! specs.each(&:validate!) end |