Class: QEDProject::Libraries::Base
- Inherits:
-
Object
- Object
- QEDProject::Libraries::Base
- Includes:
- Helpers
- Defined in:
- lib/qedproject/libraries/base.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.libs ⇒ Object
Returns the value of attribute libs.
Instance Attribute Summary collapse
-
#lib_root ⇒ Object
Returns the value of attribute lib_root.
-
#project ⇒ Object
Returns the value of attribute project.
-
#template_root ⇒ Object
Returns the value of attribute template_root.
Class Method Summary collapse
-
.library(name) ⇒ Object
Support for DSL, for setting the library name when creating the adapter.
-
.set_css_files(files) ⇒ Object
convenience method for the DSL for setting CSS files.
-
.set_image_files(files) ⇒ Object
convenience method for the DSL for setting image files.
- .set_js_files(files) ⇒ Object
Instance Method Summary collapse
- #copy_css ⇒ Object
- #copy_images ⇒ Object
- #copy_js ⇒ Object
- #generate! ⇒ Object
-
#initialize(project) ⇒ Base
constructor
A new instance of Base.
Methods included from Helpers
Constructor Details
#initialize(project) ⇒ Base
Returns a new instance of Base.
73 74 75 76 77 |
# File 'lib/qedproject/libraries/base.rb', line 73 def initialize(project) @project = project @lib_root = File.join(@project.vendor_root, self.library.to_s) @template_root = File.join(@lib_root, "templates") end |
Class Attribute Details
.libs ⇒ Object
Returns the value of attribute libs.
10 11 12 |
# File 'lib/qedproject/libraries/base.rb', line 10 def libs @libs end |
Instance Attribute Details
#lib_root ⇒ Object
Returns the value of attribute lib_root.
7 8 9 |
# File 'lib/qedproject/libraries/base.rb', line 7 def lib_root @lib_root end |
#project ⇒ Object
Returns the value of attribute project.
7 8 9 |
# File 'lib/qedproject/libraries/base.rb', line 7 def project @project end |
#template_root ⇒ Object
Returns the value of attribute template_root.
7 8 9 |
# File 'lib/qedproject/libraries/base.rb', line 7 def template_root @template_root end |
Class Method Details
.library(name) ⇒ Object
Support for DSL, for setting the library name when creating the adapter. Adds the library and class to QEDProject::Libraries::Base.libs hash and also creates a getter method on the adapter instance
16 17 18 19 20 21 22 23 24 |
# File 'lib/qedproject/libraries/base.rb', line 16 def library(name) QEDProject::Libraries::Base.libs ||= {} QEDProject::Libraries::Base.libs[name] = self class_eval do define_method :library do name end end end |
.set_css_files(files) ⇒ Object
convenience method for the DSL for setting CSS files
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/qedproject/libraries/base.rb', line 42 def set_css_files(files) # define class method to get the data out m = class << self; self; end m.send :define_method, :css_files do files end class_eval do define_method :css_files do files end end end |
.set_image_files(files) ⇒ Object
convenience method for the DSL for setting image files.
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/qedproject/libraries/base.rb', line 58 def set_image_files(files) m = class << self; self; end m.send :define_method, :image_files do files end class_eval do define_method :image_files do files end end end |
.set_js_files(files) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/qedproject/libraries/base.rb', line 26 def set_js_files(files) # define class method m = class << self; self; end m.send :define_method, :js_files do files end # define instance method class_eval do define_method :js_files do files end end end |
Instance Method Details
#copy_css ⇒ Object
91 92 93 94 95 |
# File 'lib/qedproject/libraries/base.rb', line 91 def copy_css self.css_files.each do |lib| ::FileUtils.cp_r File.join(self.lib_root, lib), File.join(self.project.path, self.project.css_path), :verbose => self.project.verbose end end |
#copy_images ⇒ Object
85 86 87 88 89 |
# File 'lib/qedproject/libraries/base.rb', line 85 def copy_images self.image_files.each do |lib| ::FileUtils.cp_r File.join(self.lib_root, lib), File.join(self.project.path, self.project.images_path), :verbose => self.project.verbose end end |
#copy_js ⇒ Object
97 98 99 100 101 |
# File 'lib/qedproject/libraries/base.rb', line 97 def copy_js self.js_files.each do |lib| ::FileUtils.cp_r File.join(self.lib_root, lib), File.join(self.project.path, self.project.js_path), :verbose => self.project.verbose end end |
#generate! ⇒ Object
79 80 81 82 83 |
# File 'lib/qedproject/libraries/base.rb', line 79 def generate! self.copy_js if self.respond_to?(:js_files) && self.js_files.any? self.copy_css if self.respond_to?(:css_files) && self.css_files.any? self.copy_images if self.respond_to?(:image_files) && self.image_files.any? end |