private_please 0.1.1 → 0.1.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: 0f5b957c5daf40f83ad7923f1bf6998d9e747704
4
- data.tar.gz: 7f99f9677b8e5e163a504ffc891089ea60e4a4b8
3
+ metadata.gz: 1c686287e2a68e5a615222b424c30c5b69904814
4
+ data.tar.gz: b222e367b3d2ec2f0e3dfb0e34d6c86c18e88011
5
5
  SHA512:
6
- metadata.gz: 233ec12deffb6bd4b31575d94ce5efe4e2bd98d50319b5d8489e714179d9c359ab62bb1eb9c3f40c18c266fc9b9ec62702b6415ba1c145de1175ecab60e70bb7
7
- data.tar.gz: e7ea701475560b044ae7aa729fbf0afa73e9a1aa4f936d3f9a6d8fe5e2a03cecb706cb12c18b5be7dd6cc5af9f7d006c4f3b6db1b2948ad9f6f6c5974e63a1fa
6
+ metadata.gz: 65014fdbf7c069639cb8b7d8c49c7c71c16b8eba850a238cbc8999829f04a3f500bf3dc408a42976d6d2d38fb8cfa35f7bc86ced299a063dbe16adbe130e9531
7
+ data.tar.gz: ffef276c360f4547ba286db987c04aefd0f27e20540b72adcbe53eb8d191f8660481fc24cf7c47760daaffc4bf8ae620a9d621b82d2218b295cf04bcc3676ae9
data/.gitignore CHANGED
@@ -3,14 +3,8 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ spec/log/traces.txt
6
7
  Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
8
  coverage
10
- lib/bundler/man
11
9
  pkg
12
10
  rdoc
13
- spec/reports
14
- test/tmp
15
- test/version_tmp
16
- tmp
data/.rubocop.yml ADDED
@@ -0,0 +1,32 @@
1
+ inherit_from:
2
+ - .rubocop_todo.yml
3
+
4
+ Metrics/LineLength:
5
+ Exclude:
6
+ - 'spec/**/*'
7
+
8
+ Style/ExtraSpacing:
9
+ Enabled: false
10
+
11
+ Style/MultilineTernaryOperator:
12
+ Enabled: false
13
+
14
+ Style/ParallelAssignment:
15
+ Enabled: false
16
+
17
+ Style/RegexpLiteral:
18
+ Enabled: false
19
+
20
+ Style/SingleLineMethods:
21
+ Enabled: false
22
+ EmptyLineBetweenDefs:
23
+ AllowAdjacentOneLineDefs: true
24
+
25
+ Style/SpaceBeforeSemicolon:
26
+ Enabled: false
27
+
28
+ Style/StructInheritance:
29
+ Enabled: false
30
+
31
+ Style/TrailingCommaInLiteral:
32
+ EnforcedStyleForMultiline: comma
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,24 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-01-19 17:37:21 +0100 using RuboCop version 0.36.0.
4
+
5
+ # Offense count: 2
6
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
7
+ # URISchemes: http, https
8
+ Metrics/LineLength:
9
+ Max: 110
10
+
11
+ # Offense count: 1
12
+ Style/Documentation:
13
+ Exclude:
14
+ - 'spec/**/*'
15
+ - 'test/**/*'
16
+ - 'lib/**/*'
17
+
18
+ Style/GlobalVars:
19
+ Exclude:
20
+ - 'lib/goody_goody/analyzer.rb'
21
+
22
+ Metrics/MethodLength:
23
+ Exclude:
24
+ - 'lib/goody_goody/analyzer.rb'
data/.travis.yml CHANGED
@@ -1,8 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "2.0.0"
4
- - "2.1"
5
- - "2.2"
6
- - "2.3.0"
7
- # uncomment this line if your project needs to run something other than `rake`:
8
- script: bundle exec rspec --format documentation
3
+ - 2.0.0
4
+ - 2.1
5
+ - 2.2.4
6
+ - 2.3.0
7
+ - ruby-head
8
+
9
+ script: bundle exec rspec --format documentation --tag ~fails_on_ci --seed 2222
10
+
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v0.1.2
2
+ - fix : support modules' "self." methods.
3
+ - fixes
4
+
1
5
  v0.1.1
2
6
  - fix : standard libraries (set, erb) must be required.
3
7
 
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in private_please.gemspec
4
4
  gemspec
5
5
 
6
- gem 'rubocop', require: false
6
+ gem 'rubocop', '~> 0.37.2', require: false
data/README.md CHANGED
@@ -8,6 +8,8 @@ This tool locates public or protected methods that can be made private.
8
8
  After you have instrumented the tests suite (see below), it watches the code as the tests are executed and identifies non-private methods that are only called privately.
9
9
  As the technique used is tracing, the execution is slowed down substantially (ex: 300%)
10
10
 
11
+ [![asciicast](https://asciinema.org/a/4sqa7u4defes3akyst27pq066.png)](https://asciinema.org/a/4sqa7u4defes3akyst27pq066)
12
+
11
13
  ## Usage
12
14
 
13
15
  Add this to the top of `spec_helper.rb`:
@@ -42,3 +42,7 @@ module PrivatePlease
42
42
  instance.result.to_two_level_hash
43
43
  end
44
44
  end
45
+
46
+ if PrivatePlease::Debug.enabled?
47
+ TRACES_LINES = File.open(File.expand_path('../../spec/log/traces.txt', __FILE__), 'w')
48
+ end
@@ -6,7 +6,7 @@ module PrivatePlease
6
6
  end
7
7
 
8
8
  def self.enabled?
9
- defined?(TRACES_LINES)
9
+ ENV['PRIVATE_PLEASE_DEBUG']
10
10
  end
11
11
 
12
12
  module TracePointDataLogger
@@ -18,11 +18,13 @@ module PrivatePlease
18
18
  # Array#new
19
19
  # Array.size
20
20
  def method_full_name
21
- if module_method?
22
- instance_method = defined_class.instance_methods.include?(method_id)
23
- instance_method ?
24
- "#{defined_class}##{method_id}" :
25
- "#{defined_class}.#{method_id}"
21
+ defined_class_s = defined_class.to_s
22
+ is_module_class_method = defined_class_s.start_with?('#<Class:')
23
+ if is_module_class_method
24
+ defined_class_s.gsub!(/^#<Class:/, '').delete!('>')
25
+ "#{defined_class_s}.#{method_id}"
26
+ elsif module_method?
27
+ "#{defined_class}##{method_id}"
26
28
  else
27
29
  instance_method = !(_self.class == Class)
28
30
  instance_method ?
@@ -27,9 +27,16 @@ module PrivatePlease
27
27
 
28
28
  private
29
29
 
30
- def remember_trace_point(tp)
31
- @latest_tracepoints.push TracePointDetails.from(tp)
32
- # Debug.log_to_trace_file tpd if Debug.enabled?
30
+ if Debug.enabled?
31
+ def remember_trace_point(tp)
32
+ tpd = TracePointDetails.from(tp)
33
+ @latest_tracepoints.push tpd
34
+ Debug.log_to_trace_file tpd
35
+ end
36
+ else
37
+ def remember_trace_point(tp)
38
+ @latest_tracepoints.push TracePointDetails.from(tp)
39
+ end
33
40
  end
34
41
 
35
42
  def untracked_code?(path)
@@ -57,6 +64,7 @@ module PrivatePlease
57
64
  end
58
65
 
59
66
  def private_call?
67
+ return unless tp_prev # fails sometime (ex: rspec-core) # UNTESTED
60
68
  curr_event, prev_event = tp_curr.event, tp_prev.event
61
69
  (curr_event == :call) &&
62
70
  [:line, :return, :c_return].include?(prev_event) &&
@@ -6,9 +6,12 @@ module PrivatePlease
6
6
  def source_path_and_lineno(klass, separator, method)
7
7
  is_instance_method = separator == '#'
8
8
  if klass.instance_of?(Module)
9
- is_instance_method ?
10
- klass.instance_method(method).source_location :
11
- klass.singleton_method(method).source_location
9
+ if is_instance_method
10
+ klass.instance_method(method).source_location
11
+ else
12
+ klass.singleton_method(method).source_location
13
+ end
14
+
12
15
  else
13
16
  is_instance_method ?
14
17
  klass.instance_method(method).source_location :
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module PrivatePlease
3
- VERSION = '0.1.1'.freeze
3
+ VERSION = '0.1.2'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: private_please
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alain Ravet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,6 +89,8 @@ extra_rdoc_files: []
89
89
  files:
90
90
  - ".gitignore"
91
91
  - ".rspec"
92
+ - ".rubocop.yml"
93
+ - ".rubocop_todo.yml"
92
94
  - ".ruby-version"
93
95
  - ".travis.yml"
94
96
  - CHANGELOG