pipin 0.0.2 → 0.0.3
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/README.rdoc +5 -9
- data/lib/pipin/version.rb +1 -1
- data/lib/pipin.rb +11 -7
- metadata +1 -1
data/README.rdoc
CHANGED
data/lib/pipin/version.rb
CHANGED
data/lib/pipin.rb
CHANGED
@@ -5,6 +5,10 @@ require 'fileutils'
|
|
5
5
|
include Haml::Helpers
|
6
6
|
alias h html_escape
|
7
7
|
|
8
|
+
def rootdir
|
9
|
+
File.join(File.dirname(File.expand_path(__FILE__)).untaint, '..')
|
10
|
+
end
|
11
|
+
|
8
12
|
module Pipin
|
9
13
|
def self.command(cmd)
|
10
14
|
__send__ "command_#{cmd}", *ARGV
|
@@ -12,7 +16,7 @@ module Pipin
|
|
12
16
|
|
13
17
|
def self.command_new(dir)
|
14
18
|
File.exist?(dir) && raise("File exists - #{dir}")
|
15
|
-
FileUtils.cp_r '
|
19
|
+
FileUtils.cp_r File.join(rootdir ,'templatefiles'), dir
|
16
20
|
puts Dir.glob(File.join(dir, '**/*')).map {|e| ' create ' + e }
|
17
21
|
end
|
18
22
|
|
@@ -24,8 +28,8 @@ module Pipin
|
|
24
28
|
end
|
25
29
|
|
26
30
|
class Builder
|
27
|
-
def initialize(
|
28
|
-
@
|
31
|
+
def initialize(distdir)
|
32
|
+
@distdir = distdir
|
29
33
|
end
|
30
34
|
|
31
35
|
def render_posts
|
@@ -40,8 +44,8 @@ module Pipin
|
|
40
44
|
end
|
41
45
|
|
42
46
|
def write_html(label, html)
|
43
|
-
|
44
|
-
File.open(File.join(@
|
47
|
+
Dir.mkdir @distdir unless File.exist?(@distdir)
|
48
|
+
File.open(File.join(@distdir, label + '.html'), 'w') {|f| f.write html }
|
45
49
|
end
|
46
50
|
|
47
51
|
def render_with_layout(template, b = binding)
|
@@ -49,13 +53,13 @@ module Pipin
|
|
49
53
|
end
|
50
54
|
|
51
55
|
def render(template, b = binding)
|
52
|
-
haml = File.read("
|
56
|
+
haml = File.read(File.join(rootdir, "views/#{template}.haml"))
|
53
57
|
Haml::Engine.new(haml).render(b)
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
57
61
|
class Post
|
58
|
-
@@entries_dir = '
|
62
|
+
@@entries_dir = 'datasample'
|
59
63
|
def self.find(pattern, options = {})
|
60
64
|
files = Dir.chdir(@@entries_dir) { Dir.glob(pattern) }.sort.reverse
|
61
65
|
files = files[0, options[:limit]] if options[:limit]
|