apropos 0.1.3 → 0.1.4
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/apropos/extension_parser.rb +12 -1
- data/lib/apropos/version.rb +1 -1
- data/spec/apropos/extension_parser_spec.rb +41 -22
- data/spec/stylesheets_spec.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad98be4a87f9fb9605a909f04e23568f1b145c46
|
4
|
+
data.tar.gz: 924c293bb77515903932e9d113de7a32a2de367e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c22b53d22e056c57a2fcd326f2df8e4d41a6bc1795f598050683bcef5e44258df65bfbd45605fc093ec5ddfe36d50e63c16713911dc5c121235c5697e6c9fd51
|
7
|
+
data.tar.gz: 74621277cb2190c35a8f575a6725db5a9e6b405f4faf848092c1176c59983a58a4d6881aea326e0524b4fe785645736b20658c0629a0857fdfde38feb45df38c
|
data/CHANGELOG.md
CHANGED
@@ -21,7 +21,7 @@ module Apropos
|
|
21
21
|
attr_reader :pattern
|
22
22
|
|
23
23
|
def initialize(pattern, &block)
|
24
|
-
@pattern = pattern
|
24
|
+
@pattern = generate_pattern(pattern)
|
25
25
|
@match_block = block
|
26
26
|
end
|
27
27
|
|
@@ -31,5 +31,16 @@ module Apropos
|
|
31
31
|
@match_block.call(matchdata)
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def generate_pattern(pattern)
|
38
|
+
case pattern
|
39
|
+
when String
|
40
|
+
%r(^#{Regexp.escape(pattern)}$)
|
41
|
+
else
|
42
|
+
pattern
|
43
|
+
end
|
44
|
+
end
|
34
45
|
end
|
35
46
|
end
|
data/lib/apropos/version.rb
CHANGED
@@ -31,41 +31,60 @@ describe Apropos::ExtensionParser do
|
|
31
31
|
described_class.each_parser do |parser|
|
32
32
|
vals << parser.pattern
|
33
33
|
end
|
34
|
-
vals.should ==
|
34
|
+
vals.should == [
|
35
|
+
/^2x$/,
|
36
|
+
/^medium$/,
|
37
|
+
/^fr$/,
|
38
|
+
]
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
42
|
describe "#match" do
|
39
43
|
let(:locale_pattern) { /^([a-z]{2})$/ }
|
40
44
|
|
41
|
-
|
42
|
-
|
43
|
-
parser
|
44
|
-
|
45
|
+
context "with a string pattern" do
|
46
|
+
let(:pattern) { 'extra-small' }
|
47
|
+
let(:parser) { described_class.new(pattern) { |_| true } }
|
48
|
+
|
49
|
+
it "matches the exact string" do
|
50
|
+
parser.match(pattern).should == true
|
51
|
+
end
|
52
|
+
|
53
|
+
it "does not match a substring" do
|
54
|
+
parser.match('small').should be_nil
|
45
55
|
end
|
46
|
-
parser.match('fr')
|
47
|
-
lastmatch[1].should == 'fr'
|
48
56
|
end
|
49
57
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
58
|
+
context "with a regular expression pattern" do
|
59
|
+
it "calls the block when the extension matches" do
|
60
|
+
lastmatch = nil
|
61
|
+
parser = described_class.new(locale_pattern) do |match|
|
62
|
+
lastmatch = match
|
54
63
|
end
|
55
|
-
parser.match('
|
56
|
-
|
57
|
-
|
64
|
+
parser.match('fr')
|
65
|
+
lastmatch[1].should == 'fr'
|
66
|
+
end
|
67
|
+
|
68
|
+
it "doesn't call the block when there is no match" do
|
69
|
+
expect {
|
70
|
+
parser = described_class.new(/^fr$/) do |match|
|
71
|
+
raise
|
72
|
+
end
|
73
|
+
parser.match('en').should be_nil
|
74
|
+
}.to_not raise_error
|
75
|
+
end
|
58
76
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
77
|
+
it "allows the block to return a nil value" do
|
78
|
+
parser = described_class.new(locale_pattern) do |match|
|
79
|
+
if match[1] == 'fr'
|
80
|
+
true
|
81
|
+
else
|
82
|
+
nil
|
83
|
+
end
|
65
84
|
end
|
85
|
+
parser.match('fr').should == true
|
86
|
+
parser.match('en').should be_nil
|
66
87
|
end
|
67
|
-
parser.match('fr').should == true
|
68
|
-
parser.match('en').should be_nil
|
69
88
|
end
|
70
89
|
end
|
71
90
|
end
|
data/spec/stylesheets_spec.rb
CHANGED
@@ -98,16 +98,20 @@ describe 'stylesheets' do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
it "allows setting breakpoints" do
|
101
|
-
stub_files(%w[hero.jpg hero.medium.jpg hero.large.jpg])
|
101
|
+
stub_files(%w[hero.jpg hero.extra-small.jpg hero.small.jpg hero.medium.jpg hero.large.jpg hero.extra-large.jpg])
|
102
102
|
@scss_file = %Q{
|
103
|
-
$apropos-breakpoints: (medium, 768px), (large, 1024px);
|
103
|
+
$apropos-breakpoints: ("extra-small", 374px), ("small", 480px), ("medium", 768px), ("large", 1024px), ("extra-large", 1292px);
|
104
104
|
@import "apropos";
|
105
105
|
.foo {
|
106
106
|
@include apropos-bg-variants('hero.jpg');
|
107
107
|
}
|
108
108
|
}
|
109
|
+
css_file.should include(".foo { background-image: url('/hero.jpg'); }")
|
110
|
+
css_file.should include("@media (min-width: 374px) { .foo { background-image: url('/hero.extra-small.jpg'); } }")
|
111
|
+
css_file.should include("@media (min-width: 480px) { .foo { background-image: url('/hero.small.jpg'); } }")
|
109
112
|
css_file.should include("@media (min-width: 768px) { .foo { background-image: url('/hero.medium.jpg'); } }")
|
110
113
|
css_file.should include("@media (min-width: 1024px) { .foo { background-image: url('/hero.large.jpg'); } }")
|
114
|
+
css_file.should include("@media (min-width: 1292px) { .foo { background-image: url('/hero.extra-large.jpg'); } }")
|
111
115
|
end
|
112
116
|
end
|
113
117
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apropos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Gilder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: compass
|