peeky 0.0.19 → 0.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,13 +8,16 @@ module Peeky
8
8
  # instance.simple('first_param')
9
9
  # instance.complex('aaa', ddd: 'ddd')
10
10
  class MethodCallMinimumParamsRender
11
+ # Method signature stores a MethodInfo object
11
12
  attr_reader :method_signature
12
13
 
13
- def initialize(method_signature, instance_name = 'instance')
14
+ def initialize(method_signature, **opts)
15
+ instance_name = opts[:instance_name] || 'instance'
14
16
  @instance_name = instance_name
15
17
  @method_signature = method_signature
16
18
  end
17
19
 
20
+ # Render the a method call with minimal parameters
18
21
  def render
19
22
  name = method_signature.name
20
23
 
@@ -28,10 +31,6 @@ module Peeky
28
31
 
29
32
  "#{@instance_name}.#{name}#{params}"
30
33
  end
31
-
32
- def debug
33
- puts render
34
- end
35
34
  end
36
35
  end
37
36
  end
@@ -4,14 +4,54 @@ module Peeky
4
4
  module Renderer
5
5
  # Render: Method Signature in compact format
6
6
  #
7
- # Example output:
7
+ # === Example output (:default):
8
+ # def simple(first_param)
9
+ # end
10
+ #
11
+ # def complex(aaa, bbb = nil, *ccc, ddd:, eee: nil, **fff, &ggg)
12
+ # end
13
+ #
14
+ # === Example output (:compact):
8
15
  # def simple(first_param); end
9
16
  # def complex(aaa, bbb = nil, *ccc, ddd:, eee: nil, **fff, &ggg); end
10
17
  class MethodSignatureRender
18
+ # Indentation prefix as a string.
19
+ #
20
+ # Defaults to ''
21
+ #
22
+ # If you were writing a class into a file with an existing
23
+ # module, you may set the indent to ' ' if you wanted this
24
+ # render to indent by two spaces
25
+ attr_accessor :indent
26
+
27
+ # Style of method rendering [:default, :compact]
28
+ #
29
+ # default:: will render +def method_name+ and +end+ on separate lines
30
+ # compact:: will render +def method_name+ and +end+ on same line
31
+ # @return [Symbol] style
32
+ attr_accessor :style
33
+
34
+ # Method signature stores a MethodInfo object
11
35
  attr_reader :method_signature
12
36
 
13
- def initialize(method_signature)
37
+ def initialize(method_signature, **_opts)
14
38
  @method_signature = method_signature
39
+ @indent = ''
40
+ @style = :compact
41
+ end
42
+
43
+ # Render the method signature in the selected style
44
+ def render
45
+ output = []
46
+ if @style == :compact
47
+ signature = "#{render_signature};"
48
+ output.push "#{signature.ljust(80)}#{render_end}"
49
+ end
50
+ if @style == :default
51
+ output.push render_signature
52
+ output.push render_end
53
+ end
54
+ output.join("\n")
15
55
  end
16
56
 
17
57
  def render_signature
@@ -19,20 +59,11 @@ module Peeky
19
59
 
20
60
  formatted_parameters = method_signature.parameters.map(&:signature_format).join(', ')
21
61
  params = formatted_parameters.length.zero? ? '' : "(#{formatted_parameters})"
22
- "def #{name}#{params}"
62
+ "#{@indent}def #{name}#{params}"
23
63
  end
24
64
 
25
65
  def render_end
26
- 'end'
27
- end
28
-
29
- def render
30
- signature = "#{render_signature};"
31
- "#{signature.ljust(80)}#{render_end}"
32
- end
33
-
34
- def debug
35
- puts render
66
+ "#{@indent}end"
36
67
  end
37
68
  end
38
69
  end
@@ -22,14 +22,22 @@ module Peeky
22
22
  # puts ggg # &ggg is block with many calling options, example - instance_eval(&block) if block_given?
23
23
  # end
24
24
  class MethodSignatureWithDebugRender
25
+ # Method signature stores a MethodInfo object
25
26
  attr_reader :method_signature
26
27
 
27
- def initialize(method_signature)
28
+ def initialize(method_signature, **_opts)
28
29
  @method_signature = method_signature
29
30
 
30
31
  @render_signature = Peeky::Renderer::MethodSignatureRender.new(method_signature)
31
32
  end
32
33
 
34
+ # Render the method with debug statements for each parameter
35
+ def render
36
+ render_method
37
+ end
38
+
39
+ private
40
+
33
41
  def render_method
34
42
  name = method_signature.name
35
43
 
@@ -38,7 +46,7 @@ module Peeky
38
46
  indent = ' '
39
47
  output += "#{indent}puts 'method name: #{name}'\n"
40
48
 
41
- output += render_logic(indent, 30)
49
+ output += render_debug_logic(indent, 30)
42
50
 
43
51
  indent = ''
44
52
  output += "#{indent}#{@render_signature.render_end}\n"
@@ -47,7 +55,7 @@ module Peeky
47
55
  end
48
56
 
49
57
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
50
- def render_logic(indent, size)
58
+ def render_debug_logic(indent, size)
51
59
  output = ''
52
60
  method_signature.parameters.each do |parameter|
53
61
  line = ''
@@ -73,14 +81,6 @@ module Peeky
73
81
  output
74
82
  end
75
83
  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
76
-
77
- def render
78
- render_method
79
- end
80
-
81
- def debug
82
- puts render
83
- end
84
84
  end
85
85
  end
86
86
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Peeky
4
- VERSION = '0.0.19'
4
+ VERSION = '0.0.33'
5
5
  end
@@ -3,13 +3,14 @@
3
3
  require_relative 'lib/peeky/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
+ # https://piotrmurach.com/articles/writing-a-ruby-gem-specification/
6
7
  spec.required_ruby_version = '>= 2.5'
7
8
  spec.name = 'peeky'
8
9
  spec.version = Peeky::VERSION
9
- spec.authors = ['David C']
10
+ spec.authors = ['David Cruwys']
10
11
  spec.email = ['david@ideasmen.com.au']
11
12
 
12
- spec.summary = 'Extracting meta data from ruby classes'
13
+ spec.summary = 'Take a peek into your ruby classes and extract useful meta data'
13
14
  spec.description = <<-TEXT
14
15
  Peeky is a Ruby GEM for peaking into ruby classes and extracting meta data.
15
16
  You can use this meta data to recreate classes, interfaces, documentation etc.
@@ -28,6 +29,10 @@ Gem::Specification.new do |spec|
28
29
  spec.metadata['homepage_uri'] = spec.homepage
29
30
  spec.metadata['source_code_uri'] = 'https://github.com/klueless-io/peeky'
30
31
  spec.metadata['changelog_uri'] = 'https://github.com/klueless-io/peeky/commits/master'
32
+ # Go to: https://rubydoc.info/
33
+ # Click Add Project:
34
+ # git@github.com:klueless-io/peeky
35
+ spec.metadata['documentation_uri'] = 'https://rubydoc.info/github/klueless-io/peeky/master'
31
36
 
32
37
  # Specify which files should be added to the gem when it is released.
33
38
  # The `git ls-files -z` loads the RubyGem files that have been added into git.
@@ -40,6 +45,13 @@ Gem::Specification.new do |spec|
40
45
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
41
46
  spec.require_paths = ['lib']
42
47
  # spec.extensions = ['ext/peeky/extconf.rb']
43
-
48
+ spec.extra_rdoc_files = ['README.md', 'STORIES.md']
49
+ spec.rdoc_options += [
50
+ '--title', 'peeky by appydave.com',
51
+ '--main', 'README.md',
52
+ '--files STORIES.MD USAGE.MD'
53
+ ]
54
+
55
+ spec.add_dependency 'activesupport'
44
56
  # spec.add_dependency 'tty-box', '~> 0.5.0'
45
57
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peeky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.33
5
5
  platform: ruby
6
6
  authors:
7
- - David C
7
+ - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-03 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2020-11-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: |2
14
28
  Peeky is a Ruby GEM for peaking into ruby classes and extracting meta data.
15
29
  You can use this meta data to recreate classes, interfaces, documentation etc.
@@ -18,7 +32,9 @@ email:
18
32
  - david@ideasmen.com.au
19
33
  executables: []
20
34
  extensions: []
21
- extra_rdoc_files: []
35
+ extra_rdoc_files:
36
+ - README.md
37
+ - STORIES.md
22
38
  files:
23
39
  - ".github/workflows/ruby.yml"
24
40
  - ".gitignore"
@@ -29,9 +45,10 @@ files:
29
45
  - Gemfile
30
46
  - Guardfile
31
47
  - LICENSE.txt
32
- - README-stories.md
33
48
  - README.md
34
49
  - Rakefile
50
+ - STORIES.md
51
+ - USAGE.md
35
52
  - bin/console
36
53
  - bin/k
37
54
  - bin/kgitsync
@@ -40,13 +57,17 @@ files:
40
57
  - hooks/pre-commit
41
58
  - hooks/update-version
42
59
  - lib/peeky.rb
60
+ - lib/peeky/api.rb
43
61
  - lib/peeky/attr_info.rb
44
62
  - lib/peeky/class_info.rb
63
+ - lib/peeky/example/yard_sample.rb
45
64
  - lib/peeky/method_info.rb
46
65
  - lib/peeky/parameter_info.rb
47
66
  - lib/peeky/predicates/attr_reader_predicate.rb
48
67
  - lib/peeky/predicates/attr_writer_predicate.rb
68
+ - lib/peeky/renderer/class_debug_render.rb
49
69
  - lib/peeky/renderer/class_interface_render.rb
70
+ - lib/peeky/renderer/class_interface_yard_render.rb
50
71
  - lib/peeky/renderer/method_call_minimum_params_render.rb
51
72
  - lib/peeky/renderer/method_signature_render.rb
52
73
  - lib/peeky/renderer/method_signature_with_debug_render.rb
@@ -59,8 +80,14 @@ metadata:
59
80
  homepage_uri: http://appydave.com/gems/peeky
60
81
  source_code_uri: https://github.com/klueless-io/peeky
61
82
  changelog_uri: https://github.com/klueless-io/peeky/commits/master
83
+ documentation_uri: https://rubydoc.info/github/klueless-io/peeky/master
62
84
  post_install_message:
63
- rdoc_options: []
85
+ rdoc_options:
86
+ - "--title"
87
+ - peeky by appydave.com
88
+ - "--main"
89
+ - README.md
90
+ - "--files STORIES.MD USAGE.MD"
64
91
  require_paths:
65
92
  - lib
66
93
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -77,5 +104,5 @@ requirements: []
77
104
  rubygems_version: 3.1.4
78
105
  signing_key:
79
106
  specification_version: 4
80
- summary: Extracting meta data from ruby classes
107
+ summary: Take a peek into your ruby classes and extract useful meta data
81
108
  test_files: []