Class: Bones::Cache::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/bones/cache.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



6
7
8
9
10
11
# File 'lib/bones/cache.rb', line 6

def initialize
  super
  self.base        = ''               # Base URL is empty
  self.release     = nil
  self.noop        = false
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



4
5
6
# File 'lib/bones/cache.rb', line 4

def base
  @base
end

#destinationObject

Returns destination



85
86
87
# File 'lib/bones/cache.rb', line 85

def destination
  @destination
end

#noopObject

Returns the value of attribute noop.



4
5
6
# File 'lib/bones/cache.rb', line 4

def noop
  @noop
end

#releaseObject

Returns the value of attribute release.



4
5
6
# File 'lib/bones/cache.rb', line 4

def release
  @release
end

#versionedObject

Returns the value of attribute versioned.



4
5
6
# File 'lib/bones/cache.rb', line 4

def versioned
  @versioned
end

Class Method Details

.process(args) ⇒ Object

Process arguments



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/bones/cache.rb', line 23

def self.process(args)
  args = [] if args.blank?
  options = new
    
  OptionParser.new do |o|
    o.on('--destination PATH', '-d PATH', "Change the destination directory") do |path|
      options.destination = path
    end

    o.on('--versioned', '--versions', "Enable versioning") do
      options.versioned = true
    end

    o.on('--base PATH', "Change the base URL path") do |path|
      options.base = path # Bones.base = path
    end
    
    o.on('--noop', "Do not write any files") do
      options.noop = true
    end

    o.on_tail("-h", "--help", "Show this message") do
      puts o; exit
    end
  end.parse!(args)
    
  options
end

Instance Method Details

#default_destinationObject



71
72
73
# File 'lib/bones/cache.rb', line 71

def default_destination
  File.expand_path(Bones.root / 'public')
end

#merge(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/bones/cache.rb', line 13

def merge(options={})
  options.each do |k, v|
    method = "#{k}=".to_sym
    send(method, v) if respond_to?(method)
  end
  
  self
end

#release?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/bones/cache.rb', line 80

def release?
  !release.nil?
end

#versioned?Boolean

Returns true if the versions enabled

Returns:

  • (Boolean)


76
77
78
# File 'lib/bones/cache.rb', line 76

def versioned?
  Bones::VersionedRelease === release
end