Class: Bashly::RenderSource
- Inherits:
-
Object
- Object
- Bashly::RenderSource
- Extended by:
- AssetHelper
- Defined in:
- lib/bashly/render_source.rb
Instance Attribute Summary collapse
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
Class Method Summary collapse
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(selector) ⇒ RenderSource
constructor
A new instance of RenderSource.
- #internal? ⇒ Boolean
- #path ⇒ Object
- #readme ⇒ Object
- #render(target, show: nil) ⇒ Object
- #summary ⇒ Object
Methods included from AssetHelper
Constructor Details
#initialize(selector) ⇒ RenderSource
Returns a new instance of RenderSource.
24 25 26 |
# File 'lib/bashly/render_source.rb', line 24 def initialize(selector) @selector = selector end |
Instance Attribute Details
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
3 4 5 |
# File 'lib/bashly/render_source.rb', line 3 def selector @selector end |
Class Method Details
.internal ⇒ Object
8 9 10 11 12 13 |
# File 'lib/bashly/render_source.rb', line 8 def internal @internal ||= internal_dirs.to_h do |dir| selector = File.basename(dir).to_sym [selector, new(selector)] end end |
.internal_dirs ⇒ Object
15 16 17 |
# File 'lib/bashly/render_source.rb', line 15 def internal_dirs @internal_dirs ||= Dir["#{internal_root}/*"].select { |x| File.directory? x } end |
.internal_root ⇒ Object
19 20 21 |
# File 'lib/bashly/render_source.rb', line 19 def internal_root asset('libraries/render') end |
Instance Method Details
#exist? ⇒ Boolean
41 42 43 |
# File 'lib/bashly/render_source.rb', line 41 def exist? Dir.exist? path end |
#internal? ⇒ Boolean
33 34 35 |
# File 'lib/bashly/render_source.rb', line 33 def internal? selector.is_a? Symbol end |
#path ⇒ Object
37 38 39 |
# File 'lib/bashly/render_source.rb', line 37 def path internal? ? "#{internal_root}/#{selector}" : selector end |
#readme ⇒ Object
49 50 51 |
# File 'lib/bashly/render_source.rb', line 49 def readme File.read readme_file if File.exist? readme_file end |
#render(target, show: nil) ⇒ Object
28 29 30 31 |
# File 'lib/bashly/render_source.rb', line 28 def render(target, show: nil) context = RenderContext.new source: path, target: target, show: show context.instance_eval render_script end |
#summary ⇒ Object
45 46 47 |
# File 'lib/bashly/render_source.rb', line 45 def summary File.readlines(summary_file)[0].chomp end |