hamdown 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/hamdown.rb +18 -2
  2. metadata +3 -3
data/lib/hamdown.rb CHANGED
@@ -6,11 +6,12 @@ class Hamdown
6
6
  def initialize(options={})
7
7
  file = options.delete(:file_path) { raise "you need to specify a file name" }
8
8
  @innerfile = File.open(file).read
9
- @outerfile = File.open('layout.haml')
9
+ @outerfile = File.open('layout.haml').read
10
10
  end
11
11
 
12
12
  def to_html(options={})
13
13
  columns = options.delete(:columns) { false }
14
+ timestamp
14
15
  if columns
15
16
  first_half = ""
16
17
  second_half = ""
@@ -34,7 +35,22 @@ class Hamdown
34
35
  else
35
36
  html = RDiscount.new(@innerfile).to_html
36
37
  end
37
- Haml::Engine.new(@outerfile.read).render { html }
38
+ Haml::Engine.new(@outerfile).render { html }
39
+ end
40
+
41
+ def timestamp
42
+ lines = ''
43
+ @innerfile.each do |line|
44
+ if line.match(/(\[:(.*):\])/)
45
+ if $2 == 'today'
46
+ line.gsub!($1, Time.now.strftime('%B %d, %Y'))
47
+ elsif $2 == 'tomorrow'
48
+ line.gsub!($1, (Time.now + (24*60*60)).strftime('%B %d, %Y'))
49
+ end
50
+ end
51
+ lines << line + '\n'
52
+ end
53
+ @innerfile = lines
38
54
  end
39
55
 
40
56
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamdown
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 9
10
- version: 0.0.9
9
+ - 10
10
+ version: 0.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Robert Fletcher