sculpt 0.1.03 → 0.1.04

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.
@@ -16,14 +16,20 @@ module SculptHelpers
16
16
  end
17
17
  end
18
18
 
19
- # plus some string additions from mynyml/unindent on github
19
+ # some awesome string additions.
20
20
 
21
21
  class String
22
- def unindent
23
- indent = self.split("\n").select {|line| !line.strip.empty? }.map {|line| line.index(/[^\s]/) }.compact.min || 0
24
- self.gsub(/^[[:blank:]]{#{indent}}/, '')
25
- end
26
- def unindent!
27
- self.replace(self.unindent)
28
- end
22
+ # this one from mynyml/unindent on github
23
+ def unindent
24
+ indent = self.split("\n").select {|line| !line.strip.empty? }.map {|line| line.index(/[^\s]/) }.compact.min || 0
25
+ self.gsub(/^[[:blank:]]{#{indent}}/, '')
26
+ end
27
+ def unindent!
28
+ self.replace(self.unindent)
29
+ end
30
+
31
+ # this awesome one by me
32
+ def to_proc
33
+ eval "Proc.new do\n#{self}\nend"
34
+ end
29
35
  end
data/lib/sculpt.rb CHANGED
@@ -31,24 +31,36 @@ class Sculpt
31
31
  @pretty
32
32
  end
33
33
 
34
- def self.render_doc(&block)
35
- puts self.make_doc(&block)
34
+ def self.render_doc(str = '', &block)
35
+ puts self.make_doc(str,&block)
36
36
  end
37
37
 
38
- def self.make_doc(&block)
38
+ def self.make_doc(str = '', &block)
39
+ if str.length > 0
40
+ proc = str.to_proc
41
+ else
42
+ proc = block
43
+ end
44
+
39
45
  self.make do
40
46
  doctype
41
- html(&block)
47
+ html(&proc)
42
48
  end
43
49
  end
44
50
 
45
- def self.render(&block)
46
- puts self.make(&block)
51
+ def self.render(str = '', &block)
52
+ puts self.make(str,&block)
47
53
  end
48
54
 
49
- def self.make(&block)
55
+ def self.make(str = '', &block)
56
+ if str.length > 0
57
+ proc = str.to_proc
58
+ else
59
+ proc = block
60
+ end
61
+
50
62
  result = Sculpture.new
51
- result.instance_eval(&block)
63
+ result.instance_eval(&proc)
52
64
  result.generate_html
53
65
  end
54
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sculpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.03
4
+ version: 0.1.04
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-10 00:00:00.000000000 Z
12
+ date: 2012-06-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! "Sculpt is an HTML generator in Ruby.\n Syntax is everything."
15
15
  email: lexy0202@gmail.com