snippr 0.15.7 → 0.15.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +10 -2
- data/lib/snippr/processor/dynamics.rb +5 -5
- data/lib/snippr/segment_filter/base.rb +2 -1
- data/snippr.gemspec +6 -6
- data/spec/snippr/processor/dynamics_spec.rb +5 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzY1OGZmOGEzZmU0MjQyMTg3ZWJhZDc4NmY3N2RhNzEyMGQ4MGM5Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjU0NTNiZWExNDY0MWZhMDdjMDllYjM4NWIyMGYzY2U3MGMwYmRkYg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWJjYzQ2ODQ0NmEwNzNhMjkxZTcxODUwMWU5NmQ5N2Q3MDFiOTAwZTUyYjQw
|
10
|
+
OTJlZGU1MDYyMjM5MTFkMDg3NmNkNGFhMzYwMDc4ODQ4YTAyMTZjOTU2MmQy
|
11
|
+
NjkxMjQyYjZkYjM5ODEwOTQ2ZTllNGYyYWM0ZWRiYzU0NmU3MDQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTA4MTQwZjNjNDBhMThhOWU0ZDAxZmRhOWFkZTM5NjEzNTU0MDM5YWNkMjI2
|
14
|
+
MWJhZDhmZDlmOWJhN2QyYjU5MzYwMTRjMTc3ZDAwOWEyOTUyN2RmZjY5N2I0
|
15
|
+
Yjk4Y2M5YzI3MTJkMDAwZjFmMGQ3ZjQzZDQ2Zjg4ZTBmNDk4OTQ=
|
data/README.md
CHANGED
@@ -53,13 +53,13 @@ You can call methods on passed parameters. Calling this:
|
|
53
53
|
|
54
54
|
on ...
|
55
55
|
|
56
|
-
<p>Snippr says: {a_variable.doit}</p>
|
56
|
+
<p>Snippr says: {a_variable.doit()}</p>
|
57
57
|
|
58
58
|
will yield:
|
59
59
|
|
60
60
|
<p>Snippr says: HELLO</p>
|
61
61
|
|
62
|
-
You can even pass parameters to the call. Those *must* be enclosed in quotes ("):
|
62
|
+
You can even pass parameters to the call. Those *must* be enclosed in double quotes ("):
|
63
63
|
|
64
64
|
class Klazz
|
65
65
|
def doitagain(p); "HELLO #{p}"; end
|
@@ -90,6 +90,14 @@ is equivalent to
|
|
90
90
|
TWO
|
91
91
|
{/two_parameters.signature}
|
92
92
|
|
93
|
+
Snippr will check (via #respond_to?) if the method is available on the receiver variable.
|
94
|
+
If that is not what you want and you want to force snippr to call the method on the receiver you can prepend a bang to the variable name (as of Snippr 0.15.8):
|
95
|
+
|
96
|
+
{!a_variable.called_even_if_not_available()}
|
97
|
+
|
98
|
+
That would result in an ``NoMethodError``.
|
99
|
+
This can be very useful if you call a method on a proxy object with dynamic method generation that isn't so polite as to implement a meaningful ``respond_to?`` or ``respond_to_missing?`` (eg. The Draper::HelperProxy)
|
100
|
+
|
93
101
|
### Meta Infos
|
94
102
|
|
95
103
|
A snippet can not only hold content but also meta infos for this snippet.
|
@@ -11,12 +11,12 @@ module Snippr
|
|
11
11
|
def process(content, opts = {})
|
12
12
|
opts.inject(content) do |c, pv|
|
13
13
|
placeholder, value = pv
|
14
|
-
c.gsub(/\{#{placeholder}(?:\.(.*?)\(["]?(.*?)["]?\))?\}/m) do |match|
|
15
|
-
if $
|
16
|
-
method = $
|
17
|
-
params = ($
|
14
|
+
c.gsub(/\{(!?)#{placeholder}(?:\.(.*?)\(["]?(.*?)["]?\))?\}/m) do |match|
|
15
|
+
if $2 && (value.respond_to?($2) || $1 == "!")
|
16
|
+
method = $2
|
17
|
+
params = ($3 || "").gsub(/[\t\r\n]/,"").split("\",\"")
|
18
18
|
value.send(method, *params).to_s
|
19
|
-
elsif $
|
19
|
+
elsif $2
|
20
20
|
match
|
21
21
|
else
|
22
22
|
value.to_s
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
module Snippr
|
2
3
|
module SegmentFilter
|
3
4
|
class Base
|
@@ -16,7 +17,7 @@ module Snippr
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def active?
|
19
|
-
raise
|
20
|
+
raise NotImplementedError("Subclasses need to implement #active?")
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
data/snippr.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = "snippr"
|
4
|
-
s.version = "0.15.
|
4
|
+
s.version = "0.15.8"
|
5
5
|
s.date = Time.now
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
|
-
s.authors = ["Daniel Harrington", "Thomas Jachmann"]
|
8
|
-
s.email = ["me@rubiii.com", "self@thomasjachmann.com"]
|
7
|
+
s.authors = ["Daniel Harrington", "Thomas Jachmann", "Frank Schumacher"]
|
8
|
+
s.email = ["me@rubiii.com", "self@thomasjachmann.com", "frank.schumacher.privat@gmail.com"]
|
9
9
|
s.homepage = "http://github.com/blaulabs/snippr"
|
10
10
|
s.summary = %q{File based content management}
|
11
11
|
s.license = "MIT"
|
@@ -17,16 +17,16 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_runtime_dependency "activesupport"
|
18
18
|
|
19
19
|
s.add_development_dependency "ci_reporter", "~> 1.6.5"
|
20
|
-
s.add_development_dependency "rspec", "~> 2.
|
20
|
+
s.add_development_dependency "rspec", "~> 2.14.0"
|
21
21
|
s.add_development_dependency "mocha", "= 0.11.4"
|
22
|
-
s.add_development_dependency "rake", "~>
|
22
|
+
s.add_development_dependency "rake", "~> 10.0"
|
23
23
|
|
24
24
|
unless ENV["CI"]
|
25
25
|
s.add_development_dependency "debugger"
|
26
26
|
end
|
27
27
|
|
28
28
|
s.files = `git ls-files`.split("\n").reject{ |a| a.start_with?("\"") }
|
29
|
-
s.test_files = `git ls-files --
|
29
|
+
s.test_files = `git ls-files -- spec/*`.split("\n").reject{ |a| a.start_with?("\"") }
|
30
30
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
31
31
|
s.require_paths = ["lib"]
|
32
32
|
end
|
@@ -47,4 +47,9 @@ describe Snippr::Processor::Dynamics do
|
|
47
47
|
subject.process(tpl, :var => Klass.new).should == tpl
|
48
48
|
end
|
49
49
|
|
50
|
+
it "calls a bang(!) method even if the receiver does not respond_to the method" do
|
51
|
+
tpl = "An instance {!var.method_not_exist()}"
|
52
|
+
lambda { subject.process(tpl, :var => Klass.new) }.should raise_error(NoMethodError)
|
53
|
+
end
|
54
|
+
|
50
55
|
end
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snippr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Harrington
|
8
8
|
- Thomas Jachmann
|
9
|
+
- Frank Schumacher
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2013-
|
13
|
+
date: 2013-07-18 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: i18n
|
@@ -59,14 +60,14 @@ dependencies:
|
|
59
60
|
requirements:
|
60
61
|
- - ~>
|
61
62
|
- !ruby/object:Gem::Version
|
62
|
-
version: 2.
|
63
|
+
version: 2.14.0
|
63
64
|
type: :development
|
64
65
|
prerelease: false
|
65
66
|
version_requirements: !ruby/object:Gem::Requirement
|
66
67
|
requirements:
|
67
68
|
- - ~>
|
68
69
|
- !ruby/object:Gem::Version
|
69
|
-
version: 2.
|
70
|
+
version: 2.14.0
|
70
71
|
- !ruby/object:Gem::Dependency
|
71
72
|
name: mocha
|
72
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,14 +88,14 @@ dependencies:
|
|
87
88
|
requirements:
|
88
89
|
- - ~>
|
89
90
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
91
|
+
version: '10.0'
|
91
92
|
type: :development
|
92
93
|
prerelease: false
|
93
94
|
version_requirements: !ruby/object:Gem::Requirement
|
94
95
|
requirements:
|
95
96
|
- - ~>
|
96
97
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
98
|
+
version: '10.0'
|
98
99
|
- !ruby/object:Gem::Dependency
|
99
100
|
name: debugger
|
100
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,6 +115,7 @@ description: This gem provides ways to access file based cms resources from a ra
|
|
114
115
|
email:
|
115
116
|
- me@rubiii.com
|
116
117
|
- self@thomasjachmann.com
|
118
|
+
- frank.schumacher.privat@gmail.com
|
117
119
|
executables: []
|
118
120
|
extensions: []
|
119
121
|
extra_rdoc_files: []
|
@@ -210,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
212
|
version: '0'
|
211
213
|
requirements: []
|
212
214
|
rubyforge_project: snippr
|
213
|
-
rubygems_version: 2.0.
|
215
|
+
rubygems_version: 2.0.4
|
214
216
|
signing_key:
|
215
217
|
specification_version: 4
|
216
218
|
summary: File based content management
|