trains 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -3
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.md +28 -8
- data/Rakefile +8 -0
- data/lib/trains/version.rb +3 -0
- data/lib/trains/visitor/migration.rb +3 -1
- data/lib/trains.rb +0 -1
- data/trains.gemspec +39 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5967b89c0edf52539f69630d235c4e32b0a14a34e2739f593ca666e6ea451e02
|
4
|
+
data.tar.gz: 95ef423ff42e64a346931ce84d1becd8d810fcb92b52e51bf9f628d84821e273
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32e6e039363c647c6175a770636d4082edc081f525d8dba56628d47e1cf55e56218ca0b6b39969b9cf64b50e6216fcdcc5dc589d0abfeeffc01f224afc9b3aaa
|
7
|
+
data.tar.gz: 5de86fe0d626f302865a2b9b6b8d4c41ea6fbf9ff20ddc7057ef06a71cca1324af3c226a016339eb78d8bc8da5c7c7a914d5e7828d8ca6b0965daf3537db8e15
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
-
|
5
|
+
## [0.0.2] - 2023-02-19
|
6
|
+
|
7
|
+
- Add `bin/setup` and `bin/console` for development convenience
|
8
|
+
|
9
|
+
## [0.0.1] - 2023-02-19
|
10
|
+
|
11
|
+
- Add AST visitors for controllers and models
|
12
|
+
- Controller visitor returns `DTO::Controller`
|
13
|
+
- Migration visitor returns `DTO::Model`
|
14
|
+
- `Scanner` class is the main interface of the gem
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -17,6 +17,7 @@ GEM
|
|
17
17
|
parser (3.1.1.0)
|
18
18
|
ast (~> 2.4.1)
|
19
19
|
prettier_print (1.2.0)
|
20
|
+
rake (13.0.6)
|
20
21
|
rspec (3.12.0)
|
21
22
|
rspec-core (~> 3.12.0)
|
22
23
|
rspec-expectations (~> 3.12.0)
|
@@ -49,6 +50,7 @@ PLATFORMS
|
|
49
50
|
DEPENDENCIES
|
50
51
|
activesupport (~> 7.0)
|
51
52
|
parallel (~> 1.22)
|
53
|
+
rake (~> 13.0)
|
52
54
|
rspec (~> 3.12)
|
53
55
|
rubocop-ast
|
54
56
|
ruby-lsp (~> 0.3.7)
|
data/README.md
CHANGED
@@ -2,6 +2,21 @@
|
|
2
2
|
|
3
3
|
A gem that statically analyses your Rails app and extracts information about its structure.
|
4
4
|
|
5
|
+
[![DeepSource](https://deepsource.io/gh/faraazahmad/trains.svg/?label=active+issues&show_trend=true&token=RKfXNZL_RQe6j2NEhXv2iOeh)](https://deepsource.io/gh/faraazahmad/trains/?ref=repository-badge)
|
6
|
+
[![DeepSource](https://deepsource.io/gh/faraazahmad/trains.svg/?label=resolved+issues&show_trend=true&token=RKfXNZL_RQe6j2NEhXv2iOeh)](https://deepsource.io/gh/faraazahmad/trains/?ref=repository-badge)
|
7
|
+
|
8
|
+
## Index
|
9
|
+
|
10
|
+
1. [Installation](#installation)
|
11
|
+
2. [Usage](#usage)
|
12
|
+
3. [Features](#features)
|
13
|
+
3.1 [Create Model definitions from migrations](#create-model-definitions-from-migrations)
|
14
|
+
3.2 [Create controller definitions from files](#create-controller-definitions-from-files)
|
15
|
+
4. [Development](#development)
|
16
|
+
5. [Contributing](#contributing)
|
17
|
+
6. [License](#license)
|
18
|
+
7. [Code of conduct](#code-of-conduct)
|
19
|
+
|
5
20
|
## Installation
|
6
21
|
|
7
22
|
Install the gem and add it to the application's Gemfile by executing:
|
@@ -48,10 +63,10 @@ Trains will generate the following Model definition:
|
|
48
63
|
Trains::DTO::Model(
|
49
64
|
name: 'Group',
|
50
65
|
fields:
|
51
|
-
|
52
|
-
Trains::DTO::Field(:
|
53
|
-
Trains::DTO::Field(:
|
54
|
-
Trains::DTO::Field(:
|
66
|
+
[
|
67
|
+
Trains::DTO::Field(:title, :string),
|
68
|
+
Trains::DTO::Field(:created_at, :datetime),
|
69
|
+
Trains::DTO::Field(:updated_at, :datetime),
|
55
70
|
],
|
56
71
|
version: 7.0
|
57
72
|
)
|
@@ -77,8 +92,13 @@ Trains will return the following controller definition:
|
|
77
92
|
|
78
93
|
```ruby
|
79
94
|
Trains::DTO::Controller(
|
80
|
-
|
81
|
-
|
95
|
+
name: 'BoxController',
|
96
|
+
method_list: [
|
97
|
+
Trains::DTO::Method(name: 'create', visibility: nil, source: nil),
|
98
|
+
Trains::DTO::Method(name: 'edit', visibility: nil, source: nil),
|
99
|
+
Trains::DTO::Method(name: 'update', visibility: nil, source: nil),
|
100
|
+
Trains::DTO::Method(name: 'destroy', visibility: nil, source: nil)
|
101
|
+
]
|
82
102
|
)
|
83
103
|
```
|
84
104
|
|
@@ -90,7 +110,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
90
110
|
|
91
111
|
## Contributing
|
92
112
|
|
93
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
113
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/faraazahmad/trains. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/faraazahmad/trains/blob/master/CODE_OF_CONDUCT.md).
|
94
114
|
|
95
115
|
## License
|
96
116
|
|
@@ -98,5 +118,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
98
118
|
|
99
119
|
## Code of Conduct
|
100
120
|
|
101
|
-
Everyone interacting in the Trains project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
121
|
+
Everyone interacting in the Trains project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/faraazahmad/trains/blob/master/CODE_OF_CONDUCT.md).
|
102
122
|
|
data/Rakefile
ADDED
@@ -19,7 +19,9 @@ module Trains
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def on_class(node)
|
22
|
-
|
22
|
+
unless node.parent_class.source.include? 'ActiveRecord::Migration'
|
23
|
+
return
|
24
|
+
end
|
23
25
|
|
24
26
|
@migration_class = node.children.first.source
|
25
27
|
@migration_version = extract_version(node.parent_class.source)
|
data/lib/trains.rb
CHANGED
data/trains.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/trains/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'trains'
|
7
|
+
spec.version = Trains::VERSION
|
8
|
+
spec.authors = ['Syed Faraaz Ahmad']
|
9
|
+
spec.email = ['faraaz98@live.com']
|
10
|
+
|
11
|
+
spec.summary =
|
12
|
+
'Collect metadata about your Rails app by statically analyzing it'
|
13
|
+
spec.homepage = 'https://github.com/faraazahmad/trains'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 2.6.0'
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
19
|
+
spec.metadata['changelog_uri'] = "https://github.com/faraazahmad/trains/blob/master/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files =
|
24
|
+
Dir.chdir(__dir__) do
|
25
|
+
`git ls-files -z`.split("\x0")
|
26
|
+
.reject do |f|
|
27
|
+
(f == __FILE__) ||
|
28
|
+
f.match(
|
29
|
+
%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)}
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
spec.require_paths = ['lib']
|
34
|
+
|
35
|
+
spec.add_dependency 'activesupport', '~> 7.0'
|
36
|
+
spec.add_dependency 'parallel', '~> 1.22'
|
37
|
+
spec.add_dependency 'rubocop-ast', '~> 1.16'
|
38
|
+
spec.add_dependency 'zeitwerk', '~> 2.5'
|
39
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trains
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Syed Faraaz Ahmad
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- Gemfile.lock
|
84
84
|
- LICENSE.txt
|
85
85
|
- README.md
|
86
|
+
- Rakefile
|
86
87
|
- lib/trains.rb
|
87
88
|
- lib/trains/dto/app.rb
|
88
89
|
- lib/trains/dto/controller.rb
|
@@ -94,10 +95,12 @@ files:
|
|
94
95
|
- lib/trains/utils/logger.rb
|
95
96
|
- lib/trains/utils/rails_dir.rb
|
96
97
|
- lib/trains/utils/result.rb
|
98
|
+
- lib/trains/version.rb
|
97
99
|
- lib/trains/visitor/base.rb
|
98
100
|
- lib/trains/visitor/controller.rb
|
99
101
|
- lib/trains/visitor/helper.rb
|
100
102
|
- lib/trains/visitor/migration.rb
|
103
|
+
- trains.gemspec
|
101
104
|
homepage: https://github.com/faraazahmad/trains
|
102
105
|
licenses:
|
103
106
|
- MIT
|