ordit 0.1.3 → 0.1.4
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/CHANGELOG.md +4 -0
- data/README.md +4 -21
- data/lib/ordit/console_output.rb +4 -20
- data/lib/ordit/definitions.rb +0 -14
- data/lib/ordit/results.rb +1 -4
- data/lib/ordit/version.rb +1 -1
- data/lib/tasks/ordit.rake +0 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85359a41eabc4eca9dd38bf08749860a980e7eb3a4f31c4e1550243a141fa14a
|
4
|
+
data.tar.gz: c2fb171d7a685aa3180c00fa3aee02af58d265f53e35d7d1eca7ca66bd33a3a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8366966cf1d4fed14fe17580e926d01e0f2f2450f4499b7fd724cda766cdf774cd0edd4203a418c9f7fc6445082366604cd32284372af70324988c24a91eefe8
|
7
|
+
data.tar.gz: 1d9af5057943c712b64116749d069cd8a737ae0a0338e32e8a7e11037b1b35a5701afc40a530fe82b768c22cc77196e21557cb44b312e8a16dc1948622843ab3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -17,7 +17,7 @@ bundle install
|
|
17
17
|
|
18
18
|
## Usage
|
19
19
|
|
20
|
-
### Audit
|
20
|
+
### Audit Stimulus Controllers
|
21
21
|
|
22
22
|
Run an audit to see all defined and used controllers in your application:
|
23
23
|
|
@@ -45,26 +45,6 @@ Example output:
|
|
45
45
|
|
46
46
|
```
|
47
47
|
|
48
|
-
### Scan for Specific Controller Usage
|
49
|
-
|
50
|
-
Find all uses of a specific controller:
|
51
|
-
|
52
|
-
```bash
|
53
|
-
rails ordit:scan[toggle]
|
54
|
-
rails ordit:scan[users--name] # For namespaced controllers
|
55
|
-
```
|
56
|
-
|
57
|
-
Example output:
|
58
|
-
|
59
|
-
```
|
60
|
-
Searching for stimulus controller: 'toggle'
|
61
|
-
|
62
|
-
📁 app/views/admin/new.html.erb
|
63
|
-
📁 app/views/posts/edit.html.erb
|
64
|
-
📁 app/views/products/show.html.erb
|
65
|
-
📁 app/views/users/edit.html.erb
|
66
|
-
```
|
67
|
-
|
68
48
|
### Configuration
|
69
49
|
|
70
50
|
You can customize the paths that are scanned in an initializer (`config/initializers/ordit.rb`):
|
@@ -98,6 +78,9 @@ end
|
|
98
78
|
|
99
79
|
# Hash rocket syntax
|
100
80
|
<%= f.submit 'Save', data: { :controller => 'products' } %>
|
81
|
+
|
82
|
+
# Hash rocket string syntax
|
83
|
+
<%= f.submit 'Save', 'data' => { 'controller' => 'products' } %>
|
101
84
|
```
|
102
85
|
- Scans ERB, HTML, and HAML files
|
103
86
|
- Works with both JavaScript and TypeScript controller files
|
data/lib/ordit/console_output.rb
CHANGED
@@ -6,21 +6,18 @@ module Ordit
|
|
6
6
|
class ConsoleOutput
|
7
7
|
extend Forwardable
|
8
8
|
|
9
|
-
def self.run
|
10
|
-
new
|
9
|
+
def self.run
|
10
|
+
new.run
|
11
11
|
end
|
12
12
|
|
13
13
|
def_delegators :@results,
|
14
14
|
:files, :active_controllers, :undefined_controllers, :unused_controllers
|
15
15
|
|
16
|
-
def initialize
|
17
|
-
@
|
18
|
-
@results = Results.new(name)
|
16
|
+
def initialize
|
17
|
+
@results = Results.new
|
19
18
|
end
|
20
19
|
|
21
20
|
def run
|
22
|
-
return print_find if @name
|
23
|
-
|
24
21
|
print_audit
|
25
22
|
end
|
26
23
|
|
@@ -51,18 +48,5 @@ module Ordit
|
|
51
48
|
puts " Unused controllers: #{unused_controllers.size}"
|
52
49
|
puts " Undefined controllers: #{undefined_controllers.size}"
|
53
50
|
end
|
54
|
-
|
55
|
-
def print_find
|
56
|
-
puts "\nSearching for stimulus controller: '#{@name}'\n\n"
|
57
|
-
|
58
|
-
if files.empty?
|
59
|
-
puts "No matches found."
|
60
|
-
return
|
61
|
-
end
|
62
|
-
|
63
|
-
files.each do |file|
|
64
|
-
puts "📁 #{file}"
|
65
|
-
end
|
66
|
-
end
|
67
51
|
end
|
68
52
|
end
|
data/lib/ordit/definitions.rb
CHANGED
@@ -19,19 +19,5 @@ module Ordit
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
23
|
-
def self.find(name)
|
24
|
-
Ordit.configuration.view_paths.flat_map do |path|
|
25
|
-
results = Dir.glob(path.to_s).reject do |file|
|
26
|
-
content = File.read(file)
|
27
|
-
matches = DefinitionMatcher.run(content)
|
28
|
-
matches.empty?
|
29
|
-
end
|
30
|
-
|
31
|
-
results.flat_map do |result|
|
32
|
-
Pathname.new(result).relative_path_from(Pathname.new(Ordit.root)).to_s
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
22
|
end
|
37
23
|
end
|
data/lib/ordit/results.rb
CHANGED
data/lib/ordit/version.rb
CHANGED
data/lib/tasks/ordit.rake
CHANGED
@@ -5,16 +5,4 @@ namespace :ordit do
|
|
5
5
|
task stimulus: :environment do
|
6
6
|
Ordit::ConsoleOutput.run
|
7
7
|
end
|
8
|
-
|
9
|
-
desc "Scan files for stimulus controller usage (e.g., rake audit:scan[products])"
|
10
|
-
task :scan, [:controller] => :environment do |_, args|
|
11
|
-
controller = args[:controller]
|
12
|
-
|
13
|
-
if controller.nil? || controller.empty?
|
14
|
-
puts "Please provide a controller name: rake ordit:scan[controller_name]"
|
15
|
-
next
|
16
|
-
end
|
17
|
-
|
18
|
-
Ordit::ConsoleOutput.run(controller)
|
19
|
-
end
|
20
8
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ordit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|