benofsky-bolt 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/bolt.rb +2 -2
- data/lib/bolt/base.rb +3 -2
- data/lib/bolt/build.rb +12 -4
- data/lib/bolt/page.rb +2 -2
- data/lib/bolt/view.rb +2 -2
- metadata +1 -1
data/lib/bolt.rb
CHANGED
@@ -40,7 +40,7 @@ module Bolt
|
|
40
40
|
# a bolt project and saving all files into the "out" directory.
|
41
41
|
def build
|
42
42
|
require 'bolt/build'
|
43
|
-
Build.new(
|
43
|
+
Build.new().run
|
44
44
|
end
|
45
45
|
|
46
46
|
# Parses command line options
|
@@ -48,8 +48,8 @@ module Bolt
|
|
48
48
|
$config.resources = "resources"
|
49
49
|
$config.lib = "lib"
|
50
50
|
$config.views = "views"
|
51
|
-
$config.pages = "pages"
|
52
51
|
$config.out = "out"
|
52
|
+
$config.pages = "pages"
|
53
53
|
$config.config = "config.yml"
|
54
54
|
|
55
55
|
opts = OptionParser.new do |opts|
|
data/lib/bolt/base.rb
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
|
9
9
|
require 'fileutils'
|
10
10
|
|
11
|
+
# Deprecated library in Ruby 1.9
|
11
12
|
require 'ftools' if RUBY_VERSION.to_f <= 1.8
|
12
13
|
|
13
14
|
$BOLT_BASE = File.dirname(__FILE__) + "/../../"
|
@@ -23,7 +24,7 @@ module Bolt
|
|
23
24
|
# Creates a directory, prefixes $config.base_dir if required
|
24
25
|
def create_directory(directory, options = {})
|
25
26
|
options[:error_if_exists] = (options[:error_if_exists].nil?) ? true : options[:error_if_exists]
|
26
|
-
directory =
|
27
|
+
directory = directory
|
27
28
|
|
28
29
|
if File.directory?(directory)
|
29
30
|
raise ArgumentError, "#{directory} exists already." if options[:error_if_exists]
|
@@ -35,7 +36,7 @@ module Bolt
|
|
35
36
|
|
36
37
|
# Forces removal of directory, <tt>directory</tt>
|
37
38
|
def remove_directory(directory)
|
38
|
-
directory =
|
39
|
+
directory = directory
|
39
40
|
FileUtils.rm_rf(directory)
|
40
41
|
puts "Removed #{directory}"
|
41
42
|
end
|
data/lib/bolt/build.rb
CHANGED
@@ -16,9 +16,17 @@ require 'bolt/view'
|
|
16
16
|
module Bolt
|
17
17
|
class Build < Base
|
18
18
|
# Performs all the nessecary steps to build a Bolt project
|
19
|
+
def initialize()
|
20
|
+
if $config.out
|
21
|
+
puts $config.out
|
22
|
+
else
|
23
|
+
$config.out = d("out")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
19
27
|
def run
|
20
|
-
remove_directory(
|
21
|
-
create_directory(
|
28
|
+
remove_directory($config.out)
|
29
|
+
create_directory($config.out, :error_if_exists => false)
|
22
30
|
copy_resources
|
23
31
|
parse_config
|
24
32
|
load_pages
|
@@ -26,8 +34,8 @@ module Bolt
|
|
26
34
|
|
27
35
|
# Copies the contents of $config.resources to the out directory
|
28
36
|
def copy_resources
|
29
|
-
FileUtils.cp_r(Dir.glob("#{d($config.resources)}/*"),
|
30
|
-
puts "Copied #{d($config.resources)} to #{
|
37
|
+
FileUtils.cp_r(Dir.glob("#{d($config.resources)}/*"), $config.out)
|
38
|
+
puts "Copied #{d($config.resources)} to #{$config.out}"
|
31
39
|
end
|
32
40
|
|
33
41
|
# Parses $config.config and loads all contents into instance variables
|
data/lib/bolt/page.rb
CHANGED
@@ -27,7 +27,7 @@ def page(path)
|
|
27
27
|
@current_page = path
|
28
28
|
create_path(path)
|
29
29
|
|
30
|
-
path = "#{$config.
|
30
|
+
path = "#{$config.out}/#{path}.html"
|
31
31
|
File.open(path, 'w') {|f| f.write yield}
|
32
32
|
puts "Created #{path}"
|
33
33
|
end
|
@@ -36,7 +36,7 @@ private
|
|
36
36
|
def create_path(path)
|
37
37
|
path = path.split('/')
|
38
38
|
if path.count > 1
|
39
|
-
path = "#{$config.
|
39
|
+
path = "#{$config.out}/#{path[0..path.length-2].join('/')}"
|
40
40
|
if !File.directory?(path)
|
41
41
|
FileUtils.mkdir_p(path)
|
42
42
|
puts "Created #{path}"
|
data/lib/bolt/view.rb
CHANGED