ginny 0.5.0 → 0.5.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
  SHA256:
3
- metadata.gz: cb6043b2cd9d1c30adfc0964cbb1cff21a551caf1833b43082b11725f932c51d
4
- data.tar.gz: da193f605882b4acb52dd5482ae62858b261d69490cfefb6b1a2ade475f97a28
3
+ metadata.gz: d25c4e9649691bd4bebc48a0875e7ae5db2f91b46a67111ee567b86e08e2a87d
4
+ data.tar.gz: 8baa17b48c0ec91e1654ce02261675a4ee9e64ac71a03e8c7212d813adf964e1
5
5
  SHA512:
6
- metadata.gz: e90efbfb5a8e2ba9fbc1e47a188b753c70557672ed4b7bd1c40d0ec7f0d5571667dafb421a7ae37f678d753b7d21453b56d797996f72821b63bec689392c9161
7
- data.tar.gz: 4d820bf235013b8e2210f88cc80cd50d966404c3c4d4c265039d6f259b80c7ff46d0d376873f869296e8c3b4197cac47f1969c4afa173e41456c747bf7074748
6
+ metadata.gz: 02a0a34e5148d8aab2f35eed3b4d01fe521883f3c3281ef4a02bd29b8e7dc341e7a444bace053719f2abe2e00b8001c022b1ea9011045e8f5645d9ae11bcb0ef
7
+ data.tar.gz: 4595b6f9d30cd39f980fc1b997c0b8157b576e18ae0b94a277592c08b5347dc05090aca474f4881f39287799919099eec7a8013064a7f025c55aed6c49597f1c
@@ -11,7 +11,7 @@ Style/DocumentationMethod:
11
11
  Exclude:
12
12
  - 'test/**/*.rb'
13
13
 
14
- Layout/EmptyLinesAroundClassBody:
14
+ Style/SingleLineMethods:
15
15
  Exclude:
16
16
  - 'test/**/*.rb'
17
17
 
@@ -19,60 +19,67 @@ Layout/EmptyLinesAroundClassBody:
19
19
  Lint/Debugger:
20
20
  Enabled: true
21
21
 
22
+ # ==============================================================================
23
+ # Layout
24
+ # ==============================================================================
25
+
22
26
  Metrics/LineLength:
23
27
  Max: 150
24
28
 
25
- Style/StringLiterals:
26
- EnforcedStyle: double_quotes
27
-
28
- Style/FrozenStringLiteralComment:
29
+ Layout/EmptyLineAfterGuardClause:
29
30
  Enabled: false
30
31
 
31
- Naming/HeredocDelimiterNaming:
32
+ Layout/EmptyLinesAroundModuleBody:
32
33
  Enabled: false
33
34
 
34
- # Only use braces if the function expects a hash argument. [different in Ruby 2.7+](https://blog.saeloun.com/2019/10/07/ruby-2-7-keyword-arguments-redesign.html)
35
- Style/BracesAroundHashParameters:
35
+ Layout/EmptyLinesAroundClassBody:
36
36
  Enabled: false
37
37
 
38
- Layout/IndentFirstHashElement:
39
- EnforcedStyle: consistent
40
-
41
- Layout/IndentFirstArrayElement:
42
- EnforcedStyle: consistent
38
+ Layout/EmptyLinesAroundBlockBody:
39
+ Enabled: false
43
40
 
44
41
  # https://unix.stackexchange.com/a/18789
45
42
  Layout/TrailingBlankLines:
46
43
  EnforcedStyle: final_newline
47
44
 
48
- Style/TrailingCommaInArguments:
49
- EnforcedStyleForMultiline: comma
45
+ # ==============================================================================
46
+ # Strings
47
+ # ==============================================================================
50
48
 
51
- Style/TrailingCommaInArrayLiteral:
52
- EnforcedStyleForMultiline: comma
49
+ Style/StringLiterals:
50
+ EnforcedStyle: double_quotes
53
51
 
54
- Style/TrailingCommaInHashLiteral:
55
- EnforcedStyleForMultiline: comma
52
+ Style/FrozenStringLiteralComment:
53
+ Enabled: false
56
54
 
57
- Layout/EmptyLineAfterGuardClause:
55
+ Naming/HeredocDelimiterNaming:
58
56
  Enabled: false
59
57
 
60
- Style/DefWithParentheses:
58
+ # ==============================================================================
59
+ # Numbers
60
+ # ==============================================================================
61
+
62
+ Style/ZeroLengthPredicate:
61
63
  Enabled: false
62
64
 
63
- Style/MethodCallWithoutArgsParentheses:
65
+ Style/NumericPredicate:
64
66
  Enabled: false
65
67
 
66
- # Explicit, not redundant
67
- Style/RedundantReturn:
68
+ Naming/VariableNumber:
69
+ EnforcedStyle: snake_case
70
+
71
+ # ==============================================================================
72
+ # Braces, Brackets, & Parens
73
+ # ==============================================================================
74
+
75
+ Style/DefWithParentheses:
68
76
  Enabled: false
69
77
 
70
- # Explicit, not redundant
71
- Style/RedundantSelf:
78
+ Style/MethodCallWithoutArgsParentheses:
72
79
  Enabled: false
73
80
 
74
- # Use of `&` with bracket access isn't what I'd call "readable".
75
- Style/SafeNavigation:
81
+ # Only use braces if the function expects a hash argument. [different in Ruby 2.7+](https://blog.saeloun.com/2019/10/07/ruby-2-7-keyword-arguments-redesign.html)
82
+ Style/BracesAroundHashParameters:
76
83
  Enabled: false
77
84
 
78
85
  Style/WordArray:
@@ -81,58 +88,88 @@ Style/WordArray:
81
88
  Style/SymbolArray:
82
89
  EnforcedStyle: brackets
83
90
 
84
- # TODO: File issue to ignore enums when using `EnforcedStyle: assign_inside_condition`.
85
- Style/ConditionalAssignment:
86
- # EnforcedStyle: assign_inside_condition
87
- # EnforcedStyle: assign_to_condition
88
- Enabled: false
91
+ # ==============================================================================
92
+ # Trailing Commas
93
+ # ==============================================================================
89
94
 
90
- Lint/HandleExceptions:
91
- AllowComments: true
95
+ Style/TrailingCommaInArguments:
96
+ EnforcedStyleForMultiline: comma
92
97
 
93
- # Lint/UnneededCopDisableDirective:
94
- # Enabled: false
98
+ Style/TrailingCommaInArrayLiteral:
99
+ EnforcedStyleForMultiline: comma
95
100
 
96
- Metrics/BlockLength:
101
+ Style/TrailingCommaInHashLiteral:
102
+ EnforcedStyleForMultiline: comma
103
+
104
+ # ==============================================================================
105
+ # Fewer lines doesn't mean better code
106
+ # ==============================================================================
107
+
108
+ Metrics/ModuleLength:
97
109
  Enabled: false
98
110
 
99
111
  Metrics/ClassLength:
100
112
  Enabled: false
101
113
 
102
- Metrics/ModuleLength:
114
+ Metrics/MethodLength:
103
115
  Enabled: false
104
116
 
105
- Metrics/MethodLength:
117
+ Metrics/BlockLength:
106
118
  Enabled: false
107
119
 
108
- Metrics/AbcSize:
120
+ # ==============================================================================
121
+ # Names
122
+ # ==============================================================================
123
+
124
+ # Everything else is snake case, numbers should be too.
125
+ Naming/VariableNumber:
126
+ EnforcedStyle: snake_case
127
+
128
+ # ==============================================================================
129
+ # Unsorted
130
+ # ==============================================================================
131
+
132
+ # Default value (special_inside_parentheses) is ridiculous.
133
+ # Look for yourself: https://www.rubydoc.info/gems/rubocop/0.69.0/RuboCop/Cop/Layout/IndentFirstHashElement
134
+ Layout/IndentFirstHashElement:
135
+ EnforcedStyle: consistent
136
+
137
+ # Default value (special_inside_parentheses) is ridiculous.
138
+ # Look for yourself: https://www.rubydoc.info/gems/rubocop/0.69.0/RuboCop/Cop/Layout/IndentFirstArrayElement
139
+ Layout/IndentFirstArrayElement:
140
+ EnforcedStyle: consistent
141
+
142
+ Layout/AlignHash:
109
143
  Enabled: false
110
144
 
111
- Metrics/CyclomaticComplexity:
145
+ # Explicit, not redundant
146
+ Style/RedundantReturn:
112
147
  Enabled: false
113
148
 
114
- Metrics/PerceivedComplexity:
149
+ # Explicit, not redundant
150
+ Style/RedundantSelf:
115
151
  Enabled: false
116
152
 
117
- Layout/EmptyLinesAroundBlockBody:
153
+ # `x&.y&.[](:argument)` isn't what I'd call "readable".
154
+ # https://stackoverflow.com/questions/34794697/using-with-the-safe-navigation-operator-in-ruby
155
+ Style/SafeNavigation:
118
156
  Enabled: false
119
157
 
120
- Layout/EmptyLinesAroundBlockBody:
158
+ # TODO: File issue to ignore enums when using `EnforcedStyle: assign_inside_condition`.
159
+ Style/ConditionalAssignment:
121
160
  Enabled: false
122
161
 
123
- Layout/EmptyLinesAroundBlockBody:
162
+ Lint/HandleExceptions:
163
+ AllowComments: true
164
+
165
+ Metrics/AbcSize:
124
166
  Enabled: false
125
167
 
126
- Style/ZeroLengthPredicate:
168
+ Metrics/CyclomaticComplexity:
127
169
  Enabled: false
128
170
 
129
- Style/NumericPredicate:
171
+ Metrics/PerceivedComplexity:
130
172
  Enabled: false
131
173
 
132
174
  Style/CommentedKeyword:
133
175
  Enabled: False
134
-
135
- Naming/VariableNumber:
136
- EnforcedStyle: snake_case
137
-
138
- # [1]: https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8
@@ -2,6 +2,29 @@
2
2
 
3
3
  <!-- ## master (unreleased) -->
4
4
 
5
+ ## 0.5.2 (2019-12-09)
6
+
7
+ ### Added
8
+
9
+ - Improved doc comments for various functions.
10
+ - Add `Ginny::INDENT` constant.
11
+
12
+ ### Changed
13
+
14
+ - Make sure not to remove newlines when trimming trailing whitespace before calls to render.
15
+
16
+ ## 0.5.1 (2019-12-03)
17
+
18
+ ### Added
19
+
20
+ - JSON Schema definition for Ginny definition files.
21
+
22
+ ### Changed
23
+
24
+ - Update badges in readme.
25
+ - Add [tcd/coolkit](https://github.com/tcd/coolkit) dependency.
26
+ - Extracted `String.indent`, `String.comment`, and `symbolize_keys` into their own gem for reuse.
27
+
5
28
  ## 0.5.0 (2019-11-28)
6
29
 
7
30
  ### Added
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ginny (0.5.0)
4
+ ginny (0.5.2)
5
+ coolkit (~> 0.2.2)
5
6
  dry-inflector (~> 0.2.0)
6
7
 
7
8
  GEM
@@ -10,6 +11,7 @@ GEM
10
11
  ansi (1.5.0)
11
12
  builder (3.2.3)
12
13
  coderay (1.1.2)
14
+ coolkit (0.2.2)
13
15
  coveralls (0.8.23)
14
16
  json (>= 1.8, < 3)
15
17
  simplecov (~> 0.16.1)
data/README.md CHANGED
@@ -1,15 +1,17 @@
1
1
  # Ginny
2
2
 
3
+ [![Gem](https://img.shields.io/gem/v/ginny)][rubygems]
4
+ [![Build Status](https://travis-ci.org/tcd/ginny.svg?branch=master)][travis-ci]
5
+ [![Coverage Status](https://coveralls.io/repos/github/tcd/ginny/badge.svg?branch=master)][coveralls-ci]
6
+ [![Documentation](http://img.shields.io/badge/docs-rubydoc.info-blue.svg)][rubydoc-gem]
7
+ [![GitHub](https://img.shields.io/github/license/tcd/ginny)][license]
8
+
9
+ [rubygems]: https://rubygems.org/gems/ginny
10
+ [travis-ci]: https://travis-ci.org/tcd/ginny
11
+ [coveralls-ci]: https://coveralls.io/github/tcd/ginny?branch=master
12
+ [rubydoc-gem]: https://www.rubydoc.info/gems/ginny/0.5.0
13
+ [license]: https://github.com/tcd/ginny/blob/master/LICENSE.txt
3
14
 
4
- [![Build Status](https://travis-ci.org/tcd/gql.svg?branch=master)](https://travis-ci.org/tcd/gql)
5
- [![Coverage Status](https://coveralls.io/repos/github/tcd/ginny/badge.svg?branch=master)](https://coveralls.io/github/tcd/ginny?branch=master)
6
- [![Documentation](http://img.shields.io/badge/docs-rubydoc.org-blue.svg)](https://rubydoc.org/github/tcd/ginny/master)
7
- [![GitHub](https://img.shields.io/github/license/tcd/ginny)](https://github.com/tcd/ginny/blob/master/LICENSE.txt)
8
-
9
- [![Gem](https://img.shields.io/gem/v/ginny)](https://rubygems.org/gems/ginny) [[1]][gem link 1] [[2]][gem link 2]
10
-
11
- [gem link 1]: https://help.rubygems.org/discussions/problems/37131-gem-push-name-too-close-to-typo-protected-gem
12
- [gem link 2]: https://github.com/rubygems/rubygems.org/issues/2058
13
15
 
14
16
  ## Installation
15
17
 
@@ -39,5 +39,6 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency "rake", "~> 10.0"
40
40
  spec.add_development_dependency "simplecov"
41
41
 
42
+ spec.add_runtime_dependency "coolkit", "~> 0.2.2"
42
43
  spec.add_runtime_dependency "dry-inflector", "~> 0.2.0"
43
44
  end
@@ -1,6 +1,9 @@
1
+ require "coolkit"
2
+
1
3
  # Ruby code generator.
2
4
  module Ginny
3
5
  QUOTE = '"'.freeze
6
+ INDENT = " ".freeze
4
7
  end
5
8
 
6
9
  Dir.glob(File.join(__dir__, "ginny", "**/*.rb")).each { |file| require file }
@@ -9,7 +9,7 @@ module Ginny
9
9
  # @param path [String]
10
10
  # @return [Hash<Symbol>]
11
11
  def self.load_yaml(path)
12
- return Ginny.symbolize_keys(YAML.load_file(File.expand_path(path)))
12
+ return Coolkit.symbolize_keys(YAML.load_file(File.expand_path(path)))
13
13
  end
14
14
 
15
15
  # Load data from a JSON file.
@@ -46,6 +46,8 @@ module Ginny
46
46
  return array.map { |f| self.create(f) }
47
47
  end
48
48
 
49
+ # Return generated code as a string.
50
+ #
49
51
  # @return [String]
50
52
  def render()
51
53
  parts = []
@@ -1,7 +1,7 @@
1
1
  require "dry/inflector"
2
2
 
3
3
  module Ginny
4
- # Used to generate a [class](https://ruby-doc.org/core-2.6.5/Class.html)
4
+ # Used to generate a [class](https://ruby-doc.org/core-2.6.5/Class.html).
5
5
  class Class
6
6
 
7
7
  # Name of the class.
@@ -49,6 +49,8 @@ module Ginny
49
49
  return c
50
50
  end
51
51
 
52
+ # Write generated code out to a file.
53
+ #
52
54
  # @param folder [String]
53
55
  # @return [String]
54
56
  def generate(folder = ".")
@@ -57,6 +59,8 @@ module Ginny
57
59
  return path
58
60
  end
59
61
 
62
+ # Return generated code as a string.
63
+ #
60
64
  # @return [String]
61
65
  def render()
62
66
  parts = []
@@ -66,10 +70,10 @@ module Ginny
66
70
  parts << (self.body&.length&.positive? ? self.body.indent(2) : nil)
67
71
  parts << "end"
68
72
  if self.modules.length > 0
69
- body = parts.compact.join("\n").gsub(/\s+$/, "")
73
+ body = parts.compact.join("\n").gsub(/(\s+)$/, "")
70
74
  return Ginny.mod(body, self.modules)
71
75
  end
72
- return parts.compact.join("\n").gsub(/\s+$/, "")
76
+ return parts.compact.join("\n").gsub(/(\s+)$/, "")
73
77
  end
74
78
 
75
79
  # @return [String]
@@ -45,6 +45,8 @@ module Ginny
45
45
  return f
46
46
  end
47
47
 
48
+ # Return generated code as a string.
49
+ #
48
50
  # @return [String]
49
51
  def render()
50
52
  # return self.render_compact() if self.body.nil? && self.params.length == 0
@@ -56,7 +58,7 @@ module Ginny
56
58
  parts << self.body.indent(2) unless self.body.nil?
57
59
  parts << "end"
58
60
 
59
- body = parts.compact.join("\n").gsub(/\s+$/, "")
61
+ body = parts.compact.join("\n").gsub(/(\s+)$/, "")
60
62
 
61
63
  return Ginny.mod(body, self.modules) if self.modules.length > 0
62
64
  return body
@@ -11,10 +11,10 @@ module Ginny
11
11
  # Description of the param. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported.
12
12
  # @return [String]
13
13
  attr_accessor :description
14
- # [Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the attribute.
14
+ # [Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the param.
15
15
  # @return [String]
16
16
  attr_accessor :type
17
- # Default value for the Param.
17
+ # Default value for the param.
18
18
  # Set `optional` as `true` for a default `nil` value.
19
19
  # @return [String]
20
20
  attr_accessor :default
@@ -53,6 +53,8 @@ module Ginny
53
53
  return array.map { |p| self.create(p) }
54
54
  end
55
55
 
56
+ # Return generated code as a string.
57
+ #
56
58
  # @return [String]
57
59
  def render
58
60
  parts = []
@@ -1,3 +1,3 @@
1
1
  module Ginny
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.5.2".freeze
3
3
  end
@@ -0,0 +1,146 @@
1
+ {
2
+ "$id": "https://github.com/tcd/ginny/blob/master/schema/ginny.json",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Files used by `Ginny` to generate ruby code.",
5
+ "type": "object",
6
+ "definitions": {
7
+ "class": {
8
+ "description": "Used to generate a [class](https://ruby-doc.org/core-2.6.5/Class.html).",
9
+ "type": "object",
10
+ "required": [
11
+ "name"
12
+ ],
13
+ "properties": {
14
+ "name": {
15
+ "description": "Name of the class.",
16
+ "type": "string"
17
+ },
18
+ "description": {
19
+ "description": "Description of the class. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported.",
20
+ "type": "string"
21
+ },
22
+ "parent": {
23
+ "description": "Name of a class to inherit from. (Ex: `YourNewClass < Parent`)",
24
+ "type": "string"
25
+ },
26
+ "modules": {
27
+ "description": "List of modules to declare the class inside.",
28
+ "type": "string"
29
+ },
30
+ "attrs": {
31
+ "description": "An array of `Ginny::Attr`s.",
32
+ "type": "array",
33
+ "items": {
34
+ "$ref": "#/definitions/attr"
35
+ }
36
+ },
37
+ "body": {
38
+ "description": "String to write into the body of the class.",
39
+ "type": "string"
40
+ },
41
+ "file_prefix": {
42
+ "description": "String to prepend to the name of the generated file.",
43
+ "type": "string"
44
+ }
45
+ }
46
+ },
47
+ "attr": {
48
+ "description": "Used to generate an instance variable with getters/setters.",
49
+ "type": "object",
50
+ "required": [
51
+ "name"
52
+ ],
53
+ "properties": {
54
+ "name": {
55
+ "description": "Name of the attribute.",
56
+ "type": "string"
57
+ },
58
+ "description": {
59
+ "description": "Description of the attribute. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported.",
60
+ "type": "string"
61
+ },
62
+ "type": {
63
+ "description": "[Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the attribute.",
64
+ "type": "string"
65
+ },
66
+ "default": {
67
+ "description": "Default value for the attribute; set in it's Class's `initialize` function.",
68
+ "type": "string"
69
+ },
70
+ "read_only": {
71
+ "description": "If `true`, an `attr_reader` will be generated for the attribute instead of an `attr_accessor`.",
72
+ "type": "boolean"
73
+ }
74
+ }
75
+ },
76
+ "func": {
77
+ "description": "Used to generate a [method](https://ruby-doc.org/core-2.6.5/doc/syntax/methods_rdoc.html).",
78
+ "type": "object",
79
+ "required": [
80
+ "name"
81
+ ],
82
+ "properties": {
83
+ "name": {
84
+ "description": "Name of the function.",
85
+ "type": "string"
86
+ },
87
+ "description": {
88
+ "description": "Description of the function. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported.",
89
+ "type": "string"
90
+ },
91
+ "return_type": {
92
+ "description": "Return [type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the function.",
93
+ "type": "string"
94
+ },
95
+ "body": {
96
+ "description": "String to write into the body of the function.",
97
+ "type": "string"
98
+ },
99
+ "modules": {
100
+ "description": "List of modules to declare the function inside of.",
101
+ "type": "string"
102
+ },
103
+ "params": {
104
+ "description": "An array of `Ginny::Param`s.",
105
+ "type": "array",
106
+ "items": {
107
+ "$ref": "#/definitions/param"
108
+ }
109
+ }
110
+ }
111
+ },
112
+ "param": {
113
+ "description": "Used to generate a function [parameter](https://ruby-doc.org/core-2.6.5/doc/syntax/methods_rdoc.html#label-Arguments).",
114
+ "type": "object",
115
+ "required": [
116
+ "name"
117
+ ],
118
+ "properties": {
119
+ "name": {
120
+ "description": "Name of the param.",
121
+ "type": "string"
122
+ },
123
+ "description": {
124
+ "description": "Description of the param. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported.",
125
+ "type": "string"
126
+ },
127
+ "type": {
128
+ "description": "[Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the param.",
129
+ "type": "string"
130
+ },
131
+ "default": {
132
+ "description": "Default value for the Param. Set `optional` as `true` for a default `nil` value.",
133
+ "type": "string"
134
+ },
135
+ "optional": {
136
+ "description": "If `true`, the default value will be `nil`.",
137
+ "type": "boolean"
138
+ },
139
+ "keyword": {
140
+ "description": "If `true`, the param will be generated as a [keyword argument](https://bugs.ruby-lang.org/issues/14183).",
141
+ "type": "boolean"
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
@@ -0,0 +1,107 @@
1
+ ---
2
+ "$id": https://github.com/tcd/ginny/blob/master/schema/ginny.json
3
+ "$schema": http://json-schema.org/draft-07/schema#
4
+ title: Files used by `Ginny` to generate ruby code.
5
+ type: object
6
+
7
+ definitions:
8
+
9
+ class:
10
+ description: Used to generate a [class](https://ruby-doc.org/core-2.6.5/Class.html).
11
+ type: object
12
+ required: [name]
13
+ properties:
14
+ name:
15
+ description: Name of the class.
16
+ type: string
17
+ description:
18
+ description: Description of the class. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported.
19
+ type: string
20
+ parent:
21
+ description: "Name of a class to inherit from. (Ex: `YourNewClass < Parent`)"
22
+ type: string
23
+ modules:
24
+ description: List of modules to declare the class inside.
25
+ type: string
26
+ attrs:
27
+ description: An array of `Ginny::Attr`s.
28
+ type: array
29
+ items:
30
+ "$ref": "#/definitions/attr"
31
+ body:
32
+ description: String to write into the body of the class.
33
+ type: string
34
+ file_prefix:
35
+ description: String to prepend to the name of the generated file.
36
+ type: string
37
+
38
+ attr:
39
+ description: Used to generate an instance variable with getters/setters.
40
+ type: object
41
+ required: [name]
42
+ properties:
43
+ name:
44
+ description: Name of the attribute.
45
+ type: string
46
+ description:
47
+ description: Description of the attribute. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported.
48
+ type: string
49
+ type:
50
+ description: "[Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the attribute."
51
+ type: string
52
+ default:
53
+ description: Default value for the attribute; set in it's Class's `initialize` function.
54
+ type: string
55
+ read_only:
56
+ description: If `true`, an `attr_reader` will be generated for the attribute instead of an `attr_accessor`.
57
+ type: boolean
58
+
59
+ func:
60
+ description: Used to generate a [method](https://ruby-doc.org/core-2.6.5/doc/syntax/methods_rdoc.html).
61
+ type: object
62
+ required: [name]
63
+ properties:
64
+ name:
65
+ description: Name of the function.
66
+ type: string
67
+ description:
68
+ description: Description of the function. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported.
69
+ type: string
70
+ return_type:
71
+ description: Return [type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the function.
72
+ type: string
73
+ body:
74
+ description: String to write into the body of the function.
75
+ type: string
76
+ modules:
77
+ description: List of modules to declare the function inside of.
78
+ type: string
79
+ params:
80
+ description: An array of `Ginny::Param`s.
81
+ type: array
82
+ items:
83
+ "$ref": "#/definitions/param"
84
+
85
+ param:
86
+ description: Used to generate a function [parameter](https://ruby-doc.org/core-2.6.5/doc/syntax/methods_rdoc.html#label-Arguments).
87
+ type: object
88
+ required: [name]
89
+ properties:
90
+ name:
91
+ description: Name of the param.
92
+ type: string
93
+ description:
94
+ description: Description of the param. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported.
95
+ type: string
96
+ type:
97
+ description: "[Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the param."
98
+ type: string
99
+ default:
100
+ description: Default value for the Param. Set `optional` as `true` for a default `nil` value.
101
+ type: string
102
+ optional:
103
+ description: If `true`, the default value will be `nil`.
104
+ type: boolean
105
+ keyword:
106
+ description: If `true`, the param will be generated as a [keyword argument](https://bugs.ruby-lang.org/issues/14183).
107
+ type: boolean
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ginny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clay Dunston
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-28 00:00:00.000000000 Z
11
+ date: 2019-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: coolkit
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.2.2
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.2.2
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: dry-inflector
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -168,17 +182,16 @@ files:
168
182
  - lib/ginny/models/class.rb
169
183
  - lib/ginny/models/func.rb
170
184
  - lib/ginny/models/param.rb
171
- - lib/ginny/string/comment.rb
172
- - lib/ginny/string/indent.rb
173
- - lib/ginny/symbolize.rb
174
185
  - lib/ginny/version.rb
186
+ - schema/ginny.json
187
+ - schema/ginny.schema.yml
175
188
  homepage: https://github.com/tcd/ginny
176
189
  licenses:
177
190
  - MIT
178
191
  metadata:
179
192
  homepage_uri: https://github.com/tcd/ginny
180
193
  source_code_uri: https://github.com/tcd/ginny
181
- documentation_uri: https://www.rubydoc.info/gems/ginny/0.5.0
194
+ documentation_uri: https://www.rubydoc.info/gems/ginny/0.5.2
182
195
  changelog_uri: https://github.com/tcd/ginny/blob/master/CHANGELOG.md
183
196
  yard.run: yri
184
197
  post_install_message:
@@ -1,19 +0,0 @@
1
- # Monkeypatch some convenience methods in to the String class.
2
- class String
3
- # Adds a comment string (`"# "`) after every newline in a string.
4
- #
5
- # @param indent_empty_lines [Boolean]
6
- # @return [void]
7
- def comment!(indent_empty_lines = true)
8
- re = indent_empty_lines ? /^/ : /^(?!$)/
9
- gsub!(re, "# ")
10
- end
11
-
12
- # Returns a copy of a string with a comment (`"# "`) after every newline in a string.
13
- #
14
- # @param indent_empty_lines [Boolean]
15
- # @return [String]
16
- def comment(indent_empty_lines = true)
17
- dup.tap { |s| s.comment!(indent_empty_lines) }
18
- end
19
- end
@@ -1,52 +0,0 @@
1
- # Monkeypatch some convenience methods in to the String class.
2
- class String
3
-
4
- # def titleize2(string)
5
- # words = self.split(" ")
6
- # skips = ["and", "of", "the", "in", "to", "over", "an", "a"]
7
- # words.each do |word|
8
- # if word == words[0] || !skips.include?(word)
9
- # element.capitalize!
10
- # end
11
- # end
12
- # answer = array.join(" ")
13
- # return answer
14
- # end
15
-
16
- # Same as {indent}, except it indents the receiver in-place.
17
- #
18
- # Returns the indented string, or `nil` if there was nothing to indent.
19
- #
20
- # @param amount [Integer] The level of indentation to add.
21
- # @param indent_string [String] Defaults to tab if a tab is present in the string, and `" "` otherwise.
22
- # @param indent_empty_lines [Boolean]
23
- #
24
- # @return [void]
25
- def indent!(amount, indent_string = nil, indent_empty_lines = false)
26
- indent_string = indent_string || self[/^[ \t]/] || " "
27
- re = indent_empty_lines ? /^/ : /^(?!$)/
28
- gsub!(re, indent_string * amount)
29
- end
30
-
31
- # Indents the lines in the receiver.
32
- #
33
- # The second argument, `indent_string`, specifies which indent string to
34
- # use. The default is `nil`, which tells the method to make a guess by
35
- # peeking at the first indented line, and fallback to a space if there is
36
- # none.
37
- #
38
- # While `indent_string` is typically one space or tab, it may be any string.
39
- #
40
- # The third argument, `indent_empty_lines`, is a flag that says whether
41
- # empty lines should be indented. Default is `false`.
42
- #
43
- # @param amount [Integer] The level of indentation to add.
44
- # @param indent_string [String] Defaults to tab if a tab is present in the string, and `" "` otherwise.
45
- # @param indent_empty_lines [Boolean]
46
- #
47
- # @return [String]
48
- def indent(amount, indent_string = nil, indent_empty_lines = false)
49
- dup.tap { |s| s.indent!(amount, indent_string, indent_empty_lines) }
50
- end
51
-
52
- end
@@ -1,31 +0,0 @@
1
- module Ginny
2
- # Recursively convert keys in a Hash or Array to symbols.
3
- #
4
- # See:
5
- # - [original code](https://avdi.codes/recursively-symbolize-keys/)
6
- # - [array support](https://gist.github.com/neektza/8585746)
7
- #
8
- # @param arg [Hash,Array]
9
- # @return [Hash,Array]
10
- def self.symbolize_keys(arg)
11
- if arg.is_a?(Hash)
12
- arg.inject({}) do |result, (key, value)|
13
- new_key = case key
14
- when String then key.to_sym()
15
- else key
16
- end
17
- new_value = case value
18
- when Hash then symbolize_keys(value)
19
- when Array then symbolize_keys(value)
20
- else value
21
- end
22
- result[new_key] = new_value
23
- result
24
- end
25
- elsif arg.is_a?(Array)
26
- arg.map { |e| symbolize_keys(e) }
27
- else
28
- arg
29
- end
30
- end
31
- end