xan_markup 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a72eecb5af9f00619a86b37553acd6c702ef520c
4
- data.tar.gz: 78e0840af089ad5b0799e7f4432b6f48e03bab43
3
+ metadata.gz: 6bac1b66d447ed5e88d8706b419f4e9cbc5280d1
4
+ data.tar.gz: 8b8c50c6337d5eec7845ab11f489f0e948c31381
5
5
  SHA512:
6
- metadata.gz: 3d6a8f37316b8c6a8f8896f750bad74f10e6216d698f39a5a0fc3422f898cb13e88edbc3e32c82c340858375617a2f92171a988f286d12575951ee57b5345961
7
- data.tar.gz: e9a75d1328b21364b5a9a8fa93c4effc1a59ae1b926e5b13ac45b0ce56e2ba01bb426bbfacf8a4a21b8c2671bf70f0127bf23878b7cdf3b20d278be0107f5848
6
+ metadata.gz: 181471f68d534fe74cb745539b172b05b2d947146c9502516f3e70e3230ceae78cd9fd302fd072d59b411f7a093d5c276f6cc9205eec62ff9b9c9220efc85e2c
7
+ data.tar.gz: 4462fb72d76f8c5987f0289511a69777b9d14cc65532e78e5ac392e5bc0e37ef976939e89d3705baa911caac39306ad159450e55f1b5314108834539160c42ce
data/Gemfile.lock CHANGED
@@ -2,13 +2,13 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  diff-lcs (1.2.1)
5
- git (1.2.5)
5
+ git (1.2.9.1)
6
6
  jeweler (1.8.4)
7
7
  bundler (~> 1.0)
8
8
  git (>= 1.2.5)
9
9
  rake
10
10
  rdoc
11
- rake (10.0.3)
11
+ rake (10.4.2)
12
12
  rdoc (4.0.0)
13
13
  rspec (2.13.0)
14
14
  rspec-core (~> 2.13.0)
data/README.md CHANGED
@@ -1,19 +1,18 @@
1
1
  # XanMarkup
2
2
 
3
-
4
3
  Very simple tag parser
5
4
 
6
5
  ## Install & Example
7
6
 
8
7
  Add to your Gemfile
9
-
8
+
10
9
  gem "xan_markup"
11
10
 
12
11
  Create helper (call it like you want)
13
-
12
+
14
13
  module MarkupHelper
15
14
  include XanMarkup::Helper
16
-
15
+
17
16
  def markup_favorite_movie
18
17
  "Matrix"
19
18
  end
@@ -33,4 +32,36 @@ You can pass attributes to tags
33
32
  ....
34
33
  end
35
34
 
36
- Copyright (c) 2009-20011 Grzegorz Derebecki, released under the MIT license
35
+
36
+ ## Customization
37
+
38
+ You can write own class that will be called when tag is found.
39
+ For example using instance variables not helper methods:
40
+
41
+ class MyCustomCaller
42
+ def initialize(context)
43
+ @context = context
44
+ end
45
+
46
+ def call
47
+ ->(tag) do
48
+ @context.instance_variable_get("@tag.name") || "missing tag: #{tag.name}"
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ def markupize(content)
55
+ Markupizer.new(content).markupize &MyCustomCaller.new(self).call
56
+ end
57
+
58
+ You can change also syntax
59
+
60
+ def markupize(content)
61
+ Markupizer.new(content, /\[ ?(.*?) ?\]/).markupize &MyCustomCaller.new(self).call
62
+ end
63
+
64
+ @favorite_movie = "Matrix"
65
+ markupize("My favorite movie is [favorite_movie]") #=> My favorite movie is Matrix
66
+
67
+ Copyright (c) 2009-20015 Grzegorz Derebecki, released under the MIT license
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -4,18 +4,19 @@ module XanMarkup
4
4
  class Markupizer
5
5
  MarkupSyntax = /\{\{ ?(.*?) ?\}\}/
6
6
 
7
- def initialize(content)
7
+ def initialize(content, syntax = MarkupSyntax)
8
8
  @content = content.to_s.dup.to_str
9
+ @syntax = syntax
9
10
  end
10
11
 
11
12
  def tags
12
- @content.scan(MarkupSyntax).map do |markup|
13
+ @content.scan(@syntax).map do |markup|
13
14
  Tag.new(markup.first)
14
15
  end
15
16
  end
16
17
 
17
18
  def markupize
18
- @content.gsub(MarkupSyntax) do |markup|
19
+ @content.gsub(@syntax) do |markup|
19
20
  yield Tag.new($1)
20
21
  end
21
22
  end
@@ -77,14 +77,15 @@ module XanMarkup
77
77
  markupizer.tags.first.args.should == {name: "xan"}
78
78
  end
79
79
 
80
-
81
-
82
-
83
80
  it "should works with classes that inherance from string" do
84
81
  markupizer = Markupizer.new SafeBuffer.new("{{test}}")
85
82
  markupizer.should have(1).tags
86
83
  end
87
84
 
85
+ it "should allow change syntax" do
86
+ markupizer = Markupizer.new "[test]", /\[ ?(.*?) ?\]/
87
+ markupizer.should have(1).tags
88
+ end
88
89
 
89
90
  end
90
91
  end
data/xan_markup.gemspec CHANGED
@@ -2,14 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: xan_markup 0.3.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "xan_markup"
8
- s.version = "0.2.0"
9
+ s.version = "0.3.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Grzegorz Derebecki"]
12
- s.date = "2013-05-20"
14
+ s.date = "2015-02-10"
13
15
  s.description = "Simple tag parser"
14
16
  s.email = "grzegorz.derebecki@fdb.pl"
15
17
  s.extra_rdoc_files = [
@@ -36,8 +38,7 @@ Gem::Specification.new do |s|
36
38
  ]
37
39
  s.homepage = "http://github.com/madmax/xan_markup"
38
40
  s.licenses = ["MIT"]
39
- s.require_paths = ["lib"]
40
- s.rubygems_version = "2.0.0"
41
+ s.rubygems_version = "2.2.2"
41
42
  s.summary = "simple tag parser"
42
43
 
43
44
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xan_markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grzegorz Derebecki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-20 00:00:00.000000000 Z
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jeweler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdoc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Simple tag parser
@@ -74,8 +74,8 @@ extra_rdoc_files:
74
74
  - LICENSE.txt
75
75
  - README.md
76
76
  files:
77
- - .document
78
- - .rspec
77
+ - ".document"
78
+ - ".rspec"
79
79
  - Gemfile
80
80
  - Gemfile.lock
81
81
  - LICENSE.txt
@@ -100,19 +100,18 @@ require_paths:
100
100
  - lib
101
101
  required_ruby_version: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - '>='
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
112
  rubyforge_project:
113
- rubygems_version: 2.0.0
113
+ rubygems_version: 2.2.2
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: simple tag parser
117
117
  test_files: []
118
- has_rdoc: