autorequire_rails 1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c4c7834e6fa2af64dcafc6f3ad709a86212b73c094e6f05b3ad44b6c05d448de
4
+ data.tar.gz: 1c3b731ad8bad5eb2023f74049b32556c4037c343a3d4225aca66432ef902407
5
+ SHA512:
6
+ metadata.gz: cf30992f767bd170fe037c0920d23c2ac4213a77942483d1914abcb81a081db8e2e1230778d1cff0fd95aeff8a7f970039e8277fb927f6c2cd316314a4317032
7
+ data.tar.gz: e5f3e57e6ed1fd04ac797b183c73d8692f086ecb33acd40768bd35d306046647e16bedad796178f220825e9b46485e3cfc0e2e8807ef2c812712ec5ddf68f9f1
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ /spec/dummy/db/*.sqlite3
12
+ /spec/dummy/db/*.sqlite3-journal
13
+ /spec/dummy/log/*.log
14
+ /spec/dummy/tmp/
15
+ /spec/dummy/.sass-cache
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format progress
2
+ --color
3
+ --require rails_helper
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ Exclude:
3
+ - spec/dummy/db/schema.rb
4
+
5
+ Style/StringLiterals:
6
+ Enabled: false
7
+
8
+ Metrics/LineLength:
9
+ Max: 130
10
+
11
+ Style/StderrPuts:
12
+ Exclude:
13
+ - spec/dummy/bin/yarn
14
+
15
+ Style/MixinUsage:
16
+ Exclude:
17
+ - spec/dummy/bin/setup
18
+ - spec/dummy/bin/update
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.4.3
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,14 @@
1
+ # CHANGELOG
2
+
3
+ ## 1.0.2 (Jan 08, 2018)
4
+
5
+ 1. Publish a new version to replace the two earlier versions that were yanked from Rubygems.
6
+
7
+ ## 1.0.1 (Jan 08, 2018)
8
+
9
+ 1. Polish the gem and add automated tests. (Issue #3)
10
+ 1. Reduce rubocop violations to 0. (Issue #6)
11
+
12
+ ## 1.0.0 (Jan 07, 2018)
13
+
14
+ 1. Autorequire all files in `lib/autorequire` via an initializer. (Issue #1)
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in autorequire_rails.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'bootsnap', require: false
8
+ gem 'puma', '~> 3.7'
9
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Robert Soly
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.
@@ -0,0 +1,51 @@
1
+ # autorequire_rails
2
+
3
+ autorequire_rails is a Rails engine that automatically requires all ruby files in `lib/autorequire` when a Rails app boots.
4
+
5
+ Why is this useful? Rails has multiple strategies for loading code and there are some scenarios that can cause Rails to ignore files in `lib`. One example where this frequently arises is when trying to monkey patch a core ruby class. Many people create a file like `lib/string.rb` and expect Rails to autoload or eagerload it. However, out of the box, Rails isn't configured to reach into `lib` so the code won't get loaded . On top of that, even if Rails were configured to look in `lib`, it still wouldn't work. Constants, like the `String` constant, are always defined so Rails never thinks it needs to go looking for additional files to load.
6
+
7
+ To solve these kinds of problems, you typically have to explicitly require files on your own. autorequire_rails saves you the trouble and establishes a pattern.
8
+
9
+ ## Versioning Scheme
10
+
11
+ This gem uses [semver](http:/semver.org).
12
+
13
+ ## Supported Rails Versions
14
+
15
+ Rails 4+.
16
+
17
+ ## Installation
18
+
19
+ Add this line to your Rails application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'autorequire_rails'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ ## Usage
30
+
31
+ Add any file with a .rb extension to the `lib/autorequire` folder (or a sub folder). Rails will automatically load it during the boot process.
32
+
33
+ ## Recommendations
34
+
35
+ #### Recommended Folder Stricture
36
+
37
+ You can use any folder structure you like, but we recommend putting extensions to ruby core classes in `lib/autorequire/core_ext` and extensions to gems in a folder like `lib/autorequire/gem_ext/<gem name here>`.
38
+
39
+ #### What to Put in lib/autorequire
40
+
41
+ Ultimately, `lib/autorequire` is useful for adding code **to constants that are already defined**. As a result, it's ideal for changes to 3rd party libraries and ruby core classes/modules. It can also be great place to hold reusable code that can be shared between applications.
42
+
43
+ If you're defining **application specific** custom classes and modules, consider using a sub folder inside `app`. If you're defining a new constant (and the file name follow proper Rails naming rules), Rails will happily discover it when needed. `app/lib` is a sensible place to hold these kind of classes and modules.
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/corlewsolutions/format_restricter_rails.
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
8
+ load 'rails/tasks/engine.rake'
9
+ load 'rails/tasks/statistics.rake'
10
+ Bundler::GemHelper.install_tasks
11
+
12
+ require "rspec/core/rake_task"
13
+
14
+ RSpec::Core::RakeTask.new(:spec)
15
+
16
+ task default: :spec
17
+
18
+ task :console do
19
+ exec "pry -r autorequire_rails -I ./lib"
20
+ # exec "irb -r autorequire_rails -I ./lib"
21
+ end
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'autorequire_rails/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "autorequire_rails"
7
+ spec.version = AutorequireRails::VERSION
8
+ spec.authors = ["roberts1000"]
9
+ spec.email = ["roberts@corlewsolutions.com"]
10
+
11
+ spec.summary = "A Rails engine that requires all ruby files in lib/autorequire when a Rails app boots."
12
+ spec.description = "A Rails engine that requires all ruby files in lib/autorequire when a Rails app boots."
13
+ spec.homepage = "https://github.com/corlewsolutions/autorequire_rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.16"
22
+ spec.add_development_dependency "pry", "~> 0.11.3"
23
+ spec.add_development_dependency "rake", "~> 12.0"
24
+ spec.add_development_dependency "rspec-rails", "~> 3.7.2"
25
+ spec.add_development_dependency "sass-rails", "~> 5.0"
26
+ spec.add_development_dependency "sqlite3", "~> 1.3.11"
27
+
28
+ spec.add_dependency "rails", ">= 4"
29
+ end
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "autorequire_rails"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
11
+
12
+ # require "irb"
13
+ # IRB.start
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This command will automatically be run when you run "rails" with Rails gems
4
+ # installed from the root of your application.
5
+
6
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
7
+ ENGINE_PATH = File.expand_path('../../lib/autorequire_rails/engine', __FILE__)
8
+ APP_PATH = File.expand_path('../../spec/dummy/config/application', __FILE__)
9
+
10
+ # Set up gems listed in the Gemfile.
11
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
12
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
13
+
14
+ require 'rails/all'
15
+ require 'rails/engine/commands'
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ # Automatically require all .rb files in the lib/autorequire directory. This directory holds any
2
+ # files that should be loaded, but are unabled to be autoloaded by Rails (like extensions to core
3
+ # classes/modules and other monkey patches to already loaded constants).
4
+ #
5
+ # Why is this necessary? Consider the situation where you would like to add a method to the String class
6
+ # inside a lib/core_ext/string.rb file. Rails has an autoloading feature, but it only kicks-in when a
7
+ # constant is missing. Since the String constant is always present, rails will never attempt to autoload it
8
+ # and any methods defined in string.rb will never be loaded. The general solution to this problem is to
9
+ # manually require files that extend core classes inside an initializer. The autorequire pattern takes this
10
+ # a step farther by giving us a place to automatically require any .rb file.
11
+ Dir.glob(Rails.root.join('lib', 'autorequire', '**', '*.rb')).each { |f| require f }
@@ -0,0 +1,13 @@
1
+ require "rails"
2
+ require "autorequire_rails/version"
3
+ require "autorequire_rails/engine"
4
+
5
+ # Setup pry for development when running "rake console". Guard against load
6
+ # errors in production (since pry is only loaded as a DEVELOPMENT dependency
7
+ # in the .gemspec)
8
+ # rubocop:disable Lint/HandleExceptions
9
+ begin
10
+ require "pry"
11
+ rescue LoadError
12
+ end
13
+ # rubocop:enable Lint/HandleExceptions
@@ -0,0 +1,4 @@
1
+ module AutorequireRails
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module AutorequireRails
2
+ VERSION = "1.0.2".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: autorequire_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - roberts1000
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-01-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.11.3
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.11.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.7.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.7.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: sass-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.11
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.3.11
97
+ - !ruby/object:Gem::Dependency
98
+ name: rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '4'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '4'
111
+ description: A Rails engine that requires all ruby files in lib/autorequire when a
112
+ Rails app boots.
113
+ email:
114
+ - roberts@corlewsolutions.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".rubocop.yml"
122
+ - ".travis.yml"
123
+ - CHANGELOG.md
124
+ - Gemfile
125
+ - LICENSE.md
126
+ - README.md
127
+ - Rakefile
128
+ - autorequire_rails.gemspec
129
+ - bin/console
130
+ - bin/rails
131
+ - bin/setup
132
+ - config/initializers/gem_autorequire_rails.rb
133
+ - lib/autorequire_rails.rb
134
+ - lib/autorequire_rails/engine.rb
135
+ - lib/autorequire_rails/version.rb
136
+ homepage: https://github.com/corlewsolutions/autorequire_rails
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.7.4
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: A Rails engine that requires all ruby files in lib/autorequire when a Rails
160
+ app boots.
161
+ test_files: []