Class: Allen::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/allen/project.rb

Direct Known Subclasses

StaticProject, UmbracoProject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = "Umbraco", settings = Allen.settings.clone) ⇒ Project

Returns a new instance of Project.



9
10
11
12
13
14
15
# File 'lib/allen/project.rb', line 9

def initialize(name="Umbraco", settings=Allen.settings.clone)
  @name = name
  @settings = settings
  @settings.configure do
    name name
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/allen/project.rb', line 7

def name
  @name
end

#settingsObject

Returns the value of attribute settings.



7
8
9
# File 'lib/allen/project.rb', line 7

def settings
  @settings
end

Instance Method Details

#assetsObject



28
29
30
# File 'lib/allen/project.rb', line 28

def assets
  @asset_bundle_collection ||= AssetBundleCollection.new(js, css)
end

#build!Object



17
18
19
20
# File 'lib/allen/project.rb', line 17

def build!
  assets.build!
  generate_meta_data!
end

#cssObject



41
42
43
44
45
46
47
48
# File 'lib/allen/project.rb', line 41

def css
  @css_asset_bundle ||= begin
    preprocessor = Preprocessors.for(settings.css_preprocessor)
    input  = "#{settings.webroot}/#{settings.css_input}"
    output = "#{settings.webroot}/#{settings.css_output}"
    AssetBundle.new(preprocessor, input, output)
  end
end

#generate_meta_data!Object



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/allen/project.rb', line 50

def generate_meta_data!
  #create a version file with the time and the latest git commit
  version_file = File.open("#{settings.webroot}/version","w")
  version_file.puts "built: #{Time.now.to_s}"
  version_file.puts `git log -1`
  version_file.close

  #create a commit-hash file with just the last commit hash in it
  hash_file = File.open("#{settings.webroot}/commit-hash","w")
  hash_file.print  `git log -1 --format="%H"`.chomp
  hash_file.close
end

#install!Object



22
23
# File 'lib/allen/project.rb', line 22

def install!
end

#jsObject



32
33
34
35
36
37
38
39
# File 'lib/allen/project.rb', line 32

def js
  @js_asset_bundle ||= begin
    preprocessor = Preprocessors.for(settings.js_preprocessor)
    input  = "#{settings.webroot}/#{settings.js_input}"
    output = "#{settings.webroot}/#{settings.js_output}"
    AssetBundle.new(preprocessor, input, output)
  end
end

#uninstall!Object



25
26
# File 'lib/allen/project.rb', line 25

def uninstall!
end