peeky 0.0.15 → 0.0.31

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
  SHA256:
3
- metadata.gz: 2ca022f75a0c8100cb747acf3be51f77abf2ebedd092b6f235fbe717ea001dc4
4
- data.tar.gz: 43250493a0da5114f6d685445a8b189d335df8dc74f3596c3d7395b4e1dd0a3a
3
+ metadata.gz: edb80ec928d5d4495d464467e28bbb6b16638a14773eca16891ddbea915335a5
4
+ data.tar.gz: febac36ff7fa54d618d0ef6f3ef20da522b5918904c76550b823f11e1eb6ffde
5
5
  SHA512:
6
- metadata.gz: bbfa5087d3653aa6aee52ce37138883205e5b8ee1c3cef4419a0619c81e97f3f577c8f8482ff7c399d9a454fe07530857b8f16863129547f954cfcd45b7ddda9
7
- data.tar.gz: 71738fcef6e04171391b2863f480468f3e34ed249fcee9dfd6188fbf2fdfab0b655ebe07d82170e058dcadfef2b76e4c06bd22617b78d200608478cb35e06a95
6
+ metadata.gz: 4c984b3df997d970c6da34e654495802f54ce67c18bf7a057e22b56ab6f0c7b9e68579834715b09288059ac389662d5c3504ebe1aa42eee7675978b8010cb1b3
7
+ data.tar.gz: c2e45fbfda42652aeec5334edc8a5d596948eba45ecaa91d3a3f8522e603c39284deff97a78abc519edc0be675e29811624b7c51a2e17d48a3fe501acd9ca669
@@ -0,0 +1,31 @@
1
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
2
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
3
+
4
+ name: Ruby
5
+
6
+ on:
7
+ push:
8
+ branches: [ master ]
9
+ pull_request:
10
+ branches: [ master ]
11
+
12
+ jobs:
13
+ test:
14
+
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby
20
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
21
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
22
+ # uses: ruby/setup-ruby@v1
23
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
24
+ with:
25
+ ruby-version: 2.6
26
+ - name: Install dependencies
27
+ run: bundle install
28
+ - name: Run tests
29
+ run: bundle exec rspec
30
+ - name: Run rubocop
31
+ run: bundle exec rubocop
@@ -4,8 +4,26 @@ AllCops:
4
4
  NewCops: enable
5
5
  Exclude:
6
6
  - "_/**/*"
7
+ - "lib/peeky/example/yard_sample.rb"
7
8
 
8
9
  # My Preferences - Start
10
+ Naming/MemoizedInstanceVariableName:
11
+ Enabled: false
12
+
13
+ Style/EmptyMethod:
14
+ Exclude:
15
+ - "**/spec/**/*"
16
+ Metrics/ParameterLists:
17
+ Exclude:
18
+ - "**/spec/**/*"
19
+ Layout/EmptyLineBetweenDefs:
20
+ Exclude:
21
+ - "**/spec/**/*"
22
+
23
+ Lint/AmbiguousBlockAssociation:
24
+ Exclude:
25
+ - "**/spec/**/*"
26
+
9
27
  Style/AccessorGrouping:
10
28
  Enabled: false
11
29
 
@@ -16,6 +34,7 @@ Layout/SpaceBeforeComma:
16
34
  Metrics/BlockLength:
17
35
  Exclude:
18
36
  - "**/spec/*"
37
+ - "*.gemspec"
19
38
  ExcludedMethods:
20
39
  - configure
21
40
  - context
@@ -21,6 +21,10 @@ Gemspec/RequiredRubyVersion:
21
21
  Exclude:
22
22
  - 'peeky.gemspec'
23
23
 
24
+ Metrics/BlockLength:
25
+ Exclude:
26
+ - 'peeky.gemspec'
27
+
24
28
  # Offense count: 1
25
29
  # Cop supports --auto-correct.
26
30
  # Configuration parameters: EnforcedStyle.
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
55
55
  ## Enforcement
56
56
 
57
57
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at david.cruwys@bugcrowd.com. All
58
+ reported by contacting the project team at david@ideasmne.com.au. All
59
59
  complaints will be reviewed and investigated and will result in a response that
60
60
  is deemed necessary and appropriate to the circumstances. The project team is
61
61
  obligated to maintain confidentiality with regard to the reporter of an incident.
data/Gemfile CHANGED
@@ -5,13 +5,16 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in poc_github_ap.gemspec
6
6
  gemspec
7
7
 
8
+ # group :development do
9
+ # # pry on steroids
10
+ # gem 'pry-coolline', github: 'owst/pry-coolline', branch: 'support_new_pry_config_api'
11
+ # gem 'jazz_fingers'
12
+ # end
13
+
8
14
  group :development, :test do
9
15
  gem 'guard-bundler'
10
16
  gem 'guard-rspec'
11
17
  gem 'guard-rubocop'
12
- # pry on steroids
13
- gem 'pry-coolline', github: 'owst/pry-coolline', branch: 'support_new_pry_config_api'
14
- gem 'jazz_fingers'
15
18
  gem 'rake', '~> 12.0'
16
19
  # this is used for cmdlets 'self-executing gems'
17
20
  gem 'rake-compiler'
data/Guardfile CHANGED
@@ -23,8 +23,8 @@ group :green_pass_then_cop, halt_on_fail: true do
23
23
  watch(%r{^lib/peeky/commands/(.+)\.rb$}) { |m| "spec/unit/commands/#{m[1]}_spec.rb" }
24
24
  end
25
25
 
26
- guard :rubocop, all_on_start: false, cli: ['--format', 'clang'] do
27
- watch(%r{.+\.rb$})
28
- watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
29
- end
26
+ # guard :rubocop, all_on_start: false, cli: ['--format', 'clang'] do
27
+ # watch(%r{.+\.rb$})
28
+ # watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
29
+ # end
30
30
  end
data/README.md CHANGED
@@ -1,40 +1,9 @@
1
- # ToDo
2
-
3
- * Manually create each file using the template system
4
- - Models
5
- - [Done] ParameterInfo
6
- - [Done] AttrInfo
7
- - [Done] ClassInfo
8
- - [Done] MethodInfo
9
- - Create predicates
10
- - [Done] attr_reader_predicate
11
- - [Done] attr_writer_predicate
12
- - Create renderers
13
- - [Done] method_call_minimum_params_render
14
- - [Done] method_signature_render
15
- - [Done] method_signature_with_debug_render
16
- - [Done] class_interface_render
17
- - [Done] Recreate peeky
18
- - [Done] Symlink KlueLess files
19
- - [Done] Hot fix after each section
20
- - [Done] Make sure the klueless files follow a natural structure
21
- - [Done] Push peeky to Ruby Gems
22
- - Build out the readme file
23
- - Build out the stories
24
- - Back compare templates vis definitions
25
- - Auto create .template folder with copied definitions
26
-
27
-
28
1
  # Peeky
29
2
 
30
3
  > Peeky is a Ruby GEM for peaking into ruby classes and extracting meta
31
4
 
32
- Welcome to your new ruby gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/peeky`.
33
-
34
5
  When using the source code for this gem, start by running `bin/setup` to install locally or `bundle install`
35
6
 
36
- To experiment with that code, run `bin/console` for an interactive prompt or run `exe/peeky` to see a list of commands.
37
-
38
7
  ## Installation
39
8
 
40
9
  Add this line to your application's Gemfile:
@@ -57,10 +26,86 @@ gem install peeky
57
26
 
58
27
  ## Stories
59
28
 
29
+ ### Main Story
30
+
31
+ As a Ruby Developer, I should be able to Reverse engineer classes and methods, so that I can document and understand them
32
+
33
+ See all [stories](./STORIES.md)
34
+
35
+ ### Featured Stories
36
+
37
+ - As a Developer, I should be able to interrogate class instance information, so that I can reverse engineer a ruby class
38
+ - As a Developer, I can render a method with minimal parameter calls, So that I know the minimum parameters when calling a method
39
+ - As a Developer, I can render a class with instance attributes and methods, So that I can quickly mock out an entire class
60
40
 
61
41
  ## Usage
62
42
 
63
- TODO: Write usage instructions here
43
+ See all [usages](./USAGE.md)
44
+
45
+ ### Basic Example
46
+
47
+ This example assumes you have this simple class
48
+
49
+
50
+
51
+ ```ruby
52
+ module Sample
53
+ class SimpleClass
54
+ attr_accessor :read_write
55
+
56
+ def position_and_optional(aaa, bbb = 1)
57
+ end
58
+ end
59
+ end
60
+ ```
61
+
62
+
63
+ ### Rendering Examples
64
+
65
+ Here a list of example renderers for the simple class
66
+
67
+ #### Class interface
68
+ Render simple class using class_interface renderer with compact formatting
69
+
70
+ ```ruby
71
+ puts api.render_class(:class_interface, instance: Sample::SimpleClass.new)
72
+ ```
73
+
74
+
75
+
76
+ ```ruby
77
+ class SimpleClass
78
+ attr_accessor :read_write
79
+
80
+ def position_and_optional(aaa, bbb = nil); end
81
+ end
82
+ ```
83
+
84
+ #### Documented class interface
85
+ Render simple class using class_interface_yard renderer to product YARD compatible documentation
86
+
87
+ ```ruby
88
+ puts api.render_class(:class_interface_yard, instance: Sample::SimpleClass.new)
89
+ ```
90
+
91
+
92
+
93
+ ```ruby
94
+ class SimpleClass
95
+ # Read write
96
+ attr_accessor :read_write
97
+
98
+ # Position and optional
99
+ #
100
+ # @param aaa [String] aaa (required)
101
+ # @param bbb [String] bbb (optional)
102
+ def position_and_optional(aaa, bbb = nil)
103
+ end
104
+ end
105
+ ```
106
+
107
+
108
+
64
109
 
65
110
  ## Development
66
111
 
@@ -0,0 +1,79 @@
1
+ # Peeky
2
+
3
+ > Peeky is a Ruby GEM for peaking into ruby classes and extracting meta
4
+
5
+ As a Ruby Developer, I should be able to Reverse engineer classes and methods, so that I can document and understand them
6
+
7
+ ## Development radar
8
+
9
+
10
+ ### Tasks next on list
11
+
12
+ As a Developer, I can use Peeky with a simple API, so that I use Peeky quickly
13
+
14
+ - Add simplified API with examples
15
+ - Start documenting usage instructions
16
+
17
+ As a Developer, I can quickly build requirements, so that I can document project features
18
+
19
+ - Add support for backlog stories and tasks
20
+ - Add usage instructions
21
+
22
+
23
+
24
+ ## Stories and tasks
25
+
26
+ ### Stories - completed
27
+
28
+ As a Developer, I can render a class with instance attributes and methods, So that I can quickly mock out an entire class
29
+
30
+ - Render: Class Interface
31
+
32
+ As a Developer, I can render method signature with debug code, So that mock out a method with parameter logging
33
+
34
+ - Render: Method signature with debug code
35
+
36
+ As a Developer, I can see the method signature of a method, So that I understand it's parameters
37
+
38
+ - Render: Method Signature in compact format
39
+
40
+ As a Developer, I can render a method with minimal parameter calls, So that I know the minimum parameters when calling a method
41
+
42
+ - Render: Simple instance method calls with minimum parameters
43
+
44
+ As a Developer, I can tell if a method is attr_*, so that I can format methods using attr_* notation
45
+
46
+ - Attr Writer Predicate will match true if the method info could be considered a valid attr_writer
47
+ - Attr Writer Predicate will match true if the method info could be considered a valid attr_writer
48
+
49
+ As a Developer, I should be able to interrogate class instance information, so that I can reverse engineer a ruby class
50
+
51
+ - ParameterInfo model to store information about parameters on a method
52
+ - MethodInfo model to store signature of a ruby instance method
53
+ - AttrInfo is a container that represents attr_reader, attr_writer or attr_accessor by storying 1 or 2 MethodInfo
54
+ - ClassInfo stores information about a ruby class. Only support instance methods
55
+
56
+
57
+ ### Tasks - completed
58
+
59
+ As a Developer, I can render a class with RDoc documentation, so that I do not have to manually type RDoc references
60
+
61
+
62
+ As a Developer, I can read detailed API documentation on Peaky, so that I use Peeky quickly
63
+
64
+ - Acid Test: Use the YARD renderer to document Peaky the GEM
65
+
66
+ Setup GitHub Action (test and lint)
67
+
68
+ - Setup Rspec action
69
+ - Setup RuboCop action
70
+
71
+ Setup new Ruby GEM
72
+
73
+ - Build out a standard GEM structure
74
+ - Add semantic versioning
75
+ - Add Rspec unit testing framework
76
+ - Add RuboCop linting
77
+ - Add Guard for automatic watch and test
78
+ - Add GitFlow support
79
+ - Add GitHub Repository
@@ -0,0 +1,322 @@
1
+ # Peeky
2
+
3
+ > Peeky is a Ruby GEM for peaking into ruby classes and extracting meta
4
+
5
+ As a Ruby Developer, I should be able to Reverse engineer classes and methods, so that I can document and understand them
6
+
7
+ ## Usage
8
+
9
+ ### Sample Classes
10
+
11
+ The usage examples listed below will work with these sample classes
12
+
13
+ #### Simple example
14
+
15
+
16
+ ```ruby
17
+ module Sample
18
+ class SimpleClass
19
+ attr_accessor :read_write
20
+
21
+ def position_and_optional(aaa, bbb = 1)
22
+ end
23
+ end
24
+ end
25
+ ```
26
+
27
+ #### Complex example
28
+
29
+
30
+ ```ruby
31
+ module Sample
32
+ class ComplexClass
33
+ attr_accessor :a_read_write1, :a_read_write2
34
+ attr_reader :b_reader, :b_another_reader
35
+ attr_writer :c_writer, :c_another_writer
36
+
37
+ def do_something_method
38
+ end
39
+
40
+ def looks_like_an_attr_reader
41
+ @looks_like_an_attr_reader ||= 5
42
+ end
43
+
44
+ def method_01(aaa); end
45
+
46
+ def method_02(aaa, bbb = 1); end
47
+
48
+ def method_03(aaa, bbb = 1, ccc = 2); end
49
+
50
+ def method_04(*aaa); end
51
+
52
+ def method_05(aaa, bbb = 1, *ccc); end
53
+
54
+ def method_06(**aaa); end
55
+
56
+ def method_07(aaa, *bbb, **ccc); end
57
+
58
+ def method_08(aaa, *bbb, **ccc, &ddd); end
59
+
60
+ def method_09(aaa:); end
61
+
62
+ def method_10(aaa:, bbb: 1); end
63
+
64
+ def questionable?; end
65
+
66
+ def destructive!; end
67
+
68
+ def method_with_every_type_of_paramater(aaa, bbb = 1, *ccc, ddd:, eee: 1, **fff, &ggg); end
69
+
70
+ # Check that methods are sorted
71
+ def alpha_sort2; end
72
+ def alpha_sort1; end
73
+ end
74
+ end
75
+ ```
76
+
77
+
78
+ ### Build Class Information
79
+
80
+ Use build_class_info to extract meta data from a ruby class
81
+
82
+ #### Build ClassInfo
83
+ By default information is lazy loaded only when accessed
84
+
85
+
86
+ ```ruby
87
+ class_info = api.build_class_info(Sample::SimpleClass.new)
88
+
89
+ puts class_info
90
+ ```
91
+
92
+
93
+
94
+ ```shell
95
+ Sample::SimpleClass
96
+ ```
97
+
98
+ #### Build ClassInfo - pre-loaded
99
+ Pre-load will ensure that methods and parameters are loaded straight away.
100
+
101
+
102
+ ```ruby
103
+ class_info = api.build_class_info(Sample::ComplexClass.new, lazy: false)
104
+
105
+ puts class_info
106
+ ```
107
+
108
+
109
+
110
+ ```shell
111
+ Sample::ComplexClass
112
+ ```
113
+
114
+
115
+ ### Render Class
116
+
117
+ Render a class using a pre-defined class renderer that can be referenced by key
118
+
119
+ #### Render class interface using class_info
120
+ Render a basic class interface in compact format "One line per method".
121
+
122
+ Note: Modules are not yet supported in Peeky
123
+
124
+
125
+ ```ruby
126
+ class_info = api.build_class_info(Sample::SimpleClass.new)
127
+
128
+ puts api.render_class(:class_interface, class_info: class_info)
129
+ ```
130
+
131
+ #### Render class interface using an instance of the intended class
132
+
133
+
134
+ ```ruby
135
+ puts api.render_class(:class_interface, instance: Sample::SimpleClass.new)
136
+ ```
137
+
138
+
139
+ ### Render Class Examples
140
+
141
+ Here a list of example renderers for the complex class
142
+
143
+ #### Class interface
144
+ Render simple class using class_interface renderer
145
+
146
+ ```ruby
147
+ puts api.render_class(:class_interface, instance: Sample::SimpleClass.new)
148
+ ```
149
+
150
+
151
+
152
+ ```ruby
153
+ class ComplexClass
154
+ attr_accessor :a_read_write1
155
+ attr_accessor :a_read_write2
156
+
157
+ attr_reader :b_another_reader
158
+ attr_reader :b_reader
159
+ attr_reader :looks_like_an_attr_reader
160
+
161
+ attr_writer :c_another_writer
162
+ attr_writer :c_writer
163
+
164
+ def alpha_sort1; end
165
+ def alpha_sort2; end
166
+ def destructive!; end
167
+ def do_something_method; end
168
+ def method_01(aaa); end
169
+ def method_02(aaa, bbb = nil); end
170
+ def method_03(aaa, bbb = nil, ccc = nil); end
171
+ def method_04(*aaa); end
172
+ def method_05(aaa, bbb = nil, *ccc); end
173
+ def method_06(**aaa); end
174
+ def method_07(aaa, *bbb, **ccc); end
175
+ def method_08(aaa, *bbb, **ccc, &ddd); end
176
+ def method_09(aaa:); end
177
+ def method_10(aaa:, bbb: nil); end
178
+ def method_with_every_type_of_paramater(aaa, bbb = nil, *ccc, ddd:, eee: nil, **fff, &ggg);end
179
+ def questionable?; end
180
+ end
181
+ ```
182
+
183
+ #### Class interface - YARD
184
+ Render complex class using class_interface_yard renderer
185
+
186
+ ```ruby
187
+ puts api.render_class(:class_interface_yard, instance: Sample::ComplexClass.new)
188
+ ```
189
+
190
+
191
+
192
+ ```ruby
193
+ class ComplexClass
194
+ # A read write1
195
+ attr_accessor :a_read_write1
196
+
197
+ # A read write2
198
+ attr_accessor :a_read_write2
199
+
200
+ # B another reader
201
+ attr_reader :b_another_reader
202
+
203
+ # B reader
204
+ attr_reader :b_reader
205
+
206
+ # Looks like an attr reader
207
+ attr_reader :looks_like_an_attr_reader
208
+
209
+ # C another writer
210
+ attr_writer :c_another_writer
211
+
212
+ # C writer
213
+ attr_writer :c_writer
214
+
215
+ # Alpha sort1
216
+ def alpha_sort1
217
+ end
218
+
219
+ # Alpha sort2
220
+ def alpha_sort2
221
+ end
222
+
223
+ # Destructive!
224
+ def destructive!
225
+ end
226
+
227
+ # Do something method
228
+ def do_something_method
229
+ end
230
+
231
+ # Method 01
232
+ #
233
+ # @param aaa [String] aaa (required)
234
+ def method_01(aaa)
235
+ end
236
+
237
+ # Method 02
238
+ #
239
+ # @param aaa [String] aaa (required)
240
+ # @param bbb [String] bbb (optional)
241
+ def method_02(aaa, bbb = nil)
242
+ end
243
+
244
+ # Method 03
245
+ #
246
+ # @param aaa [String] aaa (required)
247
+ # @param bbb [String] bbb (optional)
248
+ # @param ccc [String] ccc (optional)
249
+ def method_03(aaa, bbb = nil, ccc = nil)
250
+ end
251
+
252
+ # Method 04
253
+ #
254
+ # @param aaa [Array<Object>] *aaa - list of aaa
255
+ def method_04(*aaa)
256
+ end
257
+
258
+ # Method 05
259
+ #
260
+ # @param aaa [String] aaa (required)
261
+ # @param bbb [String] bbb (optional)
262
+ # @param ccc [Array<Object>] *ccc - list of ccc
263
+ def method_05(aaa, bbb = nil, *ccc)
264
+ end
265
+
266
+ # Method 06
267
+ #
268
+ # @param aaa [<key: value>...] **aaa - list of key/values
269
+ def method_06(**aaa)
270
+ end
271
+
272
+ # Method 07
273
+ #
274
+ # @param aaa [String] aaa (required)
275
+ # @param bbb [Array<Object>] *bbb - list of bbb
276
+ # @param ccc [<key: value>...] **ccc - list of key/values
277
+ def method_07(aaa, *bbb, **ccc)
278
+ end
279
+
280
+ # Method 08
281
+ #
282
+ # @param aaa [String] aaa (required)
283
+ # @param bbb [Array<Object>] *bbb - list of bbb
284
+ # @param ccc [<key: value>...] **ccc - list of key/values
285
+ # @param ddd [Block] &ddd
286
+ def method_08(aaa, *bbb, **ccc, &ddd)
287
+ end
288
+
289
+ # Method 09
290
+ #
291
+ # @param aaa [String] aaa: <value for aaa> (required)
292
+ def method_09(aaa:)
293
+ end
294
+
295
+ # Method 10
296
+ #
297
+ # @param aaa [String] aaa: <value for aaa> (required)
298
+ # @param bbb [String] bbb: <value for bbb> (optional)
299
+ def method_10(aaa:, bbb: nil)
300
+ end
301
+
302
+ # Method with every type of paramater
303
+ #
304
+ # @param aaa [String] aaa (required)
305
+ # @param bbb [String] bbb (optional)
306
+ # @param ccc [Array<Object>] *ccc - list of ccc
307
+ # @param ddd [String] ddd: <value for ddd> (required)
308
+ # @param eee [String] eee: <value for eee> (optional)
309
+ # @param fff [<key: value>...] **fff - list of key/values
310
+ # @param ggg [Block] &ggg
311
+ def method_with_every_type_of_paramater(aaa, bbb = nil, *ccc, ddd:, eee: nil, **fff, &ggg)
312
+ end
313
+
314
+ # Questionable?
315
+ #
316
+ # @return [Boolean] true when questionable?
317
+ def questionable?
318
+ end
319
+ end
320
+ ```
321
+
322
+ #### Debug class info