ginny 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cb6043b2cd9d1c30adfc0964cbb1cff21a551caf1833b43082b11725f932c51d
4
+ data.tar.gz: da193f605882b4acb52dd5482ae62858b261d69490cfefb6b1a2ade475f97a28
5
+ SHA512:
6
+ metadata.gz: e90efbfb5a8e2ba9fbc1e47a188b753c70557672ed4b7bd1c40d0ec7f0d5571667dafb421a7ae37f678d753b7d21453b56d797996f72821b63bec689392c9161
7
+ data.tar.gz: 4d820bf235013b8e2210f88cc80cd50d966404c3c4d4c265039d6f259b80c7ff46d0d376873f869296e8c3b4197cac47f1969c4afa173e41456c747bf7074748
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,138 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3.0
3
+
4
+ Style/Documentation:
5
+ Enabled: true
6
+ Exclude:
7
+ - 'test/**/*.rb'
8
+
9
+ Style/DocumentationMethod:
10
+ Enabled: true
11
+ Exclude:
12
+ - 'test/**/*.rb'
13
+
14
+ Layout/EmptyLinesAroundClassBody:
15
+ Exclude:
16
+ - 'test/**/*.rb'
17
+
18
+ # Don't leave calls to pry lying around.
19
+ Lint/Debugger:
20
+ Enabled: true
21
+
22
+ Metrics/LineLength:
23
+ Max: 150
24
+
25
+ Style/StringLiterals:
26
+ EnforcedStyle: double_quotes
27
+
28
+ Style/FrozenStringLiteralComment:
29
+ Enabled: false
30
+
31
+ Naming/HeredocDelimiterNaming:
32
+ Enabled: false
33
+
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:
36
+ Enabled: false
37
+
38
+ Layout/IndentFirstHashElement:
39
+ EnforcedStyle: consistent
40
+
41
+ Layout/IndentFirstArrayElement:
42
+ EnforcedStyle: consistent
43
+
44
+ # https://unix.stackexchange.com/a/18789
45
+ Layout/TrailingBlankLines:
46
+ EnforcedStyle: final_newline
47
+
48
+ Style/TrailingCommaInArguments:
49
+ EnforcedStyleForMultiline: comma
50
+
51
+ Style/TrailingCommaInArrayLiteral:
52
+ EnforcedStyleForMultiline: comma
53
+
54
+ Style/TrailingCommaInHashLiteral:
55
+ EnforcedStyleForMultiline: comma
56
+
57
+ Layout/EmptyLineAfterGuardClause:
58
+ Enabled: false
59
+
60
+ Style/DefWithParentheses:
61
+ Enabled: false
62
+
63
+ Style/MethodCallWithoutArgsParentheses:
64
+ Enabled: false
65
+
66
+ # Explicit, not redundant
67
+ Style/RedundantReturn:
68
+ Enabled: false
69
+
70
+ # Explicit, not redundant
71
+ Style/RedundantSelf:
72
+ Enabled: false
73
+
74
+ # Use of `&` with bracket access isn't what I'd call "readable".
75
+ Style/SafeNavigation:
76
+ Enabled: false
77
+
78
+ Style/WordArray:
79
+ EnforcedStyle: brackets
80
+
81
+ Style/SymbolArray:
82
+ EnforcedStyle: brackets
83
+
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
89
+
90
+ Lint/HandleExceptions:
91
+ AllowComments: true
92
+
93
+ # Lint/UnneededCopDisableDirective:
94
+ # Enabled: false
95
+
96
+ Metrics/BlockLength:
97
+ Enabled: false
98
+
99
+ Metrics/ClassLength:
100
+ Enabled: false
101
+
102
+ Metrics/ModuleLength:
103
+ Enabled: false
104
+
105
+ Metrics/MethodLength:
106
+ Enabled: false
107
+
108
+ Metrics/AbcSize:
109
+ Enabled: false
110
+
111
+ Metrics/CyclomaticComplexity:
112
+ Enabled: false
113
+
114
+ Metrics/PerceivedComplexity:
115
+ Enabled: false
116
+
117
+ Layout/EmptyLinesAroundBlockBody:
118
+ Enabled: false
119
+
120
+ Layout/EmptyLinesAroundBlockBody:
121
+ Enabled: false
122
+
123
+ Layout/EmptyLinesAroundBlockBody:
124
+ Enabled: false
125
+
126
+ Style/ZeroLengthPredicate:
127
+ Enabled: false
128
+
129
+ Style/NumericPredicate:
130
+ Enabled: false
131
+
132
+ Style/CommentedKeyword:
133
+ 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
@@ -0,0 +1,14 @@
1
+ ---
2
+ include:
3
+ - "**/*.rb"
4
+ exclude:
5
+ - spec/**/*
6
+ - test/**/*
7
+ - vendor/**/*
8
+ domains: []
9
+ reporters:
10
+ - typecheck
11
+ - rubocop
12
+ # - typecheck:strict
13
+ require_paths: []
14
+ max_files: 5000
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.4
7
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,2 @@
1
+ --charset utf-8
2
+ --markup markdown
@@ -0,0 +1,68 @@
1
+ # Changelog
2
+
3
+ <!-- ## master (unreleased) -->
4
+
5
+ ## 0.5.0 (2019-11-28)
6
+
7
+ ### Added
8
+
9
+ - Add [dry-rb/dry-inflector](https://github.com/dry-rb/dry-inflector) dependency.
10
+ - Add `file_prefix` argument to `Ginny::Class` for String to prepend to the name of the generated file.
11
+
12
+ ### Changed
13
+
14
+ - Update *description* and *documentation_uri* in gemspec.
15
+
16
+ ### Fixed
17
+
18
+ - Fix doc comment in `Ginny.symbolize_keys` that was causing `yard gems` to give this warning:
19
+ ```
20
+ [warn]: @param tag has unknown parameter name: obj
21
+ in file `lib/food_truck/symbolize.rb' near line 10
22
+ ```
23
+
24
+ ## 0.4.0 (2019-11-21)
25
+
26
+ ### Added
27
+
28
+ - Add `body` argument to `Ginny::Class` for code to be generated in the class body.
29
+
30
+ ## 0.3.0 (2019-11-21)
31
+
32
+ ### Added
33
+
34
+ - Add the option to wrap generated code in modules.
35
+
36
+ ## 0.2.1 (2019-11-18)
37
+
38
+ ### Changed
39
+
40
+ - Generate function body in `Ginny::Func.render`
41
+
42
+ ## 0.2.0 (2019-11-17)
43
+
44
+ ### Added
45
+
46
+ - Generate Functions with Yard doc comments. (`Ginny::Func`)
47
+ - Generate Function Parameters. (`Ginny::Param`)
48
+ - Add support for generating classes with inheritance.
49
+ - Add `food_truck` executable (WIP).
50
+
51
+ ### Changed
52
+
53
+ - Rename `Ginny::Klass` to `Ginny::Class`
54
+ - Rename `Ginny::Attribute` to `Ginny::Attr`
55
+
56
+ ### Fixed
57
+
58
+ - Don't use Yard `@!attribute` tags unless the attributes are added dynamically (ex: Rails Models)
59
+
60
+ ## 0.1.0 (2019-11-15)
61
+
62
+ ### Added
63
+
64
+ - Add changelog
65
+ - Implement basic functionality.
66
+ - Generate Classes with Yard doc comments. (`Ginny::Klass`)
67
+ - Generate getters/setters (`attr_accessor`s) with Yard doc comments. (`Ginny::Attribute`)
68
+ - Load data from YAML/JSON files.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ginny.gemspec
4
+ gemspec
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ginny (0.5.0)
5
+ dry-inflector (~> 0.2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ansi (1.5.0)
11
+ builder (3.2.3)
12
+ coderay (1.1.2)
13
+ coveralls (0.8.23)
14
+ json (>= 1.8, < 3)
15
+ simplecov (~> 0.16.1)
16
+ term-ansicolor (~> 1.3)
17
+ thor (>= 0.19.4, < 2.0)
18
+ tins (~> 1.6)
19
+ docile (1.3.2)
20
+ dry-inflector (0.2.0)
21
+ json (2.2.0)
22
+ method_source (0.9.2)
23
+ minitest (5.13.0)
24
+ minitest-focus (1.1.2)
25
+ minitest (>= 4, < 6)
26
+ minitest-reporters (1.4.2)
27
+ ansi
28
+ builder
29
+ minitest (>= 5.0)
30
+ ruby-progressbar
31
+ pry (0.12.2)
32
+ coderay (~> 1.1.0)
33
+ method_source (~> 0.9.0)
34
+ rake (10.5.0)
35
+ ruby-progressbar (1.10.1)
36
+ simplecov (0.16.1)
37
+ docile (~> 1.1)
38
+ json (>= 1.8, < 3)
39
+ simplecov-html (~> 0.10.0)
40
+ simplecov-html (0.10.2)
41
+ term-ansicolor (1.7.1)
42
+ tins (~> 1.0)
43
+ thor (0.20.3)
44
+ tins (1.22.2)
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ bundler (~> 2.0)
51
+ coveralls (~> 0.8.23)
52
+ ginny!
53
+ minitest (~> 5.0)
54
+ minitest-focus (~> 1.1)
55
+ minitest-reporters (~> 1.4)
56
+ pry (~> 0.12.2)
57
+ rake (~> 10.0)
58
+ simplecov
59
+
60
+ BUNDLED WITH
61
+ 2.0.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Clay Dunston
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,147 @@
1
+ # Ginny
2
+
3
+
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
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem "ginny"
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ ```ruby
25
+ bundle
26
+ ```
27
+
28
+ Or install it yourself as:
29
+
30
+ ```ruby
31
+ gem install ginny
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ### From the command line
37
+
38
+ ```yaml
39
+ # person.yml
40
+ ---
41
+ name: Human
42
+ description: This class models a person.
43
+ modules: [MilkyWay, Earth]
44
+ parent: Mammal
45
+ attrs:
46
+ - name: Name
47
+ type: String
48
+ - name: Age
49
+ description: Number of years the human has been alive.
50
+ type: Integer
51
+ read_only: true
52
+
53
+ ```
54
+
55
+ ```shell
56
+ $ ginny person.yml
57
+ ```
58
+
59
+ ### From Ruby code
60
+
61
+ ```ruby
62
+ require "ginny"
63
+
64
+ data = {
65
+ name: "Human",
66
+ description: "This class models a person.",
67
+ modules: ["MilkyWay", "Earth"],
68
+ parent: "Mammal",
69
+ attrs: [
70
+ { name: "name", type: "String" },
71
+ { name: "age", type: "Integer" read_only: true, description: "Number of years the human has been alive." },
72
+ ],
73
+ }
74
+
75
+ c = Ginny::Class.create(data)
76
+ c.render() #=> Returns the generated code as a string.
77
+ c.generate() #=> Writes the generated code to a given folder, or the current directory if no argument is passed.
78
+ ```
79
+
80
+ ```ruby
81
+ # human.rb
82
+ module MilkyWay
83
+ module Earth
84
+ # This class models a person.
85
+ class Human < Mammal
86
+ # @return [String]
87
+ attr_accessor :name
88
+ # Number of years the human has been alive.
89
+ # @return [Integer]
90
+ attr_reader :age
91
+ end
92
+ end
93
+ end
94
+ ```
95
+
96
+ ## Supported Arguments
97
+
98
+ ### `Ginny::Class`
99
+
100
+ | Name | Type | Description |
101
+ | --------------- | -------------------- | -------------------------------------------------------------- |
102
+ | name (required) | `String` | Name of the class. |
103
+ | description | `String` | Description of the class. [Markdown][markdown] is supported. |
104
+ | body | `String` | String to write into the body of the class. |
105
+ | parent | `String` | Name of a class to inherit from. (Ex: `YourNewClass < Parent`) |
106
+ | modules | `Array<String>` | List of modules to declare the class inside of |
107
+ | attrs | `Array<Ginny::Attr>` | An array of Attrs. |
108
+
109
+ ### `Ginny::Attr`
110
+
111
+ | Name | Type | Description |
112
+ | --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
113
+ | name (required) | `String` | Name of the attribute. |
114
+ | description | `String` | Description of the attribute. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported. |
115
+ | type | `String` | [Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the attribute. |
116
+ | default | `Any` | Default value for the attribute; set in it's Class's `initialize` function. |
117
+ | read_only | `Boolean` | If `true`, an `attr_reader` will be generated for the attribute instead of an `attr_accessor`. |
118
+
119
+ ### `Ginny::Func`
120
+
121
+ | Name | Type | Description |
122
+ | --------------- | --------------------- | ---------------------------------------------------------------------------------------------------------- |
123
+ | name (required) | `String` | Name of the function. |
124
+ | description | `String` | Description of the function. [Markdown][markdown] is supported. |
125
+ | return_type | `String` | Return [type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the function. |
126
+ | body | `String` | String to write into the body of the function. |
127
+ | modules | `Array<String>` | List of modules to declare the function inside of |
128
+ | params | `Array<Ginny::Param>` | An array of Params. |
129
+
130
+ ### `Ginny::Param`
131
+
132
+ | Name | Type | Description |
133
+ | --------------- | --------- | -------------------------------------------------------------------------------------------------------------------- |
134
+ | name (required) | `String` | Name of the param. |
135
+ | description | `String` | Description of the param. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported. |
136
+ | type | `String` | [Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the param. |
137
+ | default | `Any` | Default value for the param. Set `optional` as `true` for a default `nil` value. |
138
+ | optional | `Boolean` | If `true`, the default value will be `nil`. |
139
+ | keyword | `Boolean` | If `true`, the param will be generated as a [keyword argument](https://bugs.ruby-lang.org/issues/14183). |
140
+
141
+ ## Contributing
142
+
143
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tcd/ginny.
144
+
145
+ ## License
146
+
147
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).