snippr 0.15.21 → 0.15.22

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd5e914f8d8ff99c134b3c0e3ae285bd4d7579c9
4
- data.tar.gz: a4f5bb34d2ddf5b38704bdee282b5e2d92a9e21b
3
+ metadata.gz: 7285f9e6b5d7271ae0d46e93fc3b4fdb630e0af0
4
+ data.tar.gz: c7c3d8a708304c4184cdbb40321bb3a72aea8882
5
5
  SHA512:
6
- metadata.gz: 4989ca6050828708d6dc54134185ead7e052913913a7b3f90586f3430f41d841bc9aa7f191ca1c3b05ea224ebfa25383876696ab7ba96d6e9ed4017d9174a899
7
- data.tar.gz: 203ed4d06059918c6eea51c21b47f52e37ed0e5991650bf14b4cd01bc6d026fb331b51ee4ca341baeba00d54fc199dc738943202698a6c4508dfc4261e23238d
6
+ metadata.gz: e3ff81c780ad5b2636f0620bd613ef2d242b2b782f04c55f64419bdbf8a06185f1bbc1908ae70eb2cf1b883874b7751935878d4c7f9fa76e621e189d33a44a3f
7
+ data.tar.gz: cb86a46ff9c499bd1be46960df280bb86b75da4827eec12afa6dfaacfe5be75530015bb28ccd45a3e27e854ed02cc5ca38a45e2580c4da00e82afbb67a0401e2
@@ -15,19 +15,19 @@ module Snippr
15
15
 
16
16
  matches.each do |match_data|
17
17
  replacement = match_data[:all]
18
- value = opts[match_data[:placeholder].to_sym]
18
+ placeholder = match_data[:placeholder].strip.to_sym
19
+ value = opts[placeholder]
19
20
  if match_data[:method] && (value.respond_to?(match_data[:method]) || match_data[:respond_to_check] == "!")
20
21
  params = (match_data[:parameters] || "").gsub(/[\t\r\n]/,"").split("\",\"")
21
22
  replacement = value.send(match_data[:method], *params).to_s
22
23
  elsif match_data[:method]
23
24
  replacement = match_data[:all]
24
- else
25
+ elsif value
25
26
  replacement = value.to_s
26
27
  end
27
28
 
28
29
  # default set?
29
30
  replacement = match_data[:default_when_empty].strip if replacement.empty? && match_data[:default_when_empty]
30
-
31
31
  content.gsub!(match_data[:all], replacement)
32
32
  end
33
33
  content
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "snippr"
4
- s.version = '0.15.21'
4
+ s.version = '0.15.22'
5
5
  s.date = Time.now
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Daniel Harrington", "Thomas Jachmann", "Frank Schumacher"]
@@ -0,0 +1,6 @@
1
+ <style>
2
+ .clazz {
3
+ }
4
+
5
+ .clazz {}
6
+ </style>
@@ -10,16 +10,16 @@ describe "Snippr::Clock" do
10
10
  describe ".now" do
11
11
  # use TimeCop here
12
12
  it "returns a time object" do
13
- Snippr::Clock.now.should be_a(Time)
13
+ expect(Snippr::Clock.now).to be_a(Time)
14
14
  end
15
15
 
16
16
  it "returns the current time if no interval is given" do
17
- Snippr::Clock.now.to_i.should == Time.now.to_i
17
+ expect(Snippr::Clock.now.to_i).to eq(Time.now.to_i)
18
18
  end
19
19
 
20
20
  it "returns the modified time if an interval is set" do
21
21
  Snippr::Clock.interval="+1d"
22
- Snippr::Clock.now.to_i.should == (Time.now + 86400).to_i
22
+ expect(Snippr::Clock.now.to_i).to eq((Time.now + 86400).to_i)
23
23
  end
24
24
 
25
25
  end
@@ -28,50 +28,50 @@ describe "Snippr::Clock" do
28
28
  it "resets the time" do
29
29
  Snippr::Clock.interval="+1d"
30
30
  Snippr::Clock.reset
31
- Snippr::Clock.now.to_i.should == Time.now.to_i
31
+ expect(Snippr::Clock.now.to_i).to eq(Time.now.to_i)
32
32
  end
33
33
  end
34
34
 
35
35
  describe ".interval=" do
36
36
  it "sets the time forward" do
37
37
  Snippr::Clock.interval="+1m"
38
- Snippr::Clock.interval.should == +60
38
+ expect(Snippr::Clock.interval).to eq +60
39
39
  end
40
40
 
41
41
  it "sets the time backward" do
42
42
  Snippr::Clock.interval="-1m"
43
- Snippr::Clock.interval.should == -60
43
+ expect(Snippr::Clock.interval).to eq(-60)
44
44
  end
45
45
 
46
46
  it "accepts seconds as scale" do
47
47
  Snippr::Clock.interval="+1s"
48
- Snippr::Clock.interval.should == +1
48
+ expect(Snippr::Clock.interval).to eq +1
49
49
  end
50
50
 
51
51
  it "accepts minutes as scale" do
52
52
  Snippr::Clock.interval="+1m"
53
- Snippr::Clock.interval.should == +60
53
+ expect(Snippr::Clock.interval).to eq +60
54
54
  end
55
55
 
56
56
  it "accepts hours as scale" do
57
57
  Snippr::Clock.interval="+1h"
58
- Snippr::Clock.interval.should == +3600
58
+ expect(Snippr::Clock.interval).to eq +3600
59
59
  end
60
60
 
61
61
  it "accepts days as scale" do
62
62
  Snippr::Clock.interval="+1d"
63
- Snippr::Clock.interval.should == +86400
63
+ expect(Snippr::Clock.interval).to eq +86400
64
64
  end
65
65
 
66
66
  it "doesn't set the time if the interval is invalid" do
67
67
  Snippr::Clock.interval="blubb"
68
- Snippr::Clock.interval.should == 1
68
+ expect(Snippr::Clock.interval).to eq(1)
69
69
  end
70
70
  end
71
71
 
72
72
  describe "interval" do
73
73
  it "returns the interval in seconds" do
74
- Snippr::Clock.interval.should == 0
74
+ expect(Snippr::Clock.interval).to eq(0)
75
75
  end
76
76
  end
77
77
  end
@@ -6,9 +6,9 @@ describe Snippr::I18n do
6
6
 
7
7
  it "should store the enabled state" do
8
8
  subject.enabled = nil
9
- subject.enabled?.should == false
9
+ expect(subject.enabled?).to eq(false)
10
10
  subject.enabled = true
11
- subject.enabled?.should == true
11
+ expect(subject.enabled?).to eq(true)
12
12
  end
13
13
 
14
14
  end
@@ -17,12 +17,12 @@ describe Snippr::I18n do
17
17
 
18
18
  it "should return an empty string when I18n is not enabled" do
19
19
  subject.enabled = false
20
- subject.locale.should == ''
20
+ expect(subject.locale).to eq('')
21
21
  end
22
22
 
23
23
  it "should return the locale string when I18n is enabled" do
24
24
  subject.enabled = true
25
- subject.locale.should == "_#{I18n.locale}"
25
+ expect(subject.locale).to eq("_#{I18n.locale}")
26
26
  end
27
27
 
28
28
  end
@@ -7,12 +7,12 @@ describe Snippr::Links do
7
7
 
8
8
  it "defaults to [/^#/, /^[a-z]+:/i]" do
9
9
  subject.adjust_urls_except = nil
10
- subject.adjust_urls_except.should == [/^#/, /^[a-z]+:/i]
10
+ expect(subject.adjust_urls_except).to eq([/^#/, /^[a-z]+:/i])
11
11
  end
12
12
 
13
13
  it "stores exceptions" do
14
14
  subject.adjust_urls_except = [/^cms.*/]
15
- subject.adjust_urls_except.should == [/^cms.*/]
15
+ expect(subject.adjust_urls_except).to eq([/^cms.*/])
16
16
  end
17
17
 
18
18
  end
@@ -20,22 +20,22 @@ describe Snippr::Links do
20
20
  describe ".adjust_link" do
21
21
 
22
22
  it "returns an a without href unchanged" do
23
- subject.adjust_link('<a name="headline"/>').should == '<a name="headline"/>'
23
+ expect(subject.adjust_link('<a name="headline"/>')).to eq('<a name="headline"/>')
24
24
  end
25
25
 
26
26
  it "adjusts the href to the adjustd_url" do
27
- subject.should_receive(:adjust_url).with('url').and_return('adjustd_url')
28
- subject.adjust_link('<a onclick="return true;" href="url" class="link">test</a>').should == '<a onclick="return true;" href="adjustd_url" class="link">test</a>'
27
+ expect(subject).to receive(:adjust_url).with('url').and_return('adjustd_url')
28
+ expect(subject.adjust_link('<a onclick="return true;" href="url" class="link">test</a>')).to eq('<a onclick="return true;" href="adjustd_url" class="link">test</a>')
29
29
  end
30
30
 
31
31
  it "adds an onclick when href starts with popup:" do
32
- subject.should_receive(:adjust_url).with('popup_url').and_return('adjustd_url')
33
- subject.adjust_link('<a href="popup:popup_url" class="link">test</a>').should == '<a href="adjustd_url" class="link" onclick="if (typeof popup == \'undefined\') { return true; } else { popup(this); return false; }">test</a>'
32
+ expect(subject).to receive(:adjust_url).with('popup_url').and_return('adjustd_url')
33
+ expect(subject.adjust_link('<a href="popup:popup_url" class="link">test</a>')).to eq('<a href="adjustd_url" class="link" onclick="if (typeof popup == \'undefined\') { return true; } else { popup(this); return false; }">test</a>')
34
34
  end
35
35
 
36
36
  it "replaces an existing onclick when href starts with popup:" do
37
- subject.should_receive(:adjust_url).with('url').and_return('adjustd_url')
38
- subject.adjust_link('<a onclick="return true;" href="popup://url" class="link">test</a>').should == '<a onclick="if (typeof popup == \'undefined\') { return true; } else { popup(this); return false; }" href="adjustd_url" class="link">test</a>'
37
+ expect(subject).to receive(:adjust_url).with('url').and_return('adjustd_url')
38
+ expect(subject.adjust_link('<a onclick="return true;" href="popup://url" class="link">test</a>')).to eq('<a onclick="if (typeof popup == \'undefined\') { return true; } else { popup(this); return false; }" href="adjustd_url" class="link">test</a>')
39
39
  end
40
40
 
41
41
  end
@@ -47,40 +47,40 @@ describe Snippr::Links do
47
47
  end
48
48
 
49
49
  it "leaves absolute links (http) as is" do
50
- subject.adjust_url('http://www.blaulabs.de').should == 'http://www.blaulabs.de'
50
+ expect(subject.adjust_url('http://www.blaulabs.de')).to eq('http://www.blaulabs.de')
51
51
  end
52
52
 
53
53
  it "leaves absolute links (https) as is" do
54
- subject.adjust_url('https://www.blaulabs.de').should == 'https://www.blaulabs.de'
54
+ expect(subject.adjust_url('https://www.blaulabs.de')).to eq('https://www.blaulabs.de')
55
55
  end
56
56
 
57
57
  it "leaves special links (mailto) as is" do
58
- subject.adjust_url('mailto:info@blau.de').should == 'mailto:info@blau.de'
58
+ expect(subject.adjust_url('mailto:info@blau.de')).to eq('mailto:info@blau.de')
59
59
  end
60
60
 
61
61
  it "converts relative links to server absolute links" do
62
- subject.adjust_url('relative.html').should == '/root/relative.html'
62
+ expect(subject.adjust_url('relative.html')).to eq('/root/relative.html')
63
63
  end
64
64
 
65
65
  it "converts app absolute links to server absolute links" do
66
- subject.adjust_url('/absolute.html').should == '/root/absolute.html'
66
+ expect(subject.adjust_url('/absolute.html')).to eq('/root/absolute.html')
67
67
  end
68
68
 
69
69
  it "leaves internal links (#) as is" do
70
- subject.adjust_url('#aname').should == '#aname'
70
+ expect(subject.adjust_url('#aname')).to eq('#aname')
71
71
  end
72
72
 
73
73
  it "converts links excepted in next test to server absolute links" do
74
- subject.adjust_url('/cms/excepted.html').should == '/root/cms/excepted.html'
74
+ expect(subject.adjust_url('/cms/excepted.html')).to eq('/root/cms/excepted.html')
75
75
  end
76
76
 
77
77
  it "leaves server absolute links as is" do
78
- subject.adjust_url('/root/bla/absolute.html').should == '/root/bla/absolute.html'
78
+ expect(subject.adjust_url('/root/bla/absolute.html')).to eq('/root/bla/absolute.html')
79
79
  end
80
80
 
81
81
  it "leaves excepted links as is" do
82
82
  subject.adjust_urls_except << /^\/cms\//
83
- subject.adjust_url('/cms/excepted.html').should == '/cms/excepted.html'
83
+ expect(subject.adjust_url('/cms/excepted.html')).to eq('/cms/excepted.html')
84
84
  end
85
85
 
86
86
  end
@@ -88,7 +88,7 @@ describe Snippr::Links do
88
88
  describe ".relative_url_root" do
89
89
 
90
90
  it "returns / without rails" do
91
- subject.relative_url_root.should == '/'
91
+ expect(subject.relative_url_root).to eq('/')
92
92
  end
93
93
 
94
94
  context "with rails" do
@@ -103,32 +103,32 @@ describe Snippr::Links do
103
103
 
104
104
  it "returns / with relative_url_root set to nil" do
105
105
  allow(ActionController::Base).to receive(:config).and_return(double :relative_url_root => nil)
106
- subject.relative_url_root.should == '/'
106
+ expect(subject.relative_url_root).to eq('/')
107
107
  end
108
108
 
109
109
  it "returns / with relative_url_root set to empty string" do
110
110
  allow(ActionController::Base).to receive(:config).and_return(double :relative_url_root => '')
111
- subject.relative_url_root.should == '/'
111
+ expect(subject.relative_url_root).to eq('/')
112
112
  end
113
113
 
114
114
  it "returns / with relative_url_root set to /" do
115
115
  allow(ActionController::Base).to receive(:config).and_return(double :relative_url_root => '/')
116
- subject.relative_url_root.should == '/'
116
+ expect(subject.relative_url_root).to eq('/')
117
117
  end
118
118
 
119
119
  it "returns /root/ with relative_url_root set to root" do
120
120
  allow(ActionController::Base).to receive(:config).and_return(double :relative_url_root => 'root')
121
- subject.relative_url_root.should == '/root/'
121
+ expect(subject.relative_url_root).to eq('/root/')
122
122
  end
123
123
 
124
124
  it "returns /root/ with relative_url_root set to /root" do
125
125
  allow(ActionController::Base).to receive(:config).and_return(double :relative_url_root => '/root')
126
- subject.relative_url_root.should == '/root/'
126
+ expect(subject.relative_url_root).to eq('/root/')
127
127
  end
128
128
 
129
129
  it "returns /root/ with relative_url_root set to /root/" do
130
130
  allow(ActionController::Base).to receive(:config).and_return(double :relative_url_root => '/root/')
131
- subject.relative_url_root.should == '/root/'
131
+ expect(subject.relative_url_root).to eq('/root/')
132
132
  end
133
133
 
134
134
  end
@@ -11,7 +11,7 @@ describe Snippr::MetaData do
11
11
  it 'returns an array with 2 elements [contentstring, metahash]' do
12
12
  result = Snippr::MetaData.extract([:content], TEST_CONTENT)
13
13
  expect(result).to be_a Array
14
- expect(result).to have(2).items
14
+ expect(result.size).to eq(2)
15
15
  expect(result.first).to be_a String
16
16
  expect(result.second).to be_a Hash
17
17
  end
@@ -3,11 +3,11 @@ require "spec_helper"
3
3
  describe Snippr::Normalizer::Camelizer do
4
4
 
5
5
  it "should leave a string as is" do
6
- subject.normalize("blaHui_ja").should == "blaHui_ja"
6
+ expect(subject.normalize("blaHui_ja")).to eq("blaHui_ja")
7
7
  end
8
8
 
9
9
  it "should lower camelize a symbol" do
10
- subject.normalize(:symbol_with_separators).should == "symbolWithSeparators"
10
+ expect(subject.normalize(:symbol_with_separators)).to eq("symbolWithSeparators")
11
11
  end
12
12
 
13
13
  end
@@ -17,7 +17,7 @@ describe Snippr::Normalizer::DeRester do
17
17
  :update => "edit"
18
18
  }.each do |replace, with|
19
19
  it "should replace #{replace.inspect} in a path with #{with.inspect}" do
20
- subject.normalize(replace).should == with
20
+ expect(subject.normalize(replace)).to eq(with)
21
21
  end
22
22
  end
23
23
 
@@ -6,13 +6,13 @@ describe Snippr::Normalizer do
6
6
  describe ".normalizers" do
7
7
 
8
8
  it "is an array" do
9
- subject.normalizers.should be_an(Array)
9
+ expect(subject.normalizers).to be_an(Array)
10
10
  end
11
11
 
12
12
  it "has a set of default normalizers" do
13
13
  normalizers = subject.normalizers
14
- normalizers.size.should == 1
15
- normalizers[0].should be_a(Snippr::Normalizer::Camelizer)
14
+ expect(normalizers.size).to eq(1)
15
+ expect(normalizers[0]).to be_a(Snippr::Normalizer::Camelizer)
16
16
  end
17
17
 
18
18
  end
@@ -29,10 +29,10 @@ describe Snippr::Normalizer do
29
29
 
30
30
  it "calls normalize on all normalizers, passing the path element between them and returning the last result" do
31
31
  subject.normalizers.each_with_index do |normalizer, i|
32
- normalizer.should respond_to(:normalize)
32
+ expect(normalizer).to respond_to(:normalize)
33
33
  expect(normalizer).to receive(:normalize).with(i.to_s).and_return((i + 1).to_s)
34
34
  end
35
- subject.normalize('0').should == subject.normalizers.size.to_s
35
+ expect(subject.normalize('0')).to eq(subject.normalizers.size.to_s)
36
36
  end
37
37
 
38
38
  end
@@ -46,12 +46,12 @@ describe Snippr::Normalizer do
46
46
 
47
47
  it "adds the normalizer if an class" do
48
48
  subject.add(Snippr::Normalizer::DeRester.new)
49
- subject.normalizers.should have(2).normalizers
49
+ expect(subject.normalizers.size).to eq(2)
50
50
  end
51
51
 
52
52
  it "adds the normalizers if an array" do
53
53
  subject.add([Snippr::Normalizer::DeRester.new, Snippr::Normalizer::DeRester.new])
54
- subject.normalizers.should have(3).normalizers
54
+ expect(subject.normalizers.size).to eq(3)
55
55
  end
56
56
 
57
57
  end
@@ -10,14 +10,14 @@ describe Snippr::Path do
10
10
  end
11
11
 
12
12
  it "stores the path if set as string" do
13
- subject.path.should == ''
13
+ expect(subject.path).to eq('')
14
14
  subject.path = 'path'
15
- subject.path.should == 'path'
15
+ expect(subject.path).to eq('path')
16
16
  end
17
17
 
18
18
  it "stores and defers the path evaluation if passed a lambda" do
19
19
  subject.path = lambda { "WOW LAMBDA ACTION!" }
20
- subject.path.should == "WOW LAMBDA ACTION!"
20
+ expect(subject.path).to eq("WOW LAMBDA ACTION!")
21
21
  end
22
22
 
23
23
  end
@@ -27,7 +27,7 @@ describe Snippr::Path do
27
27
  it "calls Snippr::Normalizer.normalize with all names and return normalized result" do
28
28
  expect(Snippr::Normalizer).to receive(:normalize).with("a").and_return("AA")
29
29
  expect(Snippr::Normalizer).to receive(:normalize).with(:b).and_return("BB")
30
- subject.normalize_name("a", :b).should == "AA/BB"
30
+ expect(subject.normalize_name("a", :b)).to eq("AA/BB")
31
31
  end
32
32
 
33
33
  end
@@ -39,11 +39,11 @@ describe Snippr::Path do
39
39
  end
40
40
 
41
41
  it "joins path and name (with extension)" do
42
- subject.path_from_name('name', 'snip').should == 'path/name.snip'
42
+ expect(subject.path_from_name('name', 'snip')).to eq('path/name.snip')
43
43
  end
44
44
 
45
45
  it "joins path and name (without extension)" do
46
- subject.path_from_name('file').should == 'path/file'
46
+ expect(subject.path_from_name('file')).to eq('path/file')
47
47
  end
48
48
 
49
49
  end
@@ -57,11 +57,11 @@ describe Snippr::Path do
57
57
  end
58
58
 
59
59
  it "returns a list of all snippr names" do
60
- subject.list(:topup).should == [:some_error, :success]
60
+ expect(subject.list(:topup)).to eq([:some_error, :success])
61
61
  end
62
62
 
63
63
  it "returns an empty array for non existant dirs" do
64
- subject.list(:doesnotexist).should == []
64
+ expect(subject.list(:doesnotexist)).to eq([])
65
65
  end
66
66
 
67
67
  end
@@ -74,16 +74,16 @@ describe Snippr::Path do
74
74
 
75
75
  it "returns a list of all snippr names of the current locale (de)" do
76
76
  I18n.locale = :de
77
- subject.list(:i18n).should == [:list, :shop]
77
+ expect(subject.list(:i18n)).to eq([:list, :shop])
78
78
  end
79
79
 
80
80
  it "returns a list of all snippr names of the current locale (en)" do
81
81
  I18n.locale = :en
82
- subject.list(:i18n).should == [:shop]
82
+ expect(subject.list(:i18n)).to eq([:shop])
83
83
  end
84
84
 
85
85
  it "returns an empty array for non existant dirs" do
86
- subject.list(:doesnotexist).should == []
86
+ expect(subject.list(:doesnotexist)).to eq([])
87
87
  end
88
88
 
89
89
  end