ruval 0.1.1 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/lib/ruval.rb +23 -11
- data/lib/ruval/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51d35aa42146e2d865251e44a2469aba31eefcd058b3c4e74014fa770a436258
|
4
|
+
data.tar.gz: 94c389acd01473b8197ae1ce71f9903d4e38b11e0473130aba0e0454c5668dfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9f0df1791fecc145fa4471676035d71ad1ed02bf343bfe370024431d722f0530f1db33a56eb4d37e7a21137f171214fead831009a3b8b2f953293b62cd5ae90
|
7
|
+
data.tar.gz: 265bb7d0bd26d8debc11839946dada99c2064129238bf782db79e136867a0c099ddffba02cd40919cc07c06168bd089eabd5236ceb70f596cf6119d94d6dff5f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/ruval.rb
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
# vim: ft=ruby:syntax=ruby
|
12
12
|
|
13
13
|
DEFAULT_NEWLINES = 1
|
14
|
-
KEYWORDS_REGEX = /\b(?:class|module|def|if|do|end)\b/
|
14
|
+
KEYWORDS_REGEX = /\b(?:class|module|def|if|do|end)\b|[{}\[\]()]/
|
15
15
|
|
16
16
|
def prog
|
17
17
|
File.basename $0
|
@@ -47,17 +47,20 @@ end
|
|
47
47
|
|
48
48
|
file = ARGV.shift
|
49
49
|
|
50
|
+
opts = {}
|
50
51
|
if ARGV.include?('-n')
|
51
|
-
_, line_spacing
|
52
|
-
line_spacing = line_spacing.to_i
|
52
|
+
_, opts[:line_spacing]= ARGV[ARGV.index('-n'),2]
|
53
|
+
opts[:line_spacing] = opts[:line_spacing].to_i
|
53
54
|
end
|
54
|
-
line_spacing ||= DEFAULT_NEWLINES
|
55
|
+
opts[:line_spacing] ||= DEFAULT_NEWLINES
|
55
56
|
|
56
|
-
if line_spacing < 0
|
57
|
+
if opts[:line_spacing] < 0
|
57
58
|
puts "line_spacing cannot be negative"
|
58
59
|
exit
|
59
60
|
end
|
60
61
|
|
62
|
+
opts[:colorize] = ARGV.include?('-c') ? true : false
|
63
|
+
|
61
64
|
# get longest line
|
62
65
|
longest = 0
|
63
66
|
File.read(file).each_line do |l|
|
@@ -71,7 +74,7 @@ def update_scope(line, line_stack, scope)
|
|
71
74
|
return if keywords.empty? && scope.empty?
|
72
75
|
line_stack << line
|
73
76
|
keywords.each do |kw|
|
74
|
-
unless
|
77
|
+
unless %w"end } ] )".include?(kw)
|
75
78
|
scope.push kw
|
76
79
|
else
|
77
80
|
scope.pop
|
@@ -83,14 +86,23 @@ line_stack = []
|
|
83
86
|
scope = []
|
84
87
|
|
85
88
|
File.read(file).each_line do |l|
|
89
|
+
next if(comment?(l) || l.strip.empty?)
|
86
90
|
update_scope(l, line_stack, scope)
|
87
|
-
next
|
91
|
+
next unless scope.empty?
|
88
92
|
l = if line_stack.empty?
|
89
|
-
line_spacing == 0 ? l.remove_comments(longest) : l
|
93
|
+
opts[:line_spacing] == 0 ? l.remove_comments(longest) : l
|
90
94
|
else
|
91
|
-
line_stack.join
|
95
|
+
line_stack.slice!(0,line_stack.length).join
|
92
96
|
end
|
93
|
-
|
94
|
-
|
97
|
+
value = eval(l, TOPLEVEL_BINDING)
|
98
|
+
value = if value.class == String
|
99
|
+
"\"#{value}\""
|
100
|
+
elsif value.class == Symbol
|
101
|
+
":#{value}"
|
102
|
+
else
|
103
|
+
value
|
104
|
+
end
|
105
|
+
color = opts[:colorize] ? "\e[32m" : "\e[m"
|
106
|
+
puts l + "#{color}=> #{value}\e[m" + "\n" * opts[:line_spacing]
|
95
107
|
end
|
96
108
|
|
data/lib/ruval/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruval
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergio
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Print the value of every statement in a Ruby progam
|
14
14
|
email:
|
@@ -33,11 +33,11 @@ files:
|
|
33
33
|
- lib/ruval.rb
|
34
34
|
- lib/ruval/version.rb
|
35
35
|
- ruval.gemspec
|
36
|
-
homepage:
|
36
|
+
homepage:
|
37
37
|
licenses:
|
38
38
|
- MIT
|
39
39
|
metadata: {}
|
40
|
-
post_install_message:
|
40
|
+
post_install_message:
|
41
41
|
rdoc_options: []
|
42
42
|
require_paths:
|
43
43
|
- lib
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubygems_version: 3.1.4
|
56
|
-
signing_key:
|
56
|
+
signing_key:
|
57
57
|
specification_version: 4
|
58
58
|
summary: Print the value of every statement in a Ruby progam
|
59
59
|
test_files: []
|