Class: QEDProject::Libraries::Base
- Inherits:
-
Object
- Object
- QEDProject::Libraries::Base
- Includes:
- Helpers
- Defined in:
- lib/qedproject/libraries/base.rb
Direct Known Subclasses
Angular, Backbone, Ember, JQuery, Jquerymobile, Knockout, Mustache, Skeleton
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
-
.depends_on(libraries) ⇒ Object
DSL again, this lets you specify dependencies.
-
.library(name, base_path = __FILE__) ⇒ 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
for the DSL, creates both an instance method and a class instance method.
Instance Method Summary collapse
- #copy_css ⇒ Object
- #copy_images ⇒ Object
- #copy_js ⇒ Object
- #generate! ⇒ Object
-
#initialize(project) ⇒ Base
constructor
A new instance of Base.
- #render_template(source, dest) ⇒ Object
Methods included from Helpers
#cp, #cp_r, #create_file, #mkdir_p, #render_template_to_file
Constructor Details
#initialize(project) ⇒ Base
Returns a new instance of Base.
90 91 92 93 94 95 |
# File 'lib/qedproject/libraries/base.rb', line 90 def initialize(project) @project = project @lib_root = File.join(self.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
.depends_on(libraries) ⇒ Object
DSL again, this lets you specify dependencies. Creates a dependencies class instance method we can use later.
34 35 36 37 38 39 |
# File 'lib/qedproject/libraries/base.rb', line 34 def depends_on(libraries) m = class << self; self; end m.send :define_method, :dependencies do libraries end end |
.library(name, base_path = __FILE__) ⇒ 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 25 26 27 28 29 |
# File 'lib/qedproject/libraries/base.rb', line 16 def library(name, base_path = __FILE__) QEDProject::Libraries::Base.libs ||= {} QEDProject::Libraries::Base.libs[name] = self class_eval do define_method :library do name end define_method :vendor_root do File.("../../../../vendor", base_path) end end end |
.set_css_files(files) ⇒ Object
convenience method for the DSL for setting CSS files
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/qedproject/libraries/base.rb', line 59 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.
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/qedproject/libraries/base.rb', line 75 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
for the DSL, creates both an instance method and a class instance method
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/qedproject/libraries/base.rb', line 43 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
109 110 111 112 113 |
# File 'lib/qedproject/libraries/base.rb', line 109 def copy_css self.css_files.each do |lib| 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
103 104 105 106 107 |
# File 'lib/qedproject/libraries/base.rb', line 103 def copy_images self.image_files.each do |lib| 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
115 116 117 118 119 |
# File 'lib/qedproject/libraries/base.rb', line 115 def copy_js self.js_files.each do |lib| 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
97 98 99 100 101 |
# File 'lib/qedproject/libraries/base.rb', line 97 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 |
#render_template(source, dest) ⇒ Object
121 122 123 124 125 126 127 128 |
# File 'lib/qedproject/libraries/base.rb', line 121 def render_template(source, dest) if self.project.no_overwrite && File.exist?(dest) puts "Skipping #{dest}" if self.project.verbose else render_template_to_file source, dest, binding puts "Created #{dest}" if self.project.verbose end end |