trains 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5413c3e6b18ce996f955e2ad43eaddb7fc13d67ead0eab3ed79fdc09820c7fc9
4
- data.tar.gz: 1c8f46daedfc9115f35baa7ab70d8c987145e67e2f02c51906cd9a1af012c2be
3
+ metadata.gz: 5edc43c1d03aa434cb4166f79b9687574ac14a04548a8e2e8fc7f47b005573e0
4
+ data.tar.gz: ebee4c7048d82d644e4c08de0cd9a828b2f6784747558a3ec041b0feadbc043d
5
5
  SHA512:
6
- metadata.gz: 0cdd205741e22ff8cacf3f4bf590faac07cba5eb6d3dae8126da6f13cefbb65ce556734e3484f70183777c3b9dea617e3fe0c2cc953bc1b380a975ba78dbf983
7
- data.tar.gz: 31c57301eb2fa078d067f7685380ca981d2cf16c724d54fc0deed63e52836f1fbc66a3813b11756d243203133bc33c9eb33052c77329732fa5ea00df3f8d797f
6
+ metadata.gz: 7511a1b15fc8b908cee1ccacd6096d651169ee7ce5ab4eeb6b153c905b8bd949f3899fd20080b4b0f577f2c9d90260ac8e7d85940680fb7c0c74cf24386fa110
7
+ data.tar.gz: f7607d015b516c24c33e74f0473c120a25070bd146411deda8be54cbbe66e945a9ed68f56dd3122cd3c6694dae5bf3b220a836f0584f64f19aab711ba871aa54
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
- ## [Unreleased]
1
+ # Changelog
2
2
 
3
- ## [0.1.0] - 2023-02-19
3
+ All notable changes to this project will be documented in this file.
4
4
 
5
- - Initial release
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
@@ -6,6 +6,7 @@ gem 'rubocop-ast'
6
6
  gem 'zeitwerk', '~> 2.5'
7
7
 
8
8
  group :test, :development do
9
+ gem 'rake', '~> 13.0'
9
10
  gem 'rspec', '~> 3.12'
10
11
  gem 'ruby-lsp', '~> 0.3.7', require: false
11
12
  end
data/Gemfile.lock CHANGED
@@ -1,3 +1,12 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ trains (0.0.1)
5
+ activesupport (~> 7.0)
6
+ parallel (~> 1.22)
7
+ rubocop-ast (~> 1.16)
8
+ zeitwerk (~> 2.5)
9
+
1
10
  GEM
2
11
  remote: https://rubygems.org/
3
12
  specs:
@@ -17,6 +26,7 @@ GEM
17
26
  parser (3.1.1.0)
18
27
  ast (~> 2.4.1)
19
28
  prettier_print (1.2.0)
29
+ rake (13.0.6)
20
30
  rspec (3.12.0)
21
31
  rspec-core (~> 3.12.0)
22
32
  rspec-expectations (~> 3.12.0)
@@ -49,9 +59,11 @@ PLATFORMS
49
59
  DEPENDENCIES
50
60
  activesupport (~> 7.0)
51
61
  parallel (~> 1.22)
62
+ rake (~> 13.0)
52
63
  rspec (~> 3.12)
53
64
  rubocop-ast
54
65
  ruby-lsp (~> 0.3.7)
66
+ trains!
55
67
  zeitwerk (~> 2.5)
56
68
 
57
69
  BUNDLED WITH
data/README.md CHANGED
@@ -48,10 +48,10 @@ Trains will generate the following Model definition:
48
48
  Trains::DTO::Model(
49
49
  name: 'Group',
50
50
  fields:
51
- Set[
52
- Trains::DTO::Field(:datetime, :created_at),
53
- Trains::DTO::Field(:datetime, :updated_at),
54
- Trains::DTO::Field(:string, :title)
51
+ [
52
+ Trains::DTO::Field(:title, :string),
53
+ Trains::DTO::Field(:created_at, :datetime),
54
+ Trains::DTO::Field(:updated_at, :datetime),
55
55
  ],
56
56
  version: 7.0
57
57
  )
@@ -77,8 +77,13 @@ Trains will return the following controller definition:
77
77
 
78
78
  ```ruby
79
79
  Trains::DTO::Controller(
80
- name: 'BoxController',
81
- methods: Set[:create, :edit, :update, :destroy]
80
+ name: 'BoxController',
81
+ method_list: [
82
+ Trains::DTO::Method(name: 'create', visibility: nil, source: nil),
83
+ Trains::DTO::Method(name: 'edit', visibility: nil, source: nil),
84
+ Trains::DTO::Method(name: 'update', visibility: nil, source: nil),
85
+ Trains::DTO::Method(name: 'destroy', visibility: nil, source: nil)
86
+ ]
82
87
  )
83
88
  ```
84
89
 
@@ -90,7 +95,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
90
95
 
91
96
  ## Contributing
92
97
 
93
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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/[USERNAME]/trains/blob/master/CODE_OF_CONDUCT.md).
98
+ 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
99
 
95
100
  ## License
96
101
 
@@ -98,5 +103,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
98
103
 
99
104
  ## Code of Conduct
100
105
 
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/[USERNAME]/trains/blob/master/CODE_OF_CONDUCT.md).
106
+ 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
107
 
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,3 @@
1
+ module Trains
2
+ VERSION = '0.0.2'
3
+ end
@@ -19,7 +19,9 @@ module Trains
19
19
  end
20
20
 
21
21
  def on_class(node)
22
- return unless node.parent_class.source.include? 'ActiveRecord::Migration'
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
@@ -1,6 +1,5 @@
1
1
  require 'yaml'
2
2
  require 'rubocop-ast'
3
- require 'fast_ignore'
4
3
  require 'zeitwerk'
5
4
  require 'active_support/core_ext/string/inflections'
6
5
  require 'parallel'
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.1
4
+ version: 0.0.2
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,6 +95,7 @@ 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