simple-annotations 0.9.0 → 1.0.0
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.
- checksums.yaml +4 -4
- data/.debride_whitelist +11 -0
- data/.github/workflows/main.yml +23 -0
- data/.rspec +3 -0
- data/.rubocop.yml +99 -0
- data/Gemfile +2 -2
- data/LICENSE.txt +21 -0
- data/README.md +137 -0
- data/Rakefile +42 -39
- data/VERSION +1 -0
- data/bom.xml +578 -0
- data/lib/simple-annotations.rb +103 -110
- data/samples/test_base.rb +20 -0
- data/samples/test_class_method.rb +35 -0
- data/samples/test_fields.rb +21 -0
- data/samples/test_hook.rb +22 -0
- data/simple-annotations.gemspec +29 -22
- metadata +129 -20
- data/coding_convention.yml +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb8dd5c29e7e0c93d2462675fdce3029c205cebce502703edcac597fe2786497
|
4
|
+
data.tar.gz: e2b68572f27da1eabc468250616455db8b6325299ec1daa01d7197cec3127f54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d0f0a2eaab17864cf63deeb7ab16dc19c0b95c5b6e2b85149a9b5a81efbf09a010441722b6fea57209705a57c6c4e4556ed37f06bd95c5b3f0a9a7dd22886f5
|
7
|
+
data.tar.gz: 9673641541d4389035e43a3ea4fa4ec9db9d50a190e6a49016bd125db8a496dff199bdef36c6bfddc5eaff95c7cc1fe6b414e9c4e4fee4821923bb8b8b562bda
|
data/.debride_whitelist
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.2.3
|
14
|
+
- name: Getting dependencies (Bundle)
|
15
|
+
run: |
|
16
|
+
gem install bundler -v 2.2.3
|
17
|
+
bundle install
|
18
|
+
- name: Running test Rspec
|
19
|
+
run: |
|
20
|
+
bundle exec rake
|
21
|
+
- name: Running CVE security audit
|
22
|
+
run: |
|
23
|
+
bundle exec rake audit
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
SuggestExtensions: false
|
4
|
+
|
5
|
+
|
6
|
+
Gemspec/DevelopmentDependencies:
|
7
|
+
Exclude:
|
8
|
+
- 'simple-annotations.gemspec'
|
9
|
+
|
10
|
+
# Offense count: 1
|
11
|
+
# This cop supports safe autocorrection (--autocorrect).
|
12
|
+
# Configuration parameters: EnforcedStyle.
|
13
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
|
14
|
+
Layout/EmptyLinesAroundClassBody:
|
15
|
+
Exclude:
|
16
|
+
- 'lib/simple-annotations.rb'
|
17
|
+
|
18
|
+
# Offense count: 1
|
19
|
+
# This cop supports safe autocorrection (--autocorrect).
|
20
|
+
# Configuration parameters: AllowInHeredoc.
|
21
|
+
Layout/TrailingWhitespace:
|
22
|
+
Exclude:
|
23
|
+
- 'lib/simple-annotations.rb'
|
24
|
+
|
25
|
+
# Offense count: 2
|
26
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
27
|
+
Metrics/MethodLength:
|
28
|
+
Max: 11
|
29
|
+
|
30
|
+
# Offense count: 8
|
31
|
+
# Configuration parameters: AsciiConstants.
|
32
|
+
Naming/AsciiIdentifiers:
|
33
|
+
Exclude:
|
34
|
+
- 'sample/test.rb'
|
35
|
+
- 'samples/test.rb'
|
36
|
+
|
37
|
+
# Offense count: 1
|
38
|
+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
39
|
+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
|
40
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
41
|
+
Naming/FileName:
|
42
|
+
Exclude:
|
43
|
+
- 'Rakefile.rb'
|
44
|
+
- 'spec/simple-annotations_spec.rb'
|
45
|
+
- 'lib/simple-annotations.rb'
|
46
|
+
|
47
|
+
# Offense count: 2
|
48
|
+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
49
|
+
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
|
50
|
+
Naming/MethodParameterName:
|
51
|
+
Exclude:
|
52
|
+
- 'lib/simple-annotations.rb'
|
53
|
+
|
54
|
+
# Offense count: 4
|
55
|
+
# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns.
|
56
|
+
# SupportedStyles: snake_case, camelCase
|
57
|
+
Naming/VariableName:
|
58
|
+
Exclude:
|
59
|
+
- 'lib/simple-annotations.rb'
|
60
|
+
- 'samples/test.rb'
|
61
|
+
|
62
|
+
# Offense count: 2
|
63
|
+
# This cop supports safe autocorrection (--autocorrect).
|
64
|
+
Style/ClassMethods:
|
65
|
+
Exclude:
|
66
|
+
- 'lib/simple-annotations.rb'
|
67
|
+
|
68
|
+
# Offense count: 3
|
69
|
+
Style/ClassVars:
|
70
|
+
Exclude:
|
71
|
+
- 'lib/simple-annotations.rb'
|
72
|
+
|
73
|
+
# Offense count: 2
|
74
|
+
# This cop supports safe autocorrection (--autocorrect).
|
75
|
+
Style/ColonMethodDefinition:
|
76
|
+
Exclude:
|
77
|
+
- 'lib/simple-annotations.rb'
|
78
|
+
|
79
|
+
# Offense count: 5
|
80
|
+
# Configuration parameters: AllowedConstants.
|
81
|
+
Style/Documentation:
|
82
|
+
Exclude:
|
83
|
+
- 'spec/**/*'
|
84
|
+
- 'test/**/*'
|
85
|
+
- 'lib/simple-annotations.rb'
|
86
|
+
- 'samples/test.rb'
|
87
|
+
|
88
|
+
# Offense count: 1
|
89
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
90
|
+
# Configuration parameters: EnforcedStyle.
|
91
|
+
# SupportedStyles: always, always_true, never
|
92
|
+
Style/FrozenStringLiteralComment:
|
93
|
+
Exclude:
|
94
|
+
- 'samples/test.rb'
|
95
|
+
|
96
|
+
# Offense count: 1
|
97
|
+
Style/MissingRespondToMissing:
|
98
|
+
Exclude:
|
99
|
+
- 'lib/simple-annotations.rb'
|
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Romain GEORGES
|
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,137 @@
|
|
1
|
+
# Simple Annotations 4 Ruby
|
2
|
+
|
3
|
+
Simple method annotations like in java or Python methods decorators
|
4
|
+
|
5
|
+
|
6
|
+

|
7
|
+
|
8
|
+
[](https://rubydoc.info/gems/simple-annotations)
|
9
|
+

|
10
|
+

|
11
|
+

|
12
|
+

|
13
|
+
|
14
|
+

|
15
|
+
[](https://badge.fury.io/rb/simple-annotations)
|
16
|
+

|
17
|
+

|
18
|
+

|
19
|
+
|
20
|
+
|
21
|
+
<noscript><a href="https://liberapay.com/ruydiaz/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></noscript>
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Install it yourself as:
|
26
|
+
|
27
|
+
$ gem install carioca
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
## Adding annotations to a class
|
35
|
+
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
require 'rubygems'
|
39
|
+
require 'simple-annotations'
|
40
|
+
|
41
|
+
class A
|
42
|
+
using AnnotationRefinement
|
43
|
+
|
44
|
+
annotate!
|
45
|
+
|
46
|
+
§test 'string'
|
47
|
+
def method
|
48
|
+
return annotations(__callee__)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
anA = A.new
|
54
|
+
pp anA.method
|
55
|
+
|
56
|
+
```
|
57
|
+
|
58
|
+
Display
|
59
|
+
|
60
|
+
```
|
61
|
+
{:test=>"string"}
|
62
|
+
```
|
63
|
+
|
64
|
+
|
65
|
+
### Getting fields
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
require 'rubygems'
|
69
|
+
require 'simple-annotations'
|
70
|
+
|
71
|
+
class A
|
72
|
+
using AnnotationRefinement
|
73
|
+
annotate!
|
74
|
+
|
75
|
+
§foobar {:color => 'cyan' } # Hash
|
76
|
+
§test 1234 # Numeric
|
77
|
+
§foobar color: 'cyan' # Hash by double splat, like keyword
|
78
|
+
§testbar 10, {}, [], 'string' # Hybrid by splat
|
79
|
+
§barfoo # Boolean set true
|
80
|
+
§footest 'string' # String
|
81
|
+
def method
|
82
|
+
[...]
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
pp A.annotations[:method]
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
Display
|
92
|
+
|
93
|
+
```
|
94
|
+
{:test=>1234, :foobar=>{:color=>"cyan"}, :testbar=>[10, {}, [], "string"], :barfoo=>true, :footest=>"string"}
|
95
|
+
```
|
96
|
+
|
97
|
+
### Defining Hooks
|
98
|
+
|
99
|
+
Supporting 2 Hooks :
|
100
|
+
|
101
|
+
- §after
|
102
|
+
- §before
|
103
|
+
|
104
|
+
Like :
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
require 'rubygems'
|
108
|
+
require 'simple-annotations'
|
109
|
+
|
110
|
+
class A
|
111
|
+
using AnnotationRefinement
|
112
|
+
|
113
|
+
annotate!
|
114
|
+
|
115
|
+
|
116
|
+
§after -> { puts 'after' }
|
117
|
+
§before -> { puts 'before' }
|
118
|
+
def m1
|
119
|
+
puts 'test'
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
anA = A.new
|
128
|
+
anA.m1
|
129
|
+
```
|
130
|
+
|
131
|
+
Display
|
132
|
+
|
133
|
+
```
|
134
|
+
before
|
135
|
+
test
|
136
|
+
after
|
137
|
+
```
|
data/Rakefile
CHANGED
@@ -1,58 +1,61 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'rake'
|
5
|
-
require "rake/clean"
|
6
|
-
require "rubygems/package_task"
|
3
|
+
require 'bundler/gem_tasks'
|
7
4
|
require 'rspec/core/rake_task'
|
8
|
-
require '
|
9
|
-
require 'yard/rake/yardoc_task.rb'
|
10
|
-
require "rake/tasklib"
|
11
|
-
require "roodi"
|
12
|
-
require "roodi_task"
|
13
|
-
|
14
|
-
require "bundler/gem_tasks"
|
15
|
-
|
16
|
-
|
17
|
-
RoodiTask.new() do | t |
|
18
|
-
t.patterns = %w(lib/**/*.rb)
|
19
|
-
t.config = "coding_convention.yml"
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
CLEAN.include('*.tmp','*.old')
|
24
|
-
CLOBBER.include('*.tmp', 'build/*','#*#')
|
5
|
+
require 'rubocop//rake_task'
|
25
6
|
|
7
|
+
require 'yard'
|
8
|
+
require 'yard/rake/yardoc_task'
|
26
9
|
|
27
|
-
|
28
|
-
spec = eval(content)
|
10
|
+
require 'code_statistics'
|
29
11
|
|
30
|
-
|
12
|
+
RuboCop::RakeTask.new
|
13
|
+
RSpec::Core::RakeTask.new(:spec)
|
31
14
|
|
15
|
+
task default: :spec
|
32
16
|
|
17
|
+
require 'version'
|
18
|
+
require 'rake/version_task'
|
19
|
+
Rake::VersionTask.new
|
33
20
|
|
34
21
|
YARD::Rake::YardocTask.new do |t|
|
35
|
-
t.files
|
36
|
-
t.options += ['
|
37
|
-
t.options += ['-o', "yardoc"]
|
38
|
-
t.options += ['-r', "doc/manual.rdoc"]
|
22
|
+
t.files = ['lib/**/*.rb', '-', 'doc/**/*', 'spec/**/*_spec.rb']
|
23
|
+
t.options += ['-o', 'yardoc']
|
39
24
|
end
|
40
|
-
YARD::Config.load_plugin('yard-rspec')
|
25
|
+
YARD::Config.load_plugin('yard-rspec')
|
41
26
|
|
42
27
|
namespace :yardoc do
|
43
28
|
task :clobber do
|
44
|
-
|
45
|
-
|
29
|
+
begin
|
30
|
+
rm_r 'yardoc'
|
31
|
+
rescue StandardError
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
begin
|
35
|
+
rm_r '.yardoc'
|
36
|
+
rescue StandardError
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
begin
|
40
|
+
rm_r 'pkg'
|
41
|
+
rescue StandardError
|
42
|
+
nil
|
43
|
+
end
|
46
44
|
end
|
47
45
|
end
|
48
|
-
task :
|
49
|
-
|
46
|
+
task clobber: 'yardoc:clobber'
|
50
47
|
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
desc 'Run CVE security audit over bundle'
|
49
|
+
task :audit do
|
50
|
+
system('bundle audit')
|
54
51
|
end
|
55
52
|
|
53
|
+
desc 'Run dead line of code detection'
|
54
|
+
task :debride do
|
55
|
+
system('debride -w .debride_whitelist .')
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
task :
|
58
|
+
desc 'Run SBOM CycloneDX Xml format file'
|
59
|
+
task :sbom do
|
60
|
+
system('cyclonedx-ruby -p .')
|
61
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|