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.
Files changed (4) hide show
  1. data/README.rdoc +5 -9
  2. data/lib/pipin/version.rb +1 -1
  3. data/lib/pipin.rb +11 -7
  4. metadata +1 -1
data/README.rdoc CHANGED
@@ -16,16 +16,12 @@
16
16
  == todo
17
17
 
18
18
  * 原稿の入力
19
- ** html, txt(hd)
20
- ** to_html
19
+ * html, txt(hd)
20
+ * to_html
21
21
 
22
22
  * 原稿の検索
23
- ** 個別
24
- ** 最近のn件
25
- ** 月別
26
- ** カテゴリ
23
+ * カテゴリ
27
24
 
28
25
  * html出力
29
- ** 個別ページ
30
- ** トップページ
31
- ** 月別ページ
26
+ * ページ一覧
27
+ * 月別ページ
data/lib/pipin/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pipin
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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 './templatefiles', dir
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(dstdir)
28
- @dstdir = dstdir
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
- p label
44
- File.open(File.join(@dstdir, label + '.html'), 'w') {|f| f.write html }
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("../views/#{template}.haml")
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 = 'data_sample'
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]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: pipin
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - dan5ya