Class: Sphere::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/sphere/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



6
7
8
9
# File 'lib/sphere/config.rb', line 6

def initialize
  self.env  = defined?(Rails) ? Rails.env.to_s : 'development'
  self.root = defined?(Rails) ? Rails.root : Pathname.new('.')
end

Instance Attribute Details

#asset_pathObject



20
21
22
# File 'lib/sphere/config.rb', line 20

def asset_path
  @asset_path || definitions['asset_path'] || 'assets'
end

#backendObject



28
29
30
# File 'lib/sphere/config.rb', line 28

def backend
  @backend || "Sphere::Backends::#{(definitions['backend'] || 'closure').classify}".constantize
end

#compress=(value) ⇒ Object (writeonly)

Sets the attribute compress

Parameters:

  • value

    the value to set the attribute compress to.



4
5
6
# File 'lib/sphere/config.rb', line 4

def compress=(value)
  @compress = value
end

#config_fileObject



16
17
18
# File 'lib/sphere/config.rb', line 16

def config_file
  @config_file || root.join('config', 'sphere.yml')
end

#envObject

Returns the value of attribute env.



3
4
5
# File 'lib/sphere/config.rb', line 3

def env
  @env
end

#package=(value) ⇒ Object (writeonly)

Sets the attribute package

Parameters:

  • value

    the value to set the attribute package to.



4
5
6
# File 'lib/sphere/config.rb', line 4

def package=(value)
  @package = value
end

#rootObject

Returns the value of attribute root.



3
4
5
# File 'lib/sphere/config.rb', line 3

def root
  @root
end

Instance Method Details

#asset_rootObject



24
25
26
# File 'lib/sphere/config.rb', line 24

def asset_root
  public_path.join(asset_path)
end

#compass?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/sphere/config.rb', line 44

def compass?
  definitions.key?('compass') ? !!definitions['compass'] : false
end

#compress?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/sphere/config.rb', line 40

def compress?
  defined?(@compress) ? !!@compress : (definitions.key?('compress') ? !!definitions['compress'] : (self.env == 'production'))
end

#javascriptsObject



32
33
34
# File 'lib/sphere/config.rb', line 32

def javascripts
  definitions['javascripts'] ||= {}
end

#package?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/sphere/config.rb', line 48

def package?
  defined?(@package) ? !!@package : (definitions.key?('package') ? !!definitions['package'] : (self.env == 'production'))
end

#public_pathObject



52
53
54
# File 'lib/sphere/config.rb', line 52

def public_path
  @public_path ||= defined?(Rails) ? Pathname.new(Rails.public_path.to_s) : root.join('public')
end

#stylesheetsObject



36
37
38
# File 'lib/sphere/config.rb', line 36

def stylesheets
  definitions['stylesheets'] ||= {}
end

#update!(&block) ⇒ Object



11
12
13
14
# File 'lib/sphere/config.rb', line 11

def update!(&block)
  block.call(self)
  self
end