Class: Cup::Directory
- Inherits:
-
Object
- Object
- Cup::Directory
- Defined in:
- lib/cup/directory.rb
Overview
Represents the directory that holds a cup
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
-
.__current__ ⇒ Object
so that current can be overridden for all tests.
- .current ⇒ Object
Instance Method Summary collapse
- #concatenated(opts = {}) ⇒ Object
- #cupfile ⇒ Object
-
#initialize(path) ⇒ Directory
constructor
A new instance of Directory.
- #javascripts(scheme = nil) ⇒ Object
- #licence(opts = {}) ⇒ Object
- #minified(opts = {}) ⇒ Object
- #name ⇒ Object
- #stylesheets ⇒ Object
Constructor Details
#initialize(path) ⇒ Directory
Returns a new instance of Directory.
11 12 13 |
# File 'lib/cup/directory.rb', line 11 def initialize path @path = Pathname.new File.(path.to_s) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/cup/directory.rb', line 9 def path @path end |
Class Method Details
.__current__ ⇒ Object
so that current can be overridden for all tests
16 17 18 |
# File 'lib/cup/directory.rb', line 16 def self.__current__ new('.') end |
.current ⇒ Object
20 21 22 |
# File 'lib/cup/directory.rb', line 20 def self.current __current__ end |
Instance Method Details
#concatenated(opts = {}) ⇒ Object
38 39 40 41 |
# File 'lib/cup/directory.rb', line 38 def concatenated(opts={}) output = "build/#{name}-#{cupfile.version}.js" opts[:relative] ? output : "#{self.path}/#{output}" end |
#cupfile ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/cup/directory.rb', line 24 def cupfile @cupfile ||= Cup::Cupfile.new(path + 'Cupfile') unless @cupfile.valid? fail Cup::Cupfile::CupfileError.new("Cupfile not valid: #{@cupfile.path.to_s}\n#{@cupfile.("\n")}") end @cupfile end |
#javascripts(scheme = nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/cup/directory.rb', line 53 def javascripts scheme=nil load_paths = case scheme when :spec ['vendor', 'spec', 'lib', 'src'] when :build_input ['lib', 'src'] when :spec_concatenated, :spec_minified ['vendor', 'spec', 'build'] when :debug ['vendor', 'lib', 'src'] else raise "scheme not known: #{scheme}" end javascripts = load_paths.map do |load_path| if load_path == 'build' build_for scheme else cupfile.javascripts[load_path.to_sym].map{|filepath| Pathname.new(filepath).to_s} end end.flatten javascripts end |
#licence(opts = {}) ⇒ Object
48 49 50 51 |
# File 'lib/cup/directory.rb', line 48 def licence(opts={}) licence = "#{cupfile.licence}" opts[:relative] ? licence : "#{self.path}/#{licence}" end |
#minified(opts = {}) ⇒ Object
43 44 45 46 |
# File 'lib/cup/directory.rb', line 43 def minified(opts={}) output = "build/#{name}-#{cupfile.version}.min.js" opts[:relative] ? output : "#{self.path}/#{output}" end |
#name ⇒ Object
34 35 36 |
# File 'lib/cup/directory.rb', line 34 def name File.basename path.to_s end |
#stylesheets ⇒ Object
79 80 81 |
# File 'lib/cup/directory.rb', line 79 def stylesheets FileList['**/*.css'].map{|f| Pathname.new(f).} end |