food_truck 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bd099a583e774b65a4da7e95b2761a1936421aed671eb0bfa32efa28fc73dacd
4
+ data.tar.gz: 742a146fb686263044cf127db107df3e954bdef60d14a42b8b3a0d8f23f5efa6
5
+ SHA512:
6
+ metadata.gz: 1c8331443590d3edcb78aaac9f43d05b9441fee4d26958829e137ab21996d47583a155cd0b29c149719e9aaa61728a5a641145f6a11e5ceb96548660bc65ef22
7
+ data.tar.gz: da2cde49548e0c58223a7676bacdddfa282e1cb02d11b821d539fcb04658b5ee3d07fb18e7a189dc2bf1dcacdf99043eb916d4c9a64046cc4d1205e9170faf06
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rubocop.yml ADDED
@@ -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
data/.solargraph.yml ADDED
@@ -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
data/.travis.yml ADDED
@@ -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
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --charset utf-8
2
+ --markup markdown
data/CHANGELOG.md ADDED
@@ -0,0 +1,54 @@
1
+ # Changelog
2
+
3
+ ## master (unreleased)
4
+
5
+ ### 0.5.0 (2019-11-25)
6
+
7
+ - Add [dry-rb/dry-inflector](https://github.com/dry-rb/dry-inflector) dependency.
8
+ - Add `file_prefix` argument to `FoodTruck::Class` for String to prepend to the name of the generated file.
9
+
10
+ ## 0.4.0 (2019-11-21)
11
+
12
+ ### Added
13
+
14
+ - Add `body` argument to `FoodTruck::Class` for code to be generated in the class body.
15
+
16
+ ## 0.3.0 (2019-11-21)
17
+
18
+ ### Added
19
+
20
+ - Add the option to wrap generated code in modules.
21
+
22
+ ## 0.2.1 (2019-11-18)
23
+
24
+ ### Changed
25
+
26
+ - Generate function body in `FoodTruck::Func.render`
27
+
28
+ ## 0.2.0 (2019-11-17)
29
+
30
+ ### Added
31
+
32
+ - Generate Functions with Yard doc comments. (`FoodTruck::Func`)
33
+ - Generate Function Parameters. (`FoodTruck::Param`)
34
+ - Add support for generating classes with inheritance.
35
+ - Add `food_truck` executable (WIP).
36
+
37
+ ### Changed
38
+
39
+ - Rename `FoodTruck::Klass` to `FoodTruck::Class`
40
+ - Rename `FoodTruck::Attribute` to `FoodTruck::Attr`
41
+
42
+ ### Fixed
43
+
44
+ - Don't use Yard `@!attribute` tags unless the attributes are added dynamically (ex: Rails Models)
45
+
46
+ ## 0.1.0 (2019-11-15)
47
+
48
+ ### Added
49
+
50
+ - Add changelog
51
+ - Implement basic functionality.
52
+ - Generate Classes with Yard doc comments. (`FoodTruck::Klass`)
53
+ - Generate getters/setters (`attr_accessor`s) with Yard doc comments. (`FoodTruck::Attribute`)
54
+ - 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 food_truck.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ food_truck (0.4.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
+ food_truck!
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
data/LICENSE.txt ADDED
@@ -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.
data/README.md ADDED
@@ -0,0 +1,146 @@
1
+ # FoodTruck
2
+
3
+ [![Gem](https://img.shields.io/gem/v/food_truck)][rubygems]
4
+ [![Build Status](https://travis-ci.org/tcd/food_truck.svg?branch=master)][travis-ci]
5
+ [![Coverage Status](https://coveralls.io/repos/github/tcd/food_truck/badge.svg?branch=master)][coveralls-ci]
6
+ [![Documentation](http://img.shields.io/badge/docs-rubydoc.info-blue.svg)][rubydoc-gem]
7
+
8
+ [rubygems]: https://rubygems.org/gems/food_truck
9
+ [travis-ci]: https://travis-ci.org/tcd/food_truck
10
+ [coveralls-ci]: https://coveralls.io/github/tcd/food_truck?branch=master
11
+ [rubydoc-gem]: https://www.rubydoc.info/gems/food_truck/0.5.0
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem "food_truck"
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ ```ruby
24
+ bundle
25
+ ```
26
+
27
+ Or install it yourself as:
28
+
29
+ ```ruby
30
+ gem install food_truck
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ### From the command line
36
+
37
+ ```yaml
38
+ # person.yml
39
+ ---
40
+ name: Human
41
+ description: This class models a person.
42
+ modules: [MilkyWay, Earth]
43
+ parent: Mammal
44
+ attrs:
45
+ - name: Name
46
+ type: String
47
+ - name: Age
48
+ description: Number of years the human has been alive.
49
+ type: Integer
50
+ read_only: true
51
+
52
+ ```
53
+
54
+ ```shell
55
+ $ food_truck person.yml
56
+ ```
57
+
58
+ ### From Ruby code
59
+
60
+ ```ruby
61
+ require "food_truck"
62
+
63
+ data = {
64
+ name: "Human",
65
+ description: "This class models a person.",
66
+ modules: ["MilkyWay", "Earth"],
67
+ parent: "Mammal",
68
+ attrs: [
69
+ { name: "name", type: "String" },
70
+ { name: "age", type: "Integer" read_only: true, description: "Number of years the human has been alive." },
71
+ ],
72
+ }
73
+
74
+ c = FoodTruck::Class.create(data)
75
+ c.render() #=> Returns the generated code as a string.
76
+ c.generate() #=> Writes the generated code to a given folder, or the current directory if no argument is passed.
77
+ ```
78
+
79
+ ```ruby
80
+ # human.rb
81
+ module MilkyWay
82
+ module Earth
83
+ # This class models a person.
84
+ class Human < Mammal
85
+ # @return [String]
86
+ attr_accessor :name
87
+ # Number of years the human has been alive.
88
+ # @return [Integer]
89
+ attr_reader :age
90
+ end
91
+ end
92
+ end
93
+ ```
94
+
95
+ ## Supported Arguments
96
+
97
+ ### `FoodTruck::Class`
98
+
99
+ | Name | Type | Description |
100
+ | --------------- | -------------------- | -------------------------------------------------------------- |
101
+ | name (required) | `String` | Name of the class. |
102
+ | description | `String` | Description of the class. [Markdown][markdown] is supported. |
103
+ | body | `String` | String to write into the body of the class. |
104
+ | parent | `String` | Name of a class to inherit from. (Ex: `YourNewClass < Parent`) |
105
+ | modules | `Array<String>` | List of modules to declare the class inside of |
106
+ | attrs | `Array<FoodTruck::Attr>` | An array of Attrs. |
107
+
108
+ ### `FoodTruck::Attr`
109
+
110
+ | Name | Type | Description |
111
+ | --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
112
+ | name (required) | `String` | Name of the attribute. |
113
+ | description | `String` | Description of the attribute. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported. |
114
+ | type | `String` | [Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the attribute. |
115
+ | default | `Any` | Default value for the attribute; set in it's Class's `initialize` function. |
116
+ | read_only | `Boolean` | If `true`, an `attr_reader` will be generated for the attribute instead of an `attr_accessor`. |
117
+
118
+ ### `FoodTruck::Func`
119
+
120
+ | Name | Type | Description |
121
+ | --------------- | --------------------- | ---------------------------------------------------------------------------------------------------------- |
122
+ | name (required) | `String` | Name of the function. |
123
+ | description | `String` | Description of the function. [Markdown][markdown] is supported. |
124
+ | return_type | `String` | Return [type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the function. |
125
+ | body | `String` | String to write into the body of the function. |
126
+ | modules | `Array<String>` | List of modules to declare the function inside of |
127
+ | params | `Array<FoodTruck::Param>` | An array of Params. |
128
+
129
+ ### `FoodTruck::Param`
130
+
131
+ | Name | Type | Description |
132
+ | --------------- | --------- | -------------------------------------------------------------------------------------------------------------------- |
133
+ | name (required) | `String` | Name of the param. |
134
+ | description | `String` | Description of the param. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported. |
135
+ | type | `String` | [Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the param. |
136
+ | default | `Any` | Default value for the param. Set `optional` as `true` for a default `nil` value. |
137
+ | optional | `Boolean` | If `true`, the default value will be `nil`. |
138
+ | keyword | `Boolean` | If `true`, the param will be generated as a [keyword argument](https://bugs.ruby-lang.org/issues/14183). |
139
+
140
+ ## Contributing
141
+
142
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tcd/food_truck.
143
+
144
+ ## License
145
+
146
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).