Class: Jet::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/jet/application.rb

Constant Summary collapse

ASSET_PATHS =
['config', 'app/models', 'app/controllers', 'app/views',
'app/templates', 'app/states', 'app/stylesheets', 'lib', 'vendor']

Instance Method Summary collapse

Constructor Details

#initialize(environment = :development) ⇒ Application

Returns a new instance of Application.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jet/application.rb', line 11

def initialize(environment = :development)
  @environment = environment
  @root_path   = Dir.pwd
  @build_path  = ::File.join(@root_path, 'build', @environment.to_s)

  Compass.configuration do |config|
    config.project_path    = @root_path
    config.images_dir      = ::File.join('build', 'development')
    config.images_path     = 'app'
    config.http_images_dir = '/'
  end
end

Instance Method Details

#build_allObject



28
29
30
31
32
# File 'lib/jet/application.rb', line 28

def build_all
  build_javascript
  build_stylesheet
  copy_static_assets_to_build
end

#build_javascriptObject



34
35
36
# File 'lib/jet/application.rb', line 34

def build_javascript
  application_javascript_asset.write_to(::File.join(@build_path, 'application.js'))
end

#build_stylesheetObject



38
39
40
# File 'lib/jet/application.rb', line 38

def build_stylesheet
  application_stylesheet_asset.write_to(::File.join(@build_path, 'application.css'))
end

#clear_buildObject



24
25
26
# File 'lib/jet/application.rb', line 24

def clear_build
  FileUtils.rm_rf(Dir[::File.join(@build_path, '*')])
end

#copy_to_build(file) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/jet/application.rb', line 42

def copy_to_build(file)
  absolute_path = Pathname.new(::File.dirname(file))
  build_relative_path = Pathname.new(::File.join(@build_path, absolute_path.relative_path_from(Pathname.new('public'))))

  FileUtils.mkdir_p(build_relative_path) unless build_relative_path.exist?
  FileUtils.cp(file, build_relative_path)
end