Class: Aerial::Build

Inherits:
Thor show all
Includes:
FileUtils, Thor::Actions
Defined in:
lib/aerial/build.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



7
8
9
# File 'lib/aerial/build.rb', line 7

def root
  @root
end

Instance Method Details

#buildObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/aerial/build.rb', line 12

def build
  # TODO: Need a better way to find the root
  # @root = Pathname(File.dirname(__FILE__) + "/../../").expand_path
  @root = Pathname(File.dirname('.')).expand_path
  @site_path = "#{@root}/public/site"
  Aerial.new(@root, "/config/config.yml")
  Aerial::App.set :root, @root
  @articles = Aerial::Article.all
  @request = Rack::MockRequest.new(Aerial::App)
  build_style_css
  build_pages_html
  build_articles_html
  build_tags_html
  build_archives_html
  build_feed_xml
end

#build_archives_htmlObject



67
68
69
70
71
72
73
# File 'lib/aerial/build.rb', line 67

def build_archives_html
  Aerial::Article.archives.each do |archive|
    create_file "#{@site_path}/archives/#{archive.first.first}.html" do
      @request.request('get', "/archives/#{archive.first.first}").body
    end
  end
end

#build_articles_htmlObject



49
50
51
52
53
54
55
# File 'lib/aerial/build.rb', line 49

def build_articles_html
  @articles.each do |article|
    create_file "#{@site_path}/#{article.permalink}.html" do
      @request.request('get', "#{article.permalink}").body
    end
  end
end

#build_feed_xmlObject



76
77
78
79
80
# File 'lib/aerial/build.rb', line 76

def build_feed_xml
  create_file "#{@site_path}/feed.xml" do
    @request.request('get', "/feed.xml").body
  end
end

#build_pages_htmlObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/aerial/build.rb', line 37

def build_pages_html

  create_file "#{@site_path}/index.html" do
    @request.request('get', '/').body
  end

  create_file "#{@site_path}/articles.html" do
    @request.request('get', '/articles').body
  end
end

#build_style_cssObject



30
31
32
33
34
# File 'lib/aerial/build.rb', line 30

def build_style_css
  create_file "#{@site_path}/style.css" do
    @request.request('get', '/style.css').body
  end
end

#build_tags_htmlObject



58
59
60
61
62
63
64
# File 'lib/aerial/build.rb', line 58

def build_tags_html
  Aerial::Article.tags.each do |tag|
    create_file "#{@site_path}/tags/#{tag}.html" do
      @request.request('get', "/tags/#{tag}").body
    end
  end
end