readmexec 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/VERSION +1 -0
  4. data/bin/readmexec +18 -12
  5. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4de006be190a6f8a7d2579851165fe02e4b7f13
4
- data.tar.gz: 7f6111fb8bc94d0aaa2ed4e0ce7fea4bfa06fb96
3
+ metadata.gz: ed4263c9fd56dfd1d46106f720d2f9115218dbc9
4
+ data.tar.gz: ca5eaf76b3bfeaee683759ecbb294afcb52332b0
5
5
  SHA512:
6
- metadata.gz: e4535514c7bde53a83c5d0a2b0bdeb7784a41596dbccb782a693586c6e10a11028d28c845dfbd212b14bc334bdb987f3bdbc8d3cd5c8dbe375fe3b62eebdec11
7
- data.tar.gz: 69cf43d3ad26e90d53845261402bae84ca0140efe5c170931409c8d0c4fe4706db8352b9bcad2058e7da1d88dd22745668aa4181e5d44e3d357b77cc860719a2
6
+ metadata.gz: 6f02d21bc3937c95f14d76d56facebb8fefc4a2ffea7c9c8ca2bce77002fa1034714ca6a36648f01a579f61bcd1fe3f3a2fffc2d3315da6e588d00a466abf437
7
+ data.tar.gz: 6f739fcadd0e29b8618890c45b8a7b0de7f2e5ffafae6009050ea9872a66cf26cd07327466fc0e08d66cee74e3edf8e99918954165208e74223e746a0f6795d5
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  Readmexec grabs commands from your README and runs them.
4
4
 
5
- The idea here is to make README executable and verifiable since this is the only way to make it up to date.
5
+ The idea is to make README executable and verifiable since this is the only way to make sure it stays up to date. You can ensure that by using readmexec locally or on CI and verify that build instructions are still working.
6
+
7
+
6
8
 
7
9
  ## Example
8
10
 
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
data/bin/readmexec CHANGED
@@ -3,8 +3,6 @@
3
3
  BEGIN_REGEX = /\A```(.*)/
4
4
  END_REGEX = /\A```$/
5
5
 
6
- execute = ARGV[0] == "-e"
7
-
8
6
  Block = Struct.new :type, :content do
9
7
  def self.for(buffer)
10
8
  type = buffer.first.match(BEGIN_REGEX)[1]
@@ -17,24 +15,32 @@ Block = Struct.new :type, :content do
17
15
  end
18
16
  end
19
17
 
20
- lines = File.readlines("README.md")
21
- buffer = []
22
- blocks = []
18
+ def code_blocks(lines)
19
+ blocks = []
20
+ buffer = []
23
21
 
24
- lines.each do |line|
25
- if line =~ BEGIN_REGEX .. line =~ END_REGEX
26
- buffer << line
27
- end
22
+ lines.each do |line|
23
+ if line =~ BEGIN_REGEX .. line =~ END_REGEX
24
+ buffer << line
25
+ end
28
26
 
29
- if line =~ END_REGEX
30
- blocks << Block.for(buffer)
31
- buffer = []
27
+ if line =~ END_REGEX
28
+ blocks << Block.for(buffer)
29
+ buffer = []
30
+ end
32
31
  end
32
+ blocks
33
33
  end
34
34
 
35
+ execute = ARGV[0] == "-e"
36
+
37
+ lines = File.readlines("README.md")
38
+ blocks = code_blocks(lines)
39
+
35
40
  blocks.each do |block|
36
41
  block.commands.each do |command|
37
42
  if execute
43
+ $stderr.puts "Running: #{command}"
38
44
  puts `#{command}`
39
45
  else
40
46
  puts command
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readmexec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wojtek Mach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-21 00:00:00.000000000 Z
11
+ date: 2014-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -51,6 +51,7 @@ files:
51
51
  - LICENSE.txt
52
52
  - README.md
53
53
  - Rakefile
54
+ - VERSION
54
55
  - bin/readmexec
55
56
  - lib/readmexec.rb
56
57
  - lib/readmexec/version.rb