Remarkably 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/remarkably.rb +39 -0
- metadata +46 -0
data/lib/remarkably.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Remarkably
|
2
|
+
def method_missing(sym, *args, &block)
|
3
|
+
hash = if args.size > 0 && args[-1].class == Hash
|
4
|
+
args.pop
|
5
|
+
else
|
6
|
+
Hash.new
|
7
|
+
end
|
8
|
+
tag! sym.to_s.downcase, args, hash, &block
|
9
|
+
end
|
10
|
+
def tag! tag, inline, attributes, &block
|
11
|
+
@remarkably = '' if !@remarkably
|
12
|
+
tag_attributes =
|
13
|
+
attributes.inject([]) do |result,data_pair|
|
14
|
+
key,data = data_pair
|
15
|
+
result << "#{key.to_s.downcase}=\"#{data.to_s}\""
|
16
|
+
end.join(' ')
|
17
|
+
@remarkably << "<#{tag}" +
|
18
|
+
(tag_attributes.size > 0 ? ' ' + tag_attributes : '')
|
19
|
+
if block_given? or inline.size > 0
|
20
|
+
@remarkably << ">"
|
21
|
+
result = block.call if block_given?
|
22
|
+
@remarkably << inline.shift.to_s while inline.size > 0
|
23
|
+
@remarkably << result.to_s if result.class != self.class
|
24
|
+
@remarkably << "</#{tag}>"
|
25
|
+
else
|
26
|
+
@remarkably << "/>"
|
27
|
+
end
|
28
|
+
self
|
29
|
+
end
|
30
|
+
def text content
|
31
|
+
@remarkably << content
|
32
|
+
self
|
33
|
+
end
|
34
|
+
def remarkably
|
35
|
+
result = @remarkably
|
36
|
+
@remarkably = nil
|
37
|
+
result
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.2
|
3
|
+
specification_version: 1
|
4
|
+
name: Remarkably
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.1.0
|
7
|
+
date: 2007-05-03 00:00:00 +02:00
|
8
|
+
summary: Remarkably is a very tiny Markaby-like XML builder
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: clive@darkarts.co.za
|
12
|
+
homepage: http://www.darkarts.co.za/
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Clive Crous
|
31
|
+
files:
|
32
|
+
- lib/remarkably.rb
|
33
|
+
test_files: []
|
34
|
+
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
extra_rdoc_files: []
|
38
|
+
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
requirements: []
|
44
|
+
|
45
|
+
dependencies: []
|
46
|
+
|