oreilly-snippets 0.0.3 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c050b3514c9fad043f6558927fe6b7e446628f0
4
- data.tar.gz: 7168ec00e39cc8eb811b7bf44a24a0188a71aefb
3
+ metadata.gz: 15d1d4d047093c3b43eb0806790c3fa563cc67ac
4
+ data.tar.gz: 015db5a432fa389c815269492ac308232bdee236
5
5
  SHA512:
6
- metadata.gz: 3770d0c1f2eb97b7730d60928e3f1e1f0335ea9949244a901aca4eb5ff37f647ccd9981e685a7ddc0deca538728f79f9c2a672ab05956bc4c4b3c415c84a8045
7
- data.tar.gz: 5a7031154a6427e11c03168b5736400a7dee1e630e569203294fc99857b160384fe41bea51db053bac9c7dd31a18c73c2fe4b09f06f2582c9b146d535d73524f
6
+ metadata.gz: c5d8bc7dcd875d854fb43339c3d599f93f3d6a7127b1af19f3dd3d67548b436577e6f3f0052be283528ba74e3b74d2996f35d4bff26957f8ba712f7c4b709fc3
7
+ data.tar.gz: 1c83c25ab9d7b3bea22ab4f51fd17d937470f14f780ecaa78437f17c831222b9eeaef8657f6f6397dad10c537ac352dc6f7a19a4aa5274f26e3b1b2a0297ad1e
data/README.md CHANGED
@@ -104,14 +104,17 @@ The file structure I use for this:
104
104
  * Store my pre-processed files in the /pre directory. These are the
105
105
  files which have the snippets. I need to have a special directory
106
106
  because this means Atlas will ignore them, and guard will process
107
- the files into the Asciidoc files used by Atlas.
107
+ the files into the Asciidoc files stored in the root of the directory,
108
+ the files which Atlas will process.
108
109
  * In the directory root I have a bunch of .asciidoc files which are
109
110
  the post-processed files, the files which have the snippets resolved
110
111
  into real code.
111
- * Guard watches both directories. When I make a change to the files in
112
+ * Guard watches both directories (the root and the /pre directory).
113
+ When I make a change to the files in
112
114
  /pre, Guard regenerates the asciidoc files at the top level. When
113
115
  Guard sees one of those files has been changed, it processes them
114
- through Asciidoctor and then builds the HTML.
116
+ through Asciidoctor and then builds the HTML. You could combine these
117
+ into a single watch if you want.
115
118
  * I serve the HTML file using a combination of pow (pow.cx) and
116
119
  config.ru.
117
120
  * Use the live-reload plugin for Chrome:
@@ -1,5 +1,5 @@
1
1
  module Oreilly
2
2
  module Snippets
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -11,17 +11,23 @@ module Oreilly
11
11
  def self.get_content_from_file( spec, identifier, language, sha=nil, numbers=nil )
12
12
  contents = nil
13
13
  line_numbers = nil
14
+ error = false
14
15
 
15
16
  if sha
16
- if numbers
17
- sae = numbers.split( ".." ).map { |d| Integer(d)+1 }
18
- line_numbers = [sae[0], sae[1]]
17
+ if sha[0..2].eql? "xxx"
18
+ contents = "PLACEHOLDER TEXT, UPDATE WITH CORRECT SHA HASH"
19
+ else
20
+ if numbers
21
+ sae = numbers.split( ".." ).map { |d| Integer(d)+1 }
22
+ line_numbers = [sae[0], sae[1]]
23
+ end
24
+ # Use the filename to change into the directory and use git-show
25
+ cwd = Dir.pwd
26
+ Dir.chdir spec if spec
27
+ contents = `git show #{sha}`
28
+ error = true unless contents
29
+ Dir.chdir cwd if spec
19
30
  end
20
- # Use the filename to change into the directory and use git-show
21
- cwd = Dir.pwd
22
- Dir.chdir spec if spec
23
- contents = `git show #{sha}`
24
- Dir.chdir cwd if spec
25
31
  else
26
32
  contents = File.read( spec )
27
33
  end
@@ -39,6 +45,7 @@ module Oreilly
39
45
  rv = contents
40
46
  end
41
47
 
48
+ rv = "INVALID SNIPPET, WARNING" if error
42
49
  # rv = scrub_other_identifiers( contents, comments )
43
50
  rv
44
51
  end
data/spec/process_spec.rb CHANGED
@@ -20,6 +20,13 @@ Put any descriptive text you want here. It will be replaced with the
20
20
  snippet~~~~
21
21
  END
22
22
 
23
+ WITH_PLACEHOLDER_SHA = <<END
24
+ [filename="#{ROOT}", language="js", sha="xxx:test.js"]
25
+ snippet~~~~
26
+ Put any descriptive text you want here. It will be replaced with the
27
+ snippet~~~~
28
+ END
29
+
23
30
  ORIGINAL_CONTENTS = <<END
24
31
  var mod = angular.module( 'coffeetech', [] )
25
32
  mod.controller( 'ShopsCtrl', function( $scope ) {
@@ -170,7 +177,14 @@ describe Oreilly::Snippets do
170
177
  original = lines[2..4].join "\n"
171
178
  output.strip.should == original.strip
172
179
  end
180
+
181
+ it "should indicate placeholder if using xxx as the sha" do
182
+ output = Oreilly::Snippets.process( WITH_PLACEHOLDER_SHA )
183
+ output.should match( /PLACEHOLDER/ )
184
+ end
173
185
  end
186
+
187
+
174
188
 
175
189
  end
176
190
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oreilly-snippets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Dawson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-05 00:00:00.000000000 Z
11
+ date: 2014-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler