power_assert 0.1.0 → 0.1.1

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: 7444d3904ad2148eb3fc1f836d721d28f1c59fe4
4
- data.tar.gz: 6aade4c736ebba939973db85fc33f9e276daf010
3
+ metadata.gz: 99b3895797c266648105fc96abdc122df93537d1
4
+ data.tar.gz: a9af7c357642b19eadeace43da8ba2f1ee17d9fe
5
5
  SHA512:
6
- metadata.gz: 948cfe90a83135a15de3b7ac7d4dbdec085c352a2b04857b1e3e22e878a69eac63f54ca16d389aa6134037387b667e6ff8f7f3db3a94aeb3513f91c60d6e7f41
7
- data.tar.gz: 666404c70ed0c62857490819241e169b994163d23972a62ff6f22b89372c47932aaec1647018d39f1824b823c1ea47a08a4db843816ad379499c41979d22c09b
6
+ metadata.gz: ae79bba8eb3a079bcf30df88ef0109be3de8848a2d5dcd4f7d1d5fdee731dcc20150a21e272ec54c7c19f70200c684df6972c23ee0c835113be6985c143f6f63
7
+ data.tar.gz: 4f0f959d1a16f3ba502adfe0c73f92909d2c78a3383a2bbb9044e886d6c3e0c06a41dbf2b9a572b5bd6e8a411e5c060bd3e3e305d682428d0645dd321cd4b662
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
- - 2.1.1
4
+ - 2.1.2
5
5
  - ruby-head
data/lib/power_assert.rb CHANGED
@@ -3,9 +3,9 @@
3
3
  # Copyright (C) 2014 Kazuki Tsujimoto, All rights reserved.
4
4
 
5
5
  require 'power_assert/version'
6
+ require 'power_assert/pattern_match'
6
7
 
7
8
  require 'ripper'
8
- require 'pattern-match'
9
9
 
10
10
  # NB: API is not fixed
11
11
 
@@ -31,9 +31,9 @@ module PowerAssert
31
31
  @assertion_proc = assertion_proc
32
32
  @message_proc = -> {
33
33
  @assertion_message ||=
34
- @base_caller_length > 0 ? assertion_message(line, methods, return_values, refs, @assertion_proc.binding).freeze : nil
34
+ @base_caller_length > 0 ? assertion_message(line || '', methods || [], return_values, refs || [], assertion_proc.binding).freeze : nil
35
35
  }
36
- @proc_local_variables = assertion_proc ? assertion_proc.binding.eval('local_variables').map(&:to_s) : []
36
+ @proc_local_variables = assertion_proc.binding.eval('local_variables').map(&:to_s)
37
37
  @trace = TracePoint.new(:return, :c_return) do |tp|
38
38
  next if method_ids and ! method_ids.include?(tp.method_id)
39
39
  locs = tp.binding.eval('caller_locations')
@@ -46,7 +46,7 @@ module PowerAssert
46
46
  idents = extract_idents(Ripper.sexp(line), assertion_method)
47
47
  methods, refs = idents.partition {|i| i.type == :method }
48
48
  end
49
- method_ids = methods.map(&:name).map(&:to_sym).uniq
49
+ method_ids ||= methods.map(&:name).map(&:to_sym).uniq
50
50
  if path == locs[idx].path and lineno == locs[idx].lineno
51
51
  return_values << Value[tp.method_id.to_s, tp.return_value, nil]
52
52
  end
@@ -69,10 +69,10 @@ module PowerAssert
69
69
 
70
70
  def assertion_message(line, methods, return_values, refs, proc_binding)
71
71
  set_column(line, methods, return_values)
72
- ref_values = refs ? refs.map {|i| Value[i.name, proc_binding.eval(i.name), i.column] } : []
72
+ ref_values = refs.map {|i| Value[i.name, proc_binding.eval(i.name), i.column] }
73
73
  vals = (return_values + ref_values).find_all(&:column).sort_by(&:column).reverse
74
74
  if vals.empty?
75
- return line || ''
75
+ return line
76
76
  end
77
77
  fmt = (vals[0].column + 1).times.map {|i| vals.find {|v| v.column == i } ? "%<#{i}>s" : ' ' }.join
78
78
  ret = []
@@ -88,7 +88,7 @@ module PowerAssert
88
88
  end
89
89
 
90
90
  def set_column(line, methods, return_values)
91
- methods &&= methods.dup
91
+ methods = methods.dup
92
92
  return_values.each do |val|
93
93
  idx = methods.index {|method| method.name == val.name }
94
94
  if idx and (m = methods.delete_at(idx)).column
@@ -118,8 +118,8 @@ module PowerAssert
118
118
  extract_idents(s)
119
119
  end
120
120
  with(_[:method_add_arg, s0, s1]) do
121
- s0_methods = extract_idents(s0)
122
- s0_methods[0..-2] + extract_idents(s1) + [s0_methods[-1]]
121
+ s0_idents = extract_idents(s0)
122
+ s0_idents[0..-2] + extract_idents(s1) + [s0_idents[-1]]
123
123
  end
124
124
  with(_[:arg_paren, s]) do
125
125
  extract_idents(s)
@@ -0,0 +1,16 @@
1
+ require 'pattern-match/core'
2
+
3
+ class << Array
4
+ include PatternMatch::Deconstructable
5
+
6
+ def deconstruct(val)
7
+ accept_self_instance_only(val)
8
+ val
9
+ end
10
+
11
+ private
12
+
13
+ def accept_self_instance_only(val)
14
+ raise PatternMatch::PatternNotMatch unless val.kind_of?(self)
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module PowerAssert
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/power_assert.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
15
  s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f) }
16
16
  s.require_paths = ['lib']
17
- s.add_runtime_dependency 'pattern-match'
17
+ s.add_runtime_dependency 'pattern-match', '>= 0.5.1'
18
18
  s.add_development_dependency 'test-unit'
19
19
  s.add_development_dependency 'rake'
20
20
  s.extra_rdoc_files = ['README.rdoc']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power_assert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuki Tsujimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-31 00:00:00.000000000 Z
11
+ date: 2014-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pattern-match
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.5.1
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'
26
+ version: 0.5.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: test-unit
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -68,6 +68,7 @@ files:
68
68
  - README.rdoc
69
69
  - Rakefile
70
70
  - lib/power_assert.rb
71
+ - lib/power_assert/pattern_match.rb
71
72
  - lib/power_assert/version.rb
72
73
  - power_assert.gemspec
73
74
  - test/test_power_assert.rb
@@ -92,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
93
  version: '0'
93
94
  requirements: []
94
95
  rubyforge_project:
95
- rubygems_version: 2.2.0
96
+ rubygems_version: 2.2.2
96
97
  signing_key:
97
98
  specification_version: 4
98
99
  summary: Power Assert for Ruby