auto_autoloader 0.0.0

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
+ SHA1:
3
+ metadata.gz: 91459201994a488dd2ca0206e645c831841c260e
4
+ data.tar.gz: 8b1005753de40f38d028df479000ca2aa36da303
5
+ SHA512:
6
+ metadata.gz: 2310dac883ecea107d9ae20357a49f3b9bac171acd9cd0bc156a42fdc62304977ecd6c9cdecd533c39e75d31a3a6f3061d7da35434a026d0cfde32bca78810f8
7
+ data.tar.gz: 645f2cbaea057d4127ceb0db16d6543aca4e6b98055b81929ceab12215bf59240db2767b117f5ce894df79849deaf0d702d69fa91004ab4cfaf0e2c337e3594a
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,59 @@
1
+ AllCops:
2
+ Exclude:
3
+ - db/schema.rb
4
+ - spec/dummy/db/schema.rb
5
+ - auto_autoloader.gemspec
6
+
7
+ # https://github.com/AtomLinter/linter-rubocop/issues/2
8
+ Style/FileName:
9
+ Enabled: false
10
+
11
+ Metrics/LineLength:
12
+ Max: 160
13
+
14
+ Metrics/MethodLength:
15
+ Max: 50
16
+
17
+ Metrics/AbcSize:
18
+ Max: 25
19
+
20
+ Metrics/ClassLength:
21
+ Max: 250
22
+
23
+ Style/AccessModifierIndentation:
24
+ EnforcedStyle: outdent
25
+
26
+ Style/ClassAndModuleChildren:
27
+ EnforcedStyle: compact
28
+
29
+ Style/Documentation:
30
+ Enabled: false
31
+
32
+ Style/EmptyLines:
33
+ Enabled: false
34
+
35
+ StringLiterals:
36
+ EnforcedStyle: double_quotes
37
+
38
+ StringLiteralsInInterpolation:
39
+ Enabled: false
40
+
41
+ Style/NilComparison:
42
+ Enabled: false
43
+
44
+ Style/SignalException:
45
+ EnforcedStyle: only_raise
46
+
47
+ Style/MultilineOperationIndentation:
48
+ EnforcedStyle: indented
49
+
50
+ Style/SpaceInsideHashLiteralBraces:
51
+ EnforcedStyle: no_space
52
+
53
+ Style/TrivialAccessors:
54
+ ExactNameMatch: true
55
+ Enabled: true
56
+
57
+ # Disabled on purpose: https://github.com/bbatsov/rubocop/issues/1758
58
+ Style/ClosingParenthesisIndentation:
59
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "string-cases"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "rspec", "~> 3.4.0"
12
+ gem "rdoc", "~> 3.12"
13
+ gem "bundler", "~> 1.0"
14
+ gem "jeweler", "~> 2.0.1"
15
+ gem "simplecov", ">= 0"
16
+ gem "rubocop"
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,99 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.4.0)
5
+ ast (2.2.0)
6
+ astrolabe (1.3.1)
7
+ parser (~> 2.2)
8
+ builder (3.2.2)
9
+ descendants_tracker (0.0.4)
10
+ thread_safe (~> 0.3, >= 0.3.1)
11
+ diff-lcs (1.2.5)
12
+ docile (1.1.5)
13
+ faraday (0.9.2)
14
+ multipart-post (>= 1.2, < 3)
15
+ git (1.2.9.1)
16
+ github_api (0.13.1)
17
+ addressable (~> 2.4.0)
18
+ descendants_tracker (~> 0.0.4)
19
+ faraday (~> 0.8, < 0.10)
20
+ hashie (>= 3.4)
21
+ multi_json (>= 1.7.5, < 2.0)
22
+ oauth2
23
+ hashie (3.4.3)
24
+ highline (1.7.8)
25
+ jeweler (2.0.1)
26
+ builder
27
+ bundler (>= 1.0)
28
+ git (>= 1.2.5)
29
+ github_api
30
+ highline (>= 1.6.15)
31
+ nokogiri (>= 1.5.10)
32
+ rake
33
+ rdoc
34
+ json (1.8.3)
35
+ jwt (1.5.2)
36
+ mini_portile2 (2.0.0)
37
+ multi_json (1.11.2)
38
+ multi_xml (0.5.5)
39
+ multipart-post (2.0.0)
40
+ nokogiri (1.6.7.1)
41
+ mini_portile2 (~> 2.0.0.rc2)
42
+ oauth2 (1.0.0)
43
+ faraday (>= 0.8, < 0.10)
44
+ jwt (~> 1.0)
45
+ multi_json (~> 1.3)
46
+ multi_xml (~> 0.5)
47
+ rack (~> 1.2)
48
+ parser (2.2.3.0)
49
+ ast (>= 1.1, < 3.0)
50
+ powerpack (0.1.1)
51
+ rack (1.6.4)
52
+ rainbow (2.0.0)
53
+ rake (10.4.2)
54
+ rdoc (3.12.2)
55
+ json (~> 1.4)
56
+ rspec (3.4.0)
57
+ rspec-core (~> 3.4.0)
58
+ rspec-expectations (~> 3.4.0)
59
+ rspec-mocks (~> 3.4.0)
60
+ rspec-core (3.4.1)
61
+ rspec-support (~> 3.4.0)
62
+ rspec-expectations (3.4.0)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.4.0)
65
+ rspec-mocks (3.4.0)
66
+ diff-lcs (>= 1.2.0, < 2.0)
67
+ rspec-support (~> 3.4.0)
68
+ rspec-support (3.4.1)
69
+ rubocop (0.35.1)
70
+ astrolabe (~> 1.3)
71
+ parser (>= 2.2.3.0, < 3.0)
72
+ powerpack (~> 0.1)
73
+ rainbow (>= 1.99.1, < 3.0)
74
+ ruby-progressbar (~> 1.7)
75
+ tins (<= 1.6.0)
76
+ ruby-progressbar (1.7.5)
77
+ simplecov (0.11.1)
78
+ docile (~> 1.1.0)
79
+ json (~> 1.8)
80
+ simplecov-html (~> 0.10.0)
81
+ simplecov-html (0.10.0)
82
+ string-cases (0.0.1)
83
+ thread_safe (0.3.5)
84
+ tins (1.6.0)
85
+
86
+ PLATFORMS
87
+ ruby
88
+
89
+ DEPENDENCIES
90
+ bundler (~> 1.0)
91
+ jeweler (~> 2.0.1)
92
+ rdoc (~> 3.12)
93
+ rspec (~> 3.4.0)
94
+ rubocop
95
+ simplecov
96
+ string-cases
97
+
98
+ BUNDLED WITH
99
+ 1.10.6
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 kaspernj
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = auto_autoloader
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to auto_autoloader
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2016 kaspernj. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require "rake"
13
+
14
+ require "jeweler"
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "auto_autoloader"
18
+ gem.homepage = "http://github.com/kaspernj/auto_autoloader"
19
+ gem.license = "MIT"
20
+ gem.summary = %(Autoload constants in natural subfolders from the original class in Ruby with a single line of code.)
21
+ gem.description = %(Autoload constants in natural subfolders from the original class in Ruby with a single line of code.)
22
+ gem.email = "k@spernj.org"
23
+ gem.authors = ["kaspernj"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require "rspec/core"
29
+ require "rspec/core/rake_task"
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList["spec/**/*_spec.rb"]
32
+ end
33
+
34
+ desc "Code coverage detail"
35
+ task :simplecov do
36
+ ENV["COVERAGE"] = "true"
37
+ Rake::Task["spec"].execute
38
+ end
39
+
40
+ task default: :spec
41
+
42
+ require "rdoc/task"
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?("VERSION") ? File.read("VERSION") : ""
45
+
46
+ rdoc.rdoc_dir = "rdoc"
47
+ rdoc.title = "auto_autoloader #{version}"
48
+ rdoc.rdoc_files.include("README*")
49
+ rdoc.rdoc_files.include("lib/**/*.rb")
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,73 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: auto_autoloader 0.0.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "auto_autoloader"
9
+ s.version = "0.0.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["kaspernj"]
14
+ s.date = "2016-01-03"
15
+ s.description = "Autoload constants in natural subfolders from the original class in Ruby with a single line of code."
16
+ s.email = "k@spernj.org"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ ".rubocop.yml",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE.txt",
28
+ "README.rdoc",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "auto_autoloader.gemspec",
32
+ "lib/auto_autoloader.rb",
33
+ "spec/auto_autoloader_spec.rb",
34
+ "spec/spec_helper.rb",
35
+ "spec/test_class.rb",
36
+ "spec/test_class/sub_class.rb"
37
+ ]
38
+ s.homepage = "http://github.com/kaspernj/auto_autoloader"
39
+ s.licenses = ["MIT"]
40
+ s.rubygems_version = "2.2.2"
41
+ s.summary = "Autoload constants in natural subfolders from the original class in Ruby with a single line of code."
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 4
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<string-cases>, [">= 0"])
48
+ s.add_development_dependency(%q<rspec>, ["~> 3.4.0"])
49
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
50
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
51
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
52
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
53
+ s.add_development_dependency(%q<rubocop>, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<string-cases>, [">= 0"])
56
+ s.add_dependency(%q<rspec>, ["~> 3.4.0"])
57
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
58
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
59
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
60
+ s.add_dependency(%q<simplecov>, [">= 0"])
61
+ s.add_dependency(%q<rubocop>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<string-cases>, [">= 0"])
65
+ s.add_dependency(%q<rspec>, ["~> 3.4.0"])
66
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
67
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
68
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
69
+ s.add_dependency(%q<simplecov>, [">= 0"])
70
+ s.add_dependency(%q<rubocop>, [">= 0"])
71
+ end
72
+ end
73
+
@@ -0,0 +1,32 @@
1
+ class AutoAutoloader
2
+ def self.autoload_sub_classes(base, path)
3
+ base.extend AutoAutoloader::ClassMethods
4
+
5
+ base.class_eval do
6
+ @autoload_path = path
7
+ end
8
+ end
9
+
10
+ module ClassMethods
11
+ def const_missing(const_name)
12
+ require "string-cases"
13
+
14
+ last_name = const_name.to_s.split("::").last
15
+ last_class_name = name.to_s.split("::").last
16
+
17
+ path = "#{@autoload_path}/#{::StringCases.camel_to_snake(last_class_name)}/#{::StringCases.camel_to_snake(last_name)}.rb"
18
+
19
+ if File.exist?(path)
20
+ require path
21
+
22
+ if const_defined?(last_name)
23
+ return const_get(last_name)
24
+ else
25
+ raise LoadError, "Expected path to define #{const_name} but it didnt: #{path}"
26
+ end
27
+ end
28
+
29
+ super
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+
3
+ describe AutoAutoloader do
4
+ it "works" do
5
+ require_relative "test_class"
6
+ expect(TestClass::SubClass.call_to_sub_class).to eq "test"
7
+ end
8
+ end
@@ -0,0 +1,28 @@
1
+ require "simplecov"
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter "test_frameworks"
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
18
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
19
+
20
+ require "rspec"
21
+ require "auto_autoloader"
22
+
23
+ # Requires supporting files with custom matchers and macros, etc,
24
+ # in ./support/ and its subdirectories.
25
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
26
+
27
+ RSpec.configure do |config|
28
+ end
@@ -0,0 +1,3 @@
1
+ class TestClass
2
+ AutoAutoloader.autoload_sub_classes(self, __dir__)
3
+ end
@@ -0,0 +1,5 @@
1
+ class TestClass::SubClass
2
+ def self.call_to_sub_class
3
+ "test"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: auto_autoloader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - kaspernj
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: string-cases
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.4.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.4.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.0.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Autoload constants in natural subfolders from the original class in Ruby
112
+ with a single line of code.
113
+ email: k@spernj.org
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files:
117
+ - LICENSE.txt
118
+ - README.rdoc
119
+ files:
120
+ - ".document"
121
+ - ".rspec"
122
+ - ".rubocop.yml"
123
+ - Gemfile
124
+ - Gemfile.lock
125
+ - LICENSE.txt
126
+ - README.rdoc
127
+ - Rakefile
128
+ - VERSION
129
+ - auto_autoloader.gemspec
130
+ - lib/auto_autoloader.rb
131
+ - spec/auto_autoloader_spec.rb
132
+ - spec/spec_helper.rb
133
+ - spec/test_class.rb
134
+ - spec/test_class/sub_class.rb
135
+ homepage: http://github.com/kaspernj/auto_autoloader
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.2.2
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Autoload constants in natural subfolders from the original class in Ruby
159
+ with a single line of code.
160
+ test_files: []