Class: Cup::Cupfile
- Inherits:
-
Object
- Object
- Cup::Cupfile
- Defined in:
- lib/cup/cupfile.rb
Defined Under Namespace
Classes: CupfileError, DSL
Instance Attribute Summary collapse
-
#after_build ⇒ Object
readonly
Returns the value of attribute after_build.
-
#before_build ⇒ Object
readonly
Returns the value of attribute before_build.
-
#licence ⇒ Object
readonly
Returns the value of attribute licence.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#uglifier_options ⇒ Object
readonly
Returns the value of attribute uglifier_options.
-
#validation_errors ⇒ Object
readonly
Returns the value of attribute validation_errors.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #error_messages(join = ', ') ⇒ Object
-
#initialize(path) ⇒ Cupfile
constructor
A new instance of Cupfile.
- #javascripts ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ Cupfile
Returns a new instance of Cupfile.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cup/cupfile.rb', line 8 def initialize path @path = path @javascripts = {} @uglifier_options = {} @before_build = lambda {} @after_build = lambda {} @validation_errors = [] %w{vendor spec lib src}.each do |dir| set_javascript_patterns_for dir.to_sym, :* end cup_define_block = eval(File.read(path), binding, path.to_s) DSL.interpret self, &cup_define_block end |
Instance Attribute Details
#after_build ⇒ Object (readonly)
Returns the value of attribute after_build.
6 7 8 |
# File 'lib/cup/cupfile.rb', line 6 def after_build @after_build end |
#before_build ⇒ Object (readonly)
Returns the value of attribute before_build.
6 7 8 |
# File 'lib/cup/cupfile.rb', line 6 def before_build @before_build end |
#licence ⇒ Object (readonly)
Returns the value of attribute licence.
6 7 8 |
# File 'lib/cup/cupfile.rb', line 6 def licence @licence end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/cup/cupfile.rb', line 6 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/cup/cupfile.rb', line 5 def path @path end |
#uglifier_options ⇒ Object (readonly)
Returns the value of attribute uglifier_options.
6 7 8 |
# File 'lib/cup/cupfile.rb', line 6 def @uglifier_options end |
#validation_errors ⇒ Object (readonly)
Returns the value of attribute validation_errors.
6 7 8 |
# File 'lib/cup/cupfile.rb', line 6 def validation_errors @validation_errors end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/cup/cupfile.rb', line 6 def version @version end |
Instance Method Details
#error_messages(join = ', ') ⇒ Object
40 41 42 |
# File 'lib/cup/cupfile.rb', line 40 def (join=', ') @validation_errors.join join end |
#javascripts ⇒ Object
25 26 27 |
# File 'lib/cup/cupfile.rb', line 25 def javascripts @javascripts end |
#valid? ⇒ Boolean
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cup/cupfile.rb', line 29 def valid? @validation_errors = [] validation_error 'cupfile error, path not specified' if path.nil? validation_error 'name is required' if name.nil? or name.strip.size == 0 validation_error 'version is require and must be of the form X.Y.Z where X, Y and Z are numbers' unless version =~ /\d+\.\d+\.\d+/ validation_error "licence file '#{licence}' does not exist" unless licence_file_exists? @validation_errors.empty? end |