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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24b06ee55e0f75bacdc2cd2f24a26ef4b68639e0
4
- data.tar.gz: fb590fdf5fab06a173cb904b461ff37143a18373
3
+ metadata.gz: 08379b07d4eaba821c0b311b301f31a510a4c55a
4
+ data.tar.gz: c719ae44d9738abbc270eccf55a3d8c668fce5f9
5
5
  SHA512:
6
- metadata.gz: b5dae726d2b6e487e17a9eeba3e97bddad021061c2b01c30542a2db8f7eb0cea62b700427f292d729b2149f09d205f16a91aad355835b921cd19d98e263172f3
7
- data.tar.gz: f3fc078d8b72c90ec463d9c0e90d09e96294bc655c5ee8a52b5fea7a87a3f3b11f9d475f8c0797b27766c00e93a2d02a127131eac98b84cb638277182ec16080
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 '! 2 + 3'
95
+ $ ru '=2 + 3'
96
96
  5
97
97
  ```
98
98
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ../
2
+ remote: ..
3
3
  specs:
4
- ru2 (2.1.5)
4
+ ru2 (2.2.0)
5
5
  activesupport (>= 3.2.0)
6
6
 
7
7
  GEM
@@ -43,4 +43,4 @@ DEPENDENCIES
43
43
  ru2!
44
44
 
45
45
  BUNDLED WITH
46
- 1.13.6
46
+ 1.14.3
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ../
2
+ remote: ..
3
3
  specs:
4
- ru2 (2.1.5)
4
+ ru2 (2.2.0)
5
5
  activesupport (>= 3.2.0)
6
6
 
7
7
  GEM
@@ -50,4 +50,4 @@ DEPENDENCIES
50
50
  ru2!
51
51
 
52
52
  BUNDLED WITH
53
- 1.13.6
53
+ 1.14.3
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ../
2
+ remote: ..
3
3
  specs:
4
- ru2 (2.1.5)
4
+ ru2 (2.2.0)
5
5
  activesupport (>= 3.2.0)
6
6
 
7
7
  GEM
@@ -49,4 +49,4 @@ DEPENDENCIES
49
49
  ru2!
50
50
 
51
51
  BUNDLED WITH
52
- 1.13.6
52
+ 1.14.3
data/lib/ru/process.rb CHANGED
@@ -19,8 +19,8 @@ module Ru
19
19
  return
20
20
  end
21
21
 
22
- @stdin = get_stdin(args, @options[:stream]) unless @code.start_with?('! ')
23
- @code = prepare_code(@code)
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
- output = context.instance_eval(@code) || @stdin
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
- if code.kind_of?(String)
54
- if code.start_with?('[')
55
- code = 'to_self' + code
56
- elsif code.start_with?('! ')
57
- code = code[2..-1]
58
- end
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
@@ -1,3 +1,3 @@
1
1
  module Ru
2
- VERSION = '2.1.5'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -57,8 +57,8 @@ describe Ru::Process do
57
57
  expect(out).to eq("foo\nfoo\nfoo")
58
58
  end
59
59
 
60
- it "runs code prepended by '! '" do
61
- out = run('! 2 + 3')
60
+ it "runs code prepended by '='" do
61
+ out = run('=2 + 3')
62
62
  expect(out).to eq('5')
63
63
  end
64
64
 
@@ -1,3 +1,5 @@
1
+ require 'pathname'
2
+
1
3
  module FixturesHelper
2
4
  def fixture_path(*args)
3
5
  directory = Pathname.new(File.dirname(File.absolute_path(__FILE__)))
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.1.5
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-27 00:00:00.000000000 Z
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.6.8
123
+ rubygems_version: 2.4.8
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Ruby in your shell!