private_please 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,5 @@
1
+ v0.0.2
2
+ - only display the report if PrivatePlease.active?
3
+
4
+ v0.0.1
5
+ - first functional version
data/TODO ADDED
@@ -0,0 +1,22 @@
1
+
2
+ DSL
3
+ - global method marking :
4
+
5
+ ex:
6
+
7
+ private_please
8
+ def foo ..
9
+ def bar ..
10
+ public
11
+
12
+ is the same as :
13
+ ...
14
+ def foo ..
15
+ def bar ..
16
+ private_please :foo, :bar
17
+
18
+ Report :
19
+ - display list of methods that were never called
20
+
21
+ Doc
22
+ - write README
@@ -10,7 +10,7 @@ module PrivatePlease
10
10
  def private_please(*args)
11
11
  klass = self
12
12
  args.reject!{|m| !klass.instance_methods.include?(m.to_s)}
13
- candidates[klass.to_s] += args
13
+ storage.candidates[klass.to_s] += args
14
14
  args.each do |m|
15
15
  mark_method(m)
16
16
  end
@@ -40,16 +40,6 @@ module PrivatePlease
40
40
  Configuration .reset_before_new_test
41
41
  end
42
42
 
43
-
44
- #--------------
45
- # candidates
46
- #--------------
47
-
48
-
49
- def candidates ; storage.candidates end
50
- def inside_called_candidates ; storage.inside_called_candidates end
51
- def outside_called_candidates ; storage.outside_called_candidates end
52
-
53
43
  #--------------
54
44
  # report
55
45
  #--------------
@@ -81,12 +71,13 @@ private
81
71
  end
82
72
  end
83
73
 
84
-
85
74
  end
86
75
 
87
76
  Module.send :include, PrivatePlease
88
77
 
89
78
  at_exit {
90
- puts '-'*888
91
- puts PrivatePlease.report.to_s
79
+ if PrivatePlease.active?
80
+ puts '-'*888
81
+ puts PrivatePlease.report.to_s
82
+ end
92
83
  }
@@ -1,3 +1,3 @@
1
1
  module PrivatePlease
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -16,7 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.version = PrivatePlease::VERSION
17
17
 
18
18
  gem.add_development_dependency 'rake' # to run 'All specs' in Rubymine
19
- gem.add_development_dependency 'todo_next'
20
19
  gem.add_development_dependency 'rspec'
21
20
  gem.add_development_dependency 'guard-rspec'
22
21
  end
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe PrivatePlease, 'marking methods' do
4
4
 
5
+ let(:storage) { PrivatePlease.storage }
6
+
5
7
  it('records the candidates and associate them to the owning class') do
6
8
  module Marking
7
9
  class Simple1
@@ -11,7 +13,7 @@ describe PrivatePlease, 'marking methods' do
11
13
  private_please :bar, :buz
12
14
  end
13
15
  end
14
- PrivatePlease.candidates['Marking::Simple1'].should == [:bar, :buz]
16
+ storage.candidates['Marking::Simple1'].should == [:bar, :buz]
15
17
  end
16
18
 
17
19
  it('does not record invalid candidates (method not found in the class)') do
@@ -22,7 +24,7 @@ describe PrivatePlease, 'marking methods' do
22
24
  private_please :invalid_method
23
25
  end
24
26
  end
25
- PrivatePlease.candidates['Marking::Simple2'].should == [:foo]
27
+ storage.candidates['Marking::Simple2'].should == [:foo]
26
28
  end
27
29
 
28
30
  end
@@ -4,6 +4,7 @@ describe PrivatePlease, 'calling marked methods' do
4
4
  before() do
5
5
  PrivatePlease.activate(true)
6
6
  end
7
+ let(:storage) { PrivatePlease.storage }
7
8
 
8
9
  module Calling
9
10
  class Simple
@@ -20,14 +21,14 @@ describe PrivatePlease, 'calling marked methods' do
20
21
  before { Calling::Simple.new.public_m }
21
22
 
22
23
  it('records the call to the p+p method in PrivatePlease.inside_called_candidates') do
23
- PrivatePlease.inside_called_candidates[ 'Calling::Simple'].to_a.should == [:private_m]
24
- PrivatePlease.outside_called_candidates['Calling::Simple'].to_a.should == []
24
+ storage.inside_called_candidates[ 'Calling::Simple'].to_a.should == [:private_m]
25
+ storage.outside_called_candidates['Calling::Simple'].to_a.should == []
25
26
  end
26
27
 
27
28
  it('records multiple calls only once') do
28
29
  2.times{ Calling::Simple.new.public_m }
29
- PrivatePlease.inside_called_candidates[ 'Calling::Simple'].to_a.should == [:private_m]
30
- PrivatePlease.outside_called_candidates['Calling::Simple'].to_a.should == []
30
+ storage.inside_called_candidates[ 'Calling::Simple'].to_a.should == [:private_m]
31
+ storage.outside_called_candidates['Calling::Simple'].to_a.should == []
31
32
  end
32
33
  end
33
34
 
@@ -43,14 +44,14 @@ describe PrivatePlease, 'calling marked methods' do
43
44
  end
44
45
 
45
46
  it('records the call to the p+p method in PrivatePlease.inside_called_candidates') do
46
- PrivatePlease.inside_called_candidates[ 'Calling::Simple'].to_a.should == []
47
- PrivatePlease.outside_called_candidates['Calling::Simple'].to_a.should == [:private_m]
47
+ storage.inside_called_candidates[ 'Calling::Simple'].to_a.should == []
48
+ storage.outside_called_candidates['Calling::Simple'].to_a.should == [:private_m]
48
49
  end
49
50
 
50
51
  it('records multiple calls only once') do
51
52
  2.times{ Calling::Simple.new.private_m }
52
- PrivatePlease.inside_called_candidates[ 'Calling::Simple'].to_a.should == []
53
- PrivatePlease.outside_called_candidates['Calling::Simple'].to_a.should == [:private_m]
53
+ storage.inside_called_candidates[ 'Calling::Simple'].to_a.should == []
54
+ storage.outside_called_candidates['Calling::Simple'].to_a.should == [:private_m]
54
55
  end
55
56
  end
56
57
 
@@ -22,6 +22,7 @@ describe PrivatePlease, 'configuring PrivatePlease' do
22
22
  PrivatePlease::Configuration.reset_before_new_test
23
23
  PrivatePlease.should_not be_active
24
24
  end
25
+ let(:storage) { PrivatePlease.storage }
25
26
 
26
27
  context 'when disabled' do
27
28
 
@@ -31,8 +32,8 @@ describe PrivatePlease, 'configuring PrivatePlease' do
31
32
  it('is not active') { PrivatePlease.should_not be_active }
32
33
 
33
34
  it 'does NOT record the calls to candidates' do
34
- PrivatePlease.inside_called_candidates[ 'Config::Simple'].to_a.should == []
35
- PrivatePlease.outside_called_candidates['Config::Simple'].to_a.should == []
35
+ storage.inside_called_candidates[ 'Config::Simple'].to_a.should == []
36
+ storage.outside_called_candidates['Config::Simple'].to_a.should == []
36
37
  end
37
38
  end
38
39
 
@@ -44,8 +45,8 @@ describe PrivatePlease, 'configuring PrivatePlease' do
44
45
  it('is active') { PrivatePlease.should be_active }
45
46
 
46
47
  it 'DOES record the calls to candidates' do
47
- PrivatePlease.inside_called_candidates[ 'Config::Simple'].to_a.should == [:private_m]
48
- PrivatePlease.outside_called_candidates['Config::Simple'].to_a.should == [:private_m]
48
+ storage.inside_called_candidates[ 'Config::Simple'].to_a.should == [:private_m]
49
+ storage.outside_called_candidates['Config::Simple'].to_a.should == [:private_m]
49
50
  end
50
51
  end
51
52
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: private_please
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alain Ravet
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: "0"
44
44
  prerelease: false
45
45
  type: :development
46
- name: todo_next
46
+ name: rspec
47
47
  requirement: *id002
48
48
  - !ruby/object:Gem::Dependency
49
49
  version_requirements: &id003 !ruby/object:Gem::Requirement
@@ -57,22 +57,8 @@ dependencies:
57
57
  version: "0"
58
58
  prerelease: false
59
59
  type: :development
60
- name: rspec
61
- requirement: *id003
62
- - !ruby/object:Gem::Dependency
63
- version_requirements: &id004 !ruby/object:Gem::Requirement
64
- none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- hash: 3
69
- segments:
70
- - 0
71
- version: "0"
72
- prerelease: false
73
- type: :development
74
60
  name: guard-rspec
75
- requirement: *id004
61
+ requirement: *id003
76
62
  description: Test if methods can be made private
77
63
  email:
78
64
  - alainravet@gmail.com
@@ -85,11 +71,13 @@ extra_rdoc_files: []
85
71
  files:
86
72
  - .gitignore
87
73
  - .rspec
74
+ - CHANGELOG
88
75
  - Gemfile
89
76
  - Guardfile
90
77
  - LICENSE
91
78
  - README.md
92
79
  - Rakefile
80
+ - TODO
93
81
  - lib/private_please.rb
94
82
  - lib/private_please/candidates.rb
95
83
  - lib/private_please/configuration.rb
@@ -104,7 +92,6 @@ files:
104
92
  - spec/03_configuration_spec.rb
105
93
  - spec/04_at_exit_report_printing_spec.rb
106
94
  - spec/spec_helper.rb
107
- - spec/todo_next_spec.rb
108
95
  homepage: https://github.com/alainravet/private_please
109
96
  licenses: []
110
97
 
@@ -144,4 +131,3 @@ test_files:
144
131
  - spec/03_configuration_spec.rb
145
132
  - spec/04_at_exit_report_printing_spec.rb
146
133
  - spec/spec_helper.rb
147
- - spec/todo_next_spec.rb
@@ -1,52 +0,0 @@
1
- require 'rubygems'
2
- require 'rspec'
3
- require 'todo_next'
4
-
5
- todo_next(<<TEXT)
6
- * marking 1 method
7
- example :
8
- def foo
9
- ..
10
- end
11
- private_please :foo
12
-
13
- * adds the method to $private_please_candidates
14
-
15
- Marking 2 methods in 1 call
16
- example :
17
- ..
18
- private_please :foo, :bar
19
-
20
- * adds the 2 method to $private_please_candidates
21
-
22
- Global usage
23
- example :
24
- ..
25
- private_please
26
- def foo .. end
27
- def bar .. end
28
-
29
- * adds the 2 method to $private_please_candidates
30
-
31
- An outside call to a candidate marked method
32
- - goes through as is the method waspublic
33
- - $private_please_called_candidates << the candidate
34
- - $private_please_INVALID_candidates << the candidate
35
-
36
- An inside call to a candidate marked method
37
- - goes through
38
- - $private_please_called_candidates << the candidate
39
-
40
- Configuration
41
- - 'private_please' is inactive by default
42
- 'private_please' can be activate
43
- - via ENV['private_please']=true
44
- - PrivatePlease.activate(true)
45
-
46
- at_exit
47
- - prints a report about the candidates in STDOUT
48
-
49
- TEXT
50
-
51
- # √ == passed => same as a comment line
52
- # * == current => leading char - '*' - is kept