oreilly-snippets 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/oreilly/snippets.rb +4 -2
- data/lib/oreilly/snippets/version.rb +1 -1
- data/spec/process_spec.rb +15 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTI1MTRhNzZiNmZiN2U1NWQ5ODJkMDRjNDEwNmE0MTllMGI3MGRmMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzkwMmViMjc3ZjJlNDA3Y2ZjMTUxNWEzYzI0NDVjMGUwN2ZmMzc3Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmFiNzAzMzEzNDk4MmJhMzg2MTMyNTIxOWU3Y2I0OGMwYmZjZWI5Njc5YzVk
|
10
|
+
YWMzNzNjNDgzMzg0Nzc3NTZhYTg4ODI4NGNiYzlmOTk4NGYxYjQ4NWQ5NzM2
|
11
|
+
ZGVkOTU0N2I3NDk0MTMwNzY1ZDhiN2FhNDliZWU2ZTNlMGZmZDE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTljZmQxNDI2NzAxZTVlMjBhMThiM2U2ZDM2OGU5YWY0NzAxNjYwOTRiMGRl
|
14
|
+
NmM2OGVjZWVhNjcyZTczMDMwMTMxNmJjZWFjMGNkOTNkMGFlOWNkYjIyNzA4
|
15
|
+
ZDFjOGMyNmEyMTI5OTQyNjk4ZDM1ZGY1NjQxYTBkMjhmMjU1ZTg=
|
data/lib/oreilly/snippets.rb
CHANGED
@@ -55,8 +55,9 @@ module Oreilly
|
|
55
55
|
rv = contents
|
56
56
|
end
|
57
57
|
|
58
|
+
# puts "Should we skip flattening? #{language}"
|
58
59
|
unless skip_flattening( language )
|
59
|
-
if
|
60
|
+
if flatten or @@_config[:flatten]
|
60
61
|
rv = flatten_it( rv )
|
61
62
|
end
|
62
63
|
end
|
@@ -67,7 +68,8 @@ module Oreilly
|
|
67
68
|
end
|
68
69
|
|
69
70
|
def self.skip_flattening( language )
|
70
|
-
rv = ( !!@@_config[:skip_flattening] and !!@@_config[:skip_flattening][language.to_sym] )
|
71
|
+
rv = ( !!@@_config[:skip_flattening] and language and !!@@_config[:skip_flattening][language.to_sym] )
|
72
|
+
# rv = ( !!@@_config[:skip_flattening] and !!@@_config[:skip_flattening][language.to_sym] )
|
71
73
|
# puts "Skipping flattening for #{language} / #{@@_config[:skip_flattening][language.to_sym]} / #{rv} / (#{@@_config[:skip_flattening].inspect})" if rv
|
72
74
|
rv
|
73
75
|
end
|
data/spec/process_spec.rb
CHANGED
@@ -62,6 +62,14 @@ specified code snippet when you build ebook outputs
|
|
62
62
|
snippet~~~~
|
63
63
|
END
|
64
64
|
|
65
|
+
NO_LANGUAGE_FOR_FLATTENING = <<END
|
66
|
+
[filename="spec/fixtures/factorial.java", lines="3..5"]
|
67
|
+
snippet~~~~
|
68
|
+
Put any descriptive text you want here. It will be replaced with the
|
69
|
+
specified code snippet when you build ebook outputs
|
70
|
+
snippet~~~~
|
71
|
+
END
|
72
|
+
|
65
73
|
TEMPLATE = <<END
|
66
74
|
|
67
75
|
ABC
|
@@ -221,6 +229,13 @@ END
|
|
221
229
|
string.should eq( output )
|
222
230
|
end
|
223
231
|
|
232
|
+
it "should not crash when flattening if no language is specified" do
|
233
|
+
Oreilly::Snippets.config( flatten: true, skip_flattening: { java: true } )
|
234
|
+
lambda {
|
235
|
+
Oreilly::Snippets.process( NO_LANGUAGE_FOR_FLATTENING )
|
236
|
+
}.should_not raise_error()
|
237
|
+
end
|
238
|
+
|
224
239
|
it "should support flattening with tabs" do
|
225
240
|
output = Oreilly::Snippets.process( FLATTEN_WITH_TABS )
|
226
241
|
output.should == @tabs_flattened
|