pry-power_assert 0.0.1 → 0.0.2

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: e97d070244dac7b4d9ea88f9aafbc4164859be5f
4
- data.tar.gz: ac5adbd0469ea4e78c4197a7dc272ba2b3e9a21b
3
+ metadata.gz: 462cf1962718b5bc64ee6f8d567a342172bb3e17
4
+ data.tar.gz: bd38e9a31b9655923524a7a5cbfb9bf30333502d
5
5
  SHA512:
6
- metadata.gz: aa3976d9bb3d7cdff439f402bacf60b42ba474d6d8d46e05964bdf2399651adbf2fa3c4555254c57c962b7401695784a0b3fc77d3489b92530ee2c8fc57943f9
7
- data.tar.gz: 3896e15bc221b6f6c51a0815795fb9acfa067ff50a6513f1c556e539bc3e61a263e06531ccae86079fdfc4f0b172782b6d75602a8a2072aed55d37282e4400ab
6
+ metadata.gz: 511a40f9a4e493ecc622f45a0eed0319162f21cf154f281a8cbe9fb5a54636b589a601c1b8c57d857dcda99c9ffed59c395b332d533044d27ad9666f4170e82a
7
+ data.tar.gz: e6b7f9402f53f484db71fd5de4402fbdf3765954ab40c7c5b6b5b5e4c24563ed7269328595168df63486db27d250b79d884a358c74ba0aba75fea29381259d5b
data/README.md CHANGED
@@ -30,6 +30,8 @@ Type `pa RUBY_CODE`
30
30
 
31
31
  ```ruby
32
32
  [1] pry(main)> pa "0".class == "3".to_i.times.map {|i| i + 1 }.class
33
+ result: false
34
+
33
35
  "0".class == "3".to_i.times.map {|i| i + 1 }.class
34
36
  | | | | | |
35
37
  | | | | | Array
@@ -1,6 +1,6 @@
1
1
  require "pry"
2
+ require "power_assert"
2
3
  require "pry-power_assert/version"
3
- require "pry-power_assert/power_assert-ext"
4
4
 
5
5
  module PryPowerAssert
6
6
  Pry::Commands.create_command('pa', '') do
@@ -11,6 +11,8 @@ module PryPowerAssert
11
11
  The pa command show RUBY_CODE result with power_assert like format.
12
12
 
13
13
  [1] pry(main)> pa "0".class == "3".to_i.times.map {|i| i + 1 }.class
14
+ result: false
15
+
14
16
  "0".class == "3".to_i.times.map {|i| i + 1 }.class
15
17
  | | | | | |
16
18
  | | | | | Array
@@ -22,14 +24,11 @@ module PryPowerAssert
22
24
  BANNER
23
25
 
24
26
  def process
25
- result = ""
26
- code = arg_string
27
-
28
- proc = context[:target].eval "Proc.new {#{code}}"
27
+ result = "result: "
29
28
 
30
- PowerAssert.start_with_string(proc, code, assertion_method: __method__) do |pa|
31
- pa.yield
32
- result = pa.message_proc.()
29
+ PowerAssert.start(arg_string, source_binding: context[:target]) do |pa|
30
+ result << pa.yield.inspect << "\n\n"
31
+ result << pa.message_proc.()
33
32
  end
34
33
 
35
34
  output.puts result
@@ -1,3 +1,3 @@
1
1
  module PryPowerAssert
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -18,9 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "power_assert", "0.1.3"
21
+ spec.add_dependency "power_assert", ">= 0.2.0"
22
22
  spec.add_dependency "pry", ">= 0.9.8"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.7"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", ">= 3.0.0"
26
27
  end
@@ -3,7 +3,9 @@ require 'pry-power_assert'
3
3
 
4
4
  describe "ps command" do
5
5
  it "should show power_assert result" do
6
- pry_eval(%q{pa "0".class == "3".to_i.times.map {|i| i + 1 }.class}).chomp.should == <<END.chomp
6
+ expect(pry_eval(%q{pa "0".class == "3".to_i.times.map {|i| i + 1 }.class}).chomp).to eq(<<END.chomp)
7
+ result: false
8
+
7
9
  "0".class == "3".to_i.times.map {|i| i + 1 }.class
8
10
  | | | | | |
9
11
  | | | | | Array
@@ -18,7 +20,9 @@ END
18
20
  it "should show power_assert result" do
19
21
  pry_eval(%q{a = 10})
20
22
  pry_eval(%q{b = 20})
21
- pry_eval(%q{pa a + b + 30}).chomp.should == <<END.chomp
23
+ expect(pry_eval(%q{pa a + b + 30}).chomp).to eq(<<END.chomp)
24
+ result: 60
25
+
22
26
  a + b + 30
23
27
  | | | |
24
28
  | | | 60
@@ -31,7 +35,9 @@ END
31
35
  it "should show power_assert result" do
32
36
  pry_eval(%q{@a = 10})
33
37
  pry_eval(%q{@b = 20})
34
- pry_eval(%q{pa @a + @b + 30}).chomp.should == <<END.chomp
38
+ expect(pry_eval(%q{pa @a + @b + 30}).chomp).to eq(<<END.chomp)
39
+ result: 60
40
+
35
41
  @a + @b + 30
36
42
  | | | |
37
43
  | | | 60
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-power_assert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - yui-knk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-24 00:00:00.000000000 Z
11
+ date: 2014-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: power_assert
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.3
19
+ version: 0.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.3
26
+ version: 0.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0
69
83
  description: Provides power assert support for Pry
70
84
  email:
71
85
  - spiketeika@gmail.com
@@ -79,7 +93,6 @@ files:
79
93
  - README.md
80
94
  - Rakefile
81
95
  - lib/pry-power_assert.rb
82
- - lib/pry-power_assert/power_assert-ext.rb
83
96
  - lib/pry-power_assert/version.rb
84
97
  - pry-power_assert.gemspec
85
98
  - spec/pry-power_assert_spec.rb
@@ -1,45 +0,0 @@
1
- require "power_assert"
2
-
3
- module PowerAssert
4
- class PryContext < Context
5
-
6
- # args line means assertion_proc_string
7
- def initialize(assertion_proc, assertion_method, line)
8
- @line = line
9
- methods = nil
10
- refs = nil
11
- method_ids = nil
12
- return_values = []
13
- @base_caller_length = -1
14
- @assertion_proc = assertion_proc
15
- @assertion_method_name = assertion_method.to_s
16
- @message_proc = -> {
17
- @assertion_message ||=
18
- @base_caller_length > 0 ? assertion_message(@line || '',
19
- methods || [],
20
- return_values,
21
- refs || [],
22
- assertion_proc.binding).freeze :
23
- nil
24
- }
25
- @proc_local_variables = assertion_proc.binding.eval('local_variables').map(&:to_s)
26
- @trace = TracePoint.new(:return, :c_return) do |tp|
27
- next if method_ids and ! method_ids.include?(tp.method_id)
28
- locs = tp.binding.eval('caller_locations')
29
- if locs.length - @base_caller_length == TARGET_CALLER_DIFF[tp.event]
30
- idx = TARGET_CALLER_INDEX[tp.event]
31
- idents = extract_idents(Ripper.sexp(@line))
32
- methods, refs = idents.partition {|i| i.type == :method }
33
- method_ids = methods.map(&:name).map(&:to_sym).uniq
34
- return_values << Value[tp.method_id.to_s, tp.return_value, nil]
35
- end
36
- end
37
- end
38
- end
39
- private_constant :PryContext
40
-
41
- def start_with_string(assertion_proc, line, assertion_method: nil)
42
- yield PryContext.new(assertion_proc, assertion_method, line)
43
- end
44
- module_function :start_with_string
45
- end