xan_markup 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -4
- data/Gemfile.lock +16 -17
- data/VERSION +1 -1
- data/lib/xan_markup/helper.rb +3 -3
- data/spec/xan_markup/helper_spec.rb +31 -15
- data/xan_markup.gemspec +18 -21
- metadata +36 -41
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6c9cac59c7bc0bd578dac5751d30f416645cb220
|
4
|
+
data.tar.gz: 4739e35d7e01e3db54049dde6c250490413b0547
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 52c8ac1ebd69f0097755bd6151f2ea049d18fc8bf7ba008e2ff7544c4eda8f287d1c0c7aefe615588a595bfb0e61c7328d660ba3996d06da855a8fd746cc2811
|
7
|
+
data.tar.gz: e9b0a6c7ec66882f2f585673ffa70c3ac232a8bc51cc20f80e77ea65ed28d78616f07ad21b9017ec1503535f948e3cb4f2a79a7c4f10e4e5c692f839c2ae9fc1
|
data/Gemfile
CHANGED
@@ -6,9 +6,8 @@ source "http://rubygems.org"
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
8
|
group :development do
|
9
|
-
gem "rspec"
|
10
|
-
gem "bundler"
|
11
|
-
gem "jeweler"
|
12
|
-
gem "rcov", ">= 0"
|
9
|
+
gem "rspec"
|
10
|
+
gem "bundler"
|
11
|
+
gem "jeweler"
|
13
12
|
gem "rdoc"
|
14
13
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,30 +1,29 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
diff-lcs (1.1
|
4
|
+
diff-lcs (1.2.1)
|
5
5
|
git (1.2.5)
|
6
|
-
jeweler (1.
|
6
|
+
jeweler (1.8.4)
|
7
7
|
bundler (~> 1.0)
|
8
8
|
git (>= 1.2.5)
|
9
9
|
rake
|
10
|
-
|
11
|
-
|
12
|
-
rdoc (
|
13
|
-
rspec (2.
|
14
|
-
rspec-core (~> 2.
|
15
|
-
rspec-expectations (~> 2.
|
16
|
-
rspec-mocks (~> 2.
|
17
|
-
rspec-core (2.
|
18
|
-
rspec-expectations (2.
|
19
|
-
diff-lcs (
|
20
|
-
rspec-mocks (2.
|
10
|
+
rdoc
|
11
|
+
rake (10.0.3)
|
12
|
+
rdoc (4.0.0)
|
13
|
+
rspec (2.13.0)
|
14
|
+
rspec-core (~> 2.13.0)
|
15
|
+
rspec-expectations (~> 2.13.0)
|
16
|
+
rspec-mocks (~> 2.13.0)
|
17
|
+
rspec-core (2.13.1)
|
18
|
+
rspec-expectations (2.13.0)
|
19
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
20
|
+
rspec-mocks (2.13.0)
|
21
21
|
|
22
22
|
PLATFORMS
|
23
23
|
ruby
|
24
24
|
|
25
25
|
DEPENDENCIES
|
26
|
-
bundler
|
27
|
-
jeweler
|
28
|
-
rcov
|
26
|
+
bundler
|
27
|
+
jeweler
|
29
28
|
rdoc
|
30
|
-
rspec
|
29
|
+
rspec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/xan_markup/helper.rb
CHANGED
@@ -3,10 +3,10 @@ module XanMarkup
|
|
3
3
|
QuotedString = /"[^"]+"|'[^']+'/
|
4
4
|
QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/
|
5
5
|
TagAttributes = /(\w+)\s*\=\s*(#{QuotedFragment})/
|
6
|
-
CleanAttributeValue = /^("|')|("|')$/
|
6
|
+
CleanAttributeValue = /^("|')|("|')$/
|
7
7
|
module Helper
|
8
8
|
def markupize(content)
|
9
|
-
content.to_s.dup.gsub(MarkupSyntax) do |markup|
|
9
|
+
content.to_s.dup.to_str.gsub(MarkupSyntax) do |markup|
|
10
10
|
args = {}
|
11
11
|
tag = $1.split.first
|
12
12
|
method = "markup_#{tag}"
|
@@ -14,7 +14,7 @@ module XanMarkup
|
|
14
14
|
args[key.to_sym] = value.gsub(CleanAttributeValue, "")
|
15
15
|
end
|
16
16
|
if respond_to?(method)
|
17
|
-
(args.empty? ? send(method) : send(method, args)).to_s
|
17
|
+
(args.empty? ? send(method) : send(method, args)).to_s
|
18
18
|
else
|
19
19
|
"missing tag: #{tag}"
|
20
20
|
end
|
@@ -4,59 +4,75 @@ class XanMarkup::HelperTest
|
|
4
4
|
include XanMarkup::Helper
|
5
5
|
end
|
6
6
|
|
7
|
+
class SafeBuffer < String
|
8
|
+
def gsub(*args, &block)
|
9
|
+
super
|
10
|
+
end
|
11
|
+
def to_s
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
7
17
|
describe XanMarkup::Helper do
|
8
18
|
let(:helper) { XanMarkup::HelperTest.new }
|
9
|
-
|
19
|
+
|
10
20
|
it "It should call property method when found tag" do
|
11
21
|
helper.should_receive(:markup_test)
|
12
22
|
helper.markupize("this is markup {{test}} tag")
|
13
23
|
end
|
14
|
-
|
24
|
+
|
15
25
|
it "It should property parse one parameter" do
|
16
26
|
helper.should_receive(:markup_test).with(:name => "xan")
|
17
27
|
helper.markupize('this is markup {{test name="xan"}} tag')
|
18
28
|
end
|
19
|
-
|
29
|
+
|
20
30
|
it "It should property parse two parameters" do
|
21
31
|
helper.should_receive(:markup_test).with(:name => "xan", :next => "b")
|
22
32
|
helper.markupize('this is markup {{test name="xan" next="b"}} tag')
|
23
33
|
end
|
24
|
-
|
34
|
+
|
25
35
|
it "It should allow use single quotes too" do
|
26
36
|
helper.should_receive(:markup_test).with(:name => "xan")
|
27
37
|
helper.markupize("this is markup {{test name='xan'}} tag")
|
28
38
|
end
|
29
|
-
|
39
|
+
|
30
40
|
it "It should allow skip quotes too" do
|
31
41
|
helper.should_receive(:markup_test).with(:name => "xan")
|
32
42
|
helper.markupize("this is markup {{test name=xan}} tag")
|
33
43
|
end
|
34
|
-
|
44
|
+
|
35
45
|
it "It should parse two tags property" do
|
36
46
|
helper.should_receive(:markup_test).twice
|
37
47
|
helper.markupize("this is markup {{test}} {{test}} tag")
|
38
48
|
end
|
39
|
-
|
49
|
+
|
40
50
|
it "It should allow white space at beggining and end tag" do
|
41
51
|
helper.should_receive(:markup_test)
|
42
52
|
helper.markupize("this is markup {{ test }} tag")
|
43
53
|
end
|
44
|
-
|
54
|
+
|
45
55
|
it "should not raise exception if tag is not defined" do
|
46
|
-
expect { helper.markupize("this is markup {{ test }} tag") }.
|
56
|
+
expect { helper.markupize("this is markup {{ test }} tag") }.to_not raise_error(NoMethodError)
|
47
57
|
end
|
48
|
-
|
58
|
+
|
49
59
|
it "should return text that tag is not defined" do
|
50
60
|
helper.markupize("this is markup {{ test }} tag").should include("missing tag: test")
|
51
61
|
end
|
52
|
-
|
62
|
+
|
53
63
|
it "should replace tag with content returned by markup helper" do
|
54
64
|
helper.stub(:markup_best_language).and_return("Ruby")
|
55
65
|
helper.markupize("Best language is: {{ best_language }}").should include("Ruby")
|
56
66
|
end
|
57
|
-
|
58
67
|
|
59
|
-
|
60
|
-
|
61
|
-
|
68
|
+
|
69
|
+
it "should works with classes that inherance from string" do
|
70
|
+
helper.should_receive(:markup_test)
|
71
|
+
helper.markupize SafeBuffer.new("{{test}}")
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
62
78
|
end
|
data/xan_markup.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.1.
|
7
|
+
s.name = "xan_markup"
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Grzegorz Derebecki"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2013-03-19"
|
13
|
+
s.description = "Simple tag parser"
|
14
|
+
s.email = "grzegorz.derebecki@fdb.pl"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
17
|
"README.md"
|
@@ -31,33 +31,30 @@ Gem::Specification.new do |s|
|
|
31
31
|
"spec/xan_markup/helper_spec.rb",
|
32
32
|
"xan_markup.gemspec"
|
33
33
|
]
|
34
|
-
s.homepage =
|
34
|
+
s.homepage = "http://github.com/madmax/xan_markup"
|
35
35
|
s.licenses = ["MIT"]
|
36
36
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version =
|
38
|
-
s.summary =
|
37
|
+
s.rubygems_version = "2.0.0"
|
38
|
+
s.summary = "simple tag parser"
|
39
39
|
|
40
40
|
if s.respond_to? :specification_version then
|
41
|
-
s.specification_version =
|
41
|
+
s.specification_version = 4
|
42
42
|
|
43
43
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
-
s.add_development_dependency(%q<rspec>, [">=
|
45
|
-
s.add_development_dependency(%q<bundler>, [">=
|
46
|
-
s.add_development_dependency(%q<jeweler>, [">=
|
47
|
-
s.add_development_dependency(%q<rcov>, [">= 0"])
|
44
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
45
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
46
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
48
47
|
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
49
48
|
else
|
50
|
-
s.add_dependency(%q<rspec>, [">=
|
51
|
-
s.add_dependency(%q<bundler>, [">=
|
52
|
-
s.add_dependency(%q<jeweler>, [">=
|
53
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
49
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
50
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
51
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
54
52
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
55
53
|
end
|
56
54
|
else
|
57
|
-
s.add_dependency(%q<rspec>, [">=
|
58
|
-
s.add_dependency(%q<bundler>, [">=
|
59
|
-
s.add_dependency(%q<jeweler>, [">=
|
60
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
55
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
56
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
57
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
61
58
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
62
59
|
end
|
63
60
|
end
|
metadata
CHANGED
@@ -1,72 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xan_markup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Grzegorz Derebecki
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
default_executable:
|
11
|
+
date: 2013-03-19 00:00:00.000000000 Z
|
14
12
|
dependencies:
|
15
13
|
- !ruby/object:Gem::Dependency
|
16
14
|
name: rspec
|
17
|
-
requirement:
|
18
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
19
16
|
requirements:
|
20
|
-
- -
|
17
|
+
- - '>='
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
19
|
+
version: '0'
|
23
20
|
type: :development
|
24
21
|
prerelease: false
|
25
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
26
27
|
- !ruby/object:Gem::Dependency
|
27
28
|
name: bundler
|
28
|
-
requirement:
|
29
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
37
41
|
- !ruby/object:Gem::Dependency
|
38
42
|
name: jeweler
|
39
|
-
requirement:
|
40
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
41
44
|
requirements:
|
42
|
-
- -
|
45
|
+
- - '>='
|
43
46
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
47
|
+
version: '0'
|
45
48
|
type: :development
|
46
49
|
prerelease: false
|
47
|
-
version_requirements:
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: rcov
|
50
|
-
requirement: &2151875520 !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
51
|
requirements:
|
53
|
-
- -
|
52
|
+
- - '>='
|
54
53
|
- !ruby/object:Gem::Version
|
55
54
|
version: '0'
|
56
|
-
type: :development
|
57
|
-
prerelease: false
|
58
|
-
version_requirements: *2151875520
|
59
55
|
- !ruby/object:Gem::Dependency
|
60
56
|
name: rdoc
|
61
|
-
requirement:
|
62
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
63
58
|
requirements:
|
64
|
-
- -
|
59
|
+
- - '>='
|
65
60
|
- !ruby/object:Gem::Version
|
66
61
|
version: '0'
|
67
62
|
type: :development
|
68
63
|
prerelease: false
|
69
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
70
69
|
description: Simple tag parser
|
71
70
|
email: grzegorz.derebecki@fdb.pl
|
72
71
|
executables: []
|
@@ -88,33 +87,29 @@ files:
|
|
88
87
|
- spec/spec_helper.rb
|
89
88
|
- spec/xan_markup/helper_spec.rb
|
90
89
|
- xan_markup.gemspec
|
91
|
-
has_rdoc: true
|
92
90
|
homepage: http://github.com/madmax/xan_markup
|
93
91
|
licenses:
|
94
92
|
- MIT
|
93
|
+
metadata: {}
|
95
94
|
post_install_message:
|
96
95
|
rdoc_options: []
|
97
96
|
require_paths:
|
98
97
|
- lib
|
99
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
-
none: false
|
101
99
|
requirements:
|
102
|
-
- -
|
100
|
+
- - '>='
|
103
101
|
- !ruby/object:Gem::Version
|
104
102
|
version: '0'
|
105
|
-
segments:
|
106
|
-
- 0
|
107
|
-
hash: -1804077595733386823
|
108
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
104
|
requirements:
|
111
|
-
- -
|
105
|
+
- - '>='
|
112
106
|
- !ruby/object:Gem::Version
|
113
107
|
version: '0'
|
114
108
|
requirements: []
|
115
109
|
rubyforge_project:
|
116
|
-
rubygems_version:
|
110
|
+
rubygems_version: 2.0.0
|
117
111
|
signing_key:
|
118
|
-
specification_version:
|
112
|
+
specification_version: 4
|
119
113
|
summary: simple tag parser
|
120
114
|
test_files: []
|
115
|
+
has_rdoc:
|