peeky 0.0.15 → 0.0.31

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.15'
4
+ VERSION = '0.0.31'
5
5
  end
@@ -3,19 +3,20 @@
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
- You can use this meta data to recreate classes, interfaces, documentation etc.
16
+ You can use this meta data to recreate classes, interfaces, documentation etc.
16
17
  or use it just to understand the internals of a class.
17
18
  TEXT
18
-
19
+
19
20
  spec.homepage = 'http://appydave.com/gems/peeky'
20
21
  spec.license = 'MIT'
21
22
 
@@ -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.
@@ -39,6 +44,14 @@ Gem::Specification.new do |spec|
39
44
  spec.bindir = 'exe'
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']
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'
43
56
  # spec.add_dependency 'tty-box', '~> 0.5.0'
44
57
  end
metadata CHANGED
@@ -1,24 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peeky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.31
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: []
13
- description: " Peeky is a Ruby GEM for peaking into ruby classes and extracting meta
14
- data.\n You can use this meta data to recreate classes, interfaces, documentation
15
- etc. \n or use it just to understand the internals of a class.\n"
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'
27
+ description: |2
28
+ Peeky is a Ruby GEM for peaking into ruby classes and extracting meta data.
29
+ You can use this meta data to recreate classes, interfaces, documentation etc.
30
+ or use it just to understand the internals of a class.
16
31
  email:
17
32
  - david@ideasmen.com.au
18
33
  executables: []
19
34
  extensions: []
20
- extra_rdoc_files: []
35
+ extra_rdoc_files:
36
+ - README.md
37
+ - STORIES.md
21
38
  files:
39
+ - ".github/workflows/ruby.yml"
22
40
  - ".gitignore"
23
41
  - ".rspec"
24
42
  - ".rubocop.yml"
@@ -29,6 +47,8 @@ files:
29
47
  - LICENSE.txt
30
48
  - README.md
31
49
  - Rakefile
50
+ - STORIES.md
51
+ - USAGE.md
32
52
  - bin/console
33
53
  - bin/k
34
54
  - bin/kgitsync
@@ -37,13 +57,16 @@ files:
37
57
  - hooks/pre-commit
38
58
  - hooks/update-version
39
59
  - lib/peeky.rb
60
+ - lib/peeky/api.rb
40
61
  - lib/peeky/attr_info.rb
41
62
  - lib/peeky/class_info.rb
63
+ - lib/peeky/example/yard_sample.rb
42
64
  - lib/peeky/method_info.rb
43
65
  - lib/peeky/parameter_info.rb
44
66
  - lib/peeky/predicates/attr_reader_predicate.rb
45
67
  - lib/peeky/predicates/attr_writer_predicate.rb
46
68
  - lib/peeky/renderer/class_interface_render.rb
69
+ - lib/peeky/renderer/class_interface_yard_render.rb
47
70
  - lib/peeky/renderer/method_call_minimum_params_render.rb
48
71
  - lib/peeky/renderer/method_signature_render.rb
49
72
  - lib/peeky/renderer/method_signature_with_debug_render.rb
@@ -56,8 +79,14 @@ metadata:
56
79
  homepage_uri: http://appydave.com/gems/peeky
57
80
  source_code_uri: https://github.com/klueless-io/peeky
58
81
  changelog_uri: https://github.com/klueless-io/peeky/commits/master
82
+ documentation_uri: https://rubydoc.info/github/klueless-io/peeky/master
59
83
  post_install_message:
60
- rdoc_options: []
84
+ rdoc_options:
85
+ - "--title"
86
+ - peeky by appydave.com
87
+ - "--main"
88
+ - README.md
89
+ - "--files STORIES.MD USAGE.MD"
61
90
  require_paths:
62
91
  - lib
63
92
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -74,5 +103,5 @@ requirements: []
74
103
  rubygems_version: 3.1.4
75
104
  signing_key:
76
105
  specification_version: 4
77
- summary: Extracting meta data from ruby classes
106
+ summary: Take a peek into your ruby classes and extract useful meta data
78
107
  test_files: []