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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTliMzUzMGVmN2RhZjA2MWNmNTVmODMxZGYzYzEwOTNiYzhhNGQzMg==
4
+ YTI1MTRhNzZiNmZiN2U1NWQ5ODJkMDRjNDEwNmE0MTllMGI3MGRmMg==
5
5
  data.tar.gz: !binary |-
6
- ODE2MTBiM2Y0OTJmMjRlY2FjYzA2MDFkNzBjNTYzYWJjZjgwNzM0NQ==
6
+ YzkwMmViMjc3ZjJlNDA3Y2ZjMTUxNWEzYzI0NDVjMGUwN2ZmMzc3Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2QzODEyOWI5NzI5NmFkNDQ5ZGUzZTE2ZDViOWQ4ZDRjNzgxYmMwYTUzZTkx
10
- MTQyOWU4Y2JkNWQ4YzA2NGU0M2IxNTNjMzc0MTY3NzQ4ZTYyYzg3MjQ5MTU4
11
- YzNjMWY0YTc5NDg3MDIzYWExN2Q3OWMxZjJkNmQzMTQ2ODdmNjE=
9
+ MmFiNzAzMzEzNDk4MmJhMzg2MTMyNTIxOWU3Y2I0OGMwYmZjZWI5Njc5YzVk
10
+ YWMzNzNjNDgzMzg0Nzc3NTZhYTg4ODI4NGNiYzlmOTk4NGYxYjQ4NWQ5NzM2
11
+ ZGVkOTU0N2I3NDk0MTMwNzY1ZDhiN2FhNDliZWU2ZTNlMGZmZDE=
12
12
  data.tar.gz: !binary |-
13
- Y2NkYzAxYzYyYWMxOWY4ODc2NWVjZTNlNzk0ZDUzZGMxNTMxM2ZiZWM3NmFh
14
- Mjk3YjRjNTU5OTYyZTA0NmNlMzBmNWIyOWVlYjNkMDEzOTAyMzI2YTg3ZjIz
15
- MmQxMDZkZmM3MzFiNDY4OWZmODYzOWZhMTlhOThkNjBlMDBkZDk=
13
+ NTljZmQxNDI2NzAxZTVlMjBhMThiM2U2ZDM2OGU5YWY0NzAxNjYwOTRiMGRl
14
+ NmM2OGVjZWVhNjcyZTczMDMwMTMxNmJjZWFjMGNkOTNkMGFlOWNkYjIyNzA4
15
+ ZDFjOGMyNmEyMTI5OTQyNjk4ZDM1ZGY1NjQxYTBkMjhmMjU1ZTg=
@@ -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 ( flatten or @@_config[:flatten] )
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
@@ -1,5 +1,5 @@
1
1
  module Oreilly
2
2
  module Snippets
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
  end
5
5
  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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oreilly-snippets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Dawson