loose_erbs 0.0.1

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: a199c48574375f7ba4180d6b80b2f5bac67ed8a9a7c77f12c57d5a2fb7f1d53a
4
+ data.tar.gz: cd693a62b42d1f2eec23ce25bec589b03586da8ae646d9d0a5a478a02e540e36
5
+ SHA512:
6
+ metadata.gz: 5678e042d65edac1b9868f7d2438860973f3830d6766f943e81e234af9dfcaf1065f9f0034be43221de7e72a3dc9037130cdac84a5c43406da91334cad52d71e
7
+ data.tar.gz: b96dda47a01a131505b6585fbc87f43cab4e93df845d096ee61983577f17b71919717ea3f3a0713f76bc994165bd9624c38797e1389f56d778d34e9a90092509
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Hartley McGuire
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,35 @@
1
+ # LooseErbs
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/loose_erbs`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/loose_erbs.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ task default: :test
data/exe/loose_erbs ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "loose_erbs"
4
+
5
+ LooseErbs::Cli.new.run
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LooseErbs
4
+ VERSION = "0.0.1"
5
+ end
data/lib/loose_erbs.rb ADDED
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "action_view"
4
+ require "action_view/dependency_tracker"
5
+
6
+ require_relative "loose_erbs/version"
7
+
8
+ module LooseErbs
9
+ singleton_class.attr_accessor :parser_class
10
+
11
+ self.parser_class = if defined?(ActionView::DependencyTracker::RubyTracker)
12
+ ActionView::DependencyTracker::RubyTracker
13
+ else
14
+ ActionView::DependencyTracker::RipperTracker
15
+ end
16
+
17
+ class Template
18
+ class << self
19
+ def from(path)
20
+ new(path, File.read(path))
21
+ end
22
+ end
23
+
24
+ attr_reader :path, :source
25
+
26
+ def initialize(path, source)
27
+ @path = path
28
+ @source = source
29
+ end
30
+
31
+ def dependencies
32
+ LooseErbs.parser_class.call(path, self)
33
+ end
34
+
35
+ def handler
36
+ ActionView::Template::Handlers::ERB
37
+ end
38
+
39
+ def type
40
+ ["text/html"]
41
+ end
42
+
43
+ def inspect
44
+ path
45
+ end
46
+ end
47
+
48
+ class Registry
49
+ def initialize
50
+ @map = {}
51
+ end
52
+
53
+ def print
54
+ @map.values.each do |template|
55
+ puts template.inspect
56
+
57
+ template.dependencies.each do |dependency|
58
+ puts "└── #{dependency}"
59
+ end
60
+ end
61
+ end
62
+
63
+ def register(path)
64
+ @map[path] = Template.from(path)
65
+ end
66
+ end
67
+
68
+ class Cli
69
+ def run
70
+ registry = Registry.new
71
+
72
+ views.each { registry.register(_1) }
73
+
74
+ registry.print
75
+ end
76
+
77
+ private
78
+
79
+ def views
80
+ Dir["#{Dir.pwd}/app/views/**/*.html.erb"]
81
+ end
82
+ end
83
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: loose_erbs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hartley McGuire
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-01-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionview
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '7.0'
27
+ description:
28
+ email:
29
+ - skipkayhil@gmail.com
30
+ executables:
31
+ - loose_erbs
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE.txt
36
+ - README.md
37
+ - Rakefile
38
+ - exe/loose_erbs
39
+ - lib/loose_erbs.rb
40
+ - lib/loose_erbs/version.rb
41
+ homepage: https://github.com/skipkayhil/loose_erbs
42
+ licenses:
43
+ - MIT
44
+ metadata:
45
+ homepage_uri: https://github.com/skipkayhil/loose_erbs
46
+ source_code_uri: https://github.com/skipkayhil/loose_erbs
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 2.7.0
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubygems_version: 3.5.3
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: A tool to help find Loose ERBs in your app!
66
+ test_files: []