md-ruby-eval 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 976f3b3c85f20c71f00ccdbaee4fb6ccb47c5da7
4
- data.tar.gz: ae934cd01a7893ebc779df854bedb76d8b01ed56
2
+ SHA256:
3
+ metadata.gz: dec15b3f48af5f743b96c4a8c8afceee6f6f6819cc16fad51a91dfd06e531462
4
+ data.tar.gz: ab6707c2f223488c986bac361c597e496123b5af8f935af8567971af0cb83e35
5
5
  SHA512:
6
- metadata.gz: d242cec222b5c3cdda8ccca28f86a8dee722c90c37130ea829892232a0c2ed1140654bf859c0d6daa9cf4f3be1122c530ae307647aeaddadd5ced88065158a7b
7
- data.tar.gz: 4697d9a800916ab71a16e777515e97666cdfa441b86eb8b6be5e275811c990f77b30780ab6c5e4b6a517cc5cb37ce9b5186c5c4e53d7c0522c387a4f0ac30e21
6
+ metadata.gz: bf6f4607c2f0dafcc31cce0e44753fafaa511cf6101ff93e3cc4b2cbadc136bd0765805efc65437bfc14cd2512a14cc24981669a68961b0aedd509cb457a3848
7
+ data.tar.gz: 01d08f8118ec12274801803b2be8591e472af988849a4b13c6966131e229f2089b721cd8db760eb918fe3d1567718cf83aeaa01a2e7fde3b8706782295c4b789
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Usage: md-ruby-eval [options] --auto
4
4
  md-ruby-eval [options] INPUT_FILE OUTPUT_FILE
5
- md-ruby-eval --help
5
+ md-ruby-eval --help
6
6
 
7
7
  Evaluates Ruby examples in MD files.
8
8
 
@@ -60,7 +60,7 @@ added to the output as a comment, which is useful for method and class definitio
60
60
  c.md
61
61
 
62
62
  - `md-ruby-eval --auto` call the tool
63
-
63
+
64
64
  Creates files `a.out.md` and `b.out.md` evaluating each in isolated environments, before
65
65
  `a.out.md` is evaluated `a.init.md` is required to setup its environment. `c.md` is ignored
66
66
  since it does not have `in` marker.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -7,10 +7,15 @@ to_require = []
7
7
  indentation = 40
8
8
  line_length = 79
9
9
  auto = false
10
+ dir = Dir.pwd
10
11
 
11
12
  OptionParser.new do |opts|
12
13
  opts.banner = File.read(__dir__ + '/../README.md') + "\n## Options:\n\n"
13
14
 
15
+ opts.on('-d', '--directory DIR', 'Working directory') do |v|
16
+ dir = File.expand_path v
17
+ end
18
+
14
19
  opts.on('-r', '--require FILE', 'Require given files before processing the MD files') do |v|
15
20
  to_require << v
16
21
  end
@@ -33,25 +38,27 @@ OptionParser.new do |opts|
33
38
  end
34
39
  end.parse!
35
40
 
36
- if auto
37
- input_paths = Dir.glob('*.in.md')
38
- input_paths.each do |input_path|
41
+ Dir.chdir dir do
42
+ if auto
43
+ input_paths = Dir.glob('*.in.md')
44
+ input_paths.each do |input_path|
39
45
 
40
- pid = fork do
41
- to_require.each { |p| require p }
42
- init_path = File.basename(input_path, '.in.md') + '.init.rb'
43
- if File.exist? init_path
44
- puts "using: #{init_path}"
45
- load init_path
46
+ pid = fork do
47
+ to_require.each { |p| require p }
48
+ init_path = File.basename(input_path, '.in.md') + '.init.rb'
49
+ if File.exist? init_path
50
+ puts "using: #{init_path}"
51
+ load init_path
52
+ end
53
+ MDRubyEval.new input_path, input_path.gsub(/(\.in)?\.md$/, '.out.md'), binding, indentation, line_length
46
54
  end
47
- MDRubyEval.new input_path, input_path.gsub(/(\.in)?\.md$/, '.out.md'), binding, indentation, line_length
48
- end
49
55
 
50
- Process.wait pid
56
+ Process.wait pid
57
+ end
58
+ else
59
+ input_path, output_path = ARGV.map { |p| File.expand_path p }
60
+ raise 'no input path' unless input_path && File.exist?(input_path)
61
+ MDRubyEval.new input_path, output_path, binding, indentation, line_length
51
62
  end
52
- else
53
- input_path, output_path = ARGV.map { |p| File.expand_path p }
54
- raise 'no input path' unless input_path && File.exist?(input_path)
55
- MDRubyEval.new input_path, output_path, binding, indentation, line_length
56
63
  end
57
64
 
@@ -13,7 +13,7 @@ class MDRubyEval
13
13
  @line_length = line_length
14
14
 
15
15
  @last_id = 1
16
- @known_ids = Hash.new { |h, k| h[k] = format('%016x', @last_id += 1) }
16
+ @known_ids = Hash.new { |h, k| h[k] = format('%06x', @last_id += 1) }
17
17
 
18
18
  process_file input_path
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md-ruby-eval
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Chalupa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-06 00:00:00.000000000 Z
11
+ date: 2018-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  version: '0'
60
60
  requirements: []
61
61
  rubyforge_project:
62
- rubygems_version: 2.6.14
62
+ rubygems_version: 2.7.6
63
63
  signing_key:
64
64
  specification_version: 4
65
65
  summary: Evaluator of Ruby examples in Markdown files.