ru2 2.1.5 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/gemfiles/activesupport_3.gemfile.lock +3 -3
- data/gemfiles/activesupport_4.gemfile.lock +3 -3
- data/gemfiles/activesupport_5.gemfile.lock +3 -3
- data/lib/ru/process.rb +15 -10
- data/lib/ru/version.rb +1 -1
- data/spec/lib/process_spec.rb +2 -2
- data/spec/support/fixtures_helper.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08379b07d4eaba821c0b311b301f31a510a4c55a
|
4
|
+
data.tar.gz: c719ae44d9738abbc270eccf55a3d8c668fce5f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4c283b44df3305650164ede3763cddcd902229cc90b6cb39b05b969e1f8c21c5f50942b7ed83255990e4fb2f1a02b3eb9d074bfe4569e3045f9f71a71d1ae31
|
7
|
+
data.tar.gz: 0c2bfdd5c341663051cf9bd0900ab994d0fffde0d77266046676ec1b89bc2cdfd282702be7b3afaef900296ea0dfa99f0cadaaa8f77a5d27796831bde4ea241b
|
data/README.md
CHANGED
@@ -89,10 +89,10 @@ $ ru 'map(:to_i).sum' myfile myfile
|
|
89
89
|
10
|
90
90
|
```
|
91
91
|
|
92
|
-
You can also run Ruby code without any input by prepending a
|
92
|
+
You can also run Ruby code without any input by prepending a `=`:
|
93
93
|
|
94
94
|
```bash
|
95
|
-
$ ru '
|
95
|
+
$ ru '=2 + 3'
|
96
96
|
5
|
97
97
|
```
|
98
98
|
|
data/lib/ru/process.rb
CHANGED
@@ -19,8 +19,8 @@ module Ru
|
|
19
19
|
return
|
20
20
|
end
|
21
21
|
|
22
|
-
@
|
23
|
-
@
|
22
|
+
@parsed = prepare_code(@code)
|
23
|
+
@stdin = get_stdin(args, @options[:stream]) if @parsed[:get_stdin]
|
24
24
|
|
25
25
|
context =
|
26
26
|
if @stdin.nil?
|
@@ -42,7 +42,9 @@ module Ru
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
|
+
output = context.instance_eval(@parsed[:code])
|
47
|
+
output = @stdin if output == nil
|
46
48
|
|
47
49
|
prepare_output(output)
|
48
50
|
end
|
@@ -50,14 +52,17 @@ module Ru
|
|
50
52
|
private
|
51
53
|
|
52
54
|
def prepare_code(code)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
return code unless code.kind_of?(String)
|
56
|
+
if code.start_with?('[')
|
57
|
+
{ code: "to_self#{code}", get_stdin: true }
|
58
|
+
elsif code.start_with?('=')
|
59
|
+
{ code: code[1..-1], get_stdin: false }
|
60
|
+
elsif code.start_with?('!')
|
61
|
+
ActiveSupport::Deprecation.warn %('!1+2' syntax is going to be replaced with '=1+2')
|
62
|
+
{ code: code[1..-1], get_stdin: false }
|
63
|
+
else
|
64
|
+
{ code: code, get_stdin: true }
|
59
65
|
end
|
60
|
-
code
|
61
66
|
end
|
62
67
|
|
63
68
|
def prepare_output(output)
|
data/lib/ru/version.rb
CHANGED
data/spec/lib/process_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ru2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Benner
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-01-
|
12
|
+
date: 2017-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.4.8
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Ruby in your shell!
|