open_namespace 0.4.0 → 0.4.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 27c14527e862b51cac2728bd23be2d39d840cc296dd7cf62cf39428a3fbc6c60
4
+ data.tar.gz: f186567025a8c9b3d91b2d1719d9f6c814bc85d5fd152b9335c04c4a4aa8258a
5
+ SHA512:
6
+ metadata.gz: ec0f07fb897e17be72e11db13395d7568327b43509a4a78ac0a3f8358874736ccac4553c933f29bd02777bcb9d139548d912a25b823c20641ba4faf13809d791
7
+ data.tar.gz: d6328b3f3da9a744e462eaeb0e812bd01348a0c3ff0353bae32c9854869833d2920bba6806fd82af56e23b54bc7de57f5a8ab4d68436e27ffd823ff2dda38b69
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ -
2
+ ChangeLog.md
3
+ LICENSE.txt
@@ -0,0 +1,28 @@
1
+ name: CI
2
+
3
+ on: [ push, pull_request ]
4
+
5
+ jobs:
6
+ tests:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby:
12
+ - "3.0"
13
+ - "3.1"
14
+ - "3.2"
15
+ - "3.3"
16
+ - jruby
17
+ - truffleruby
18
+ name: Ruby ${{ matrix.ruby }}
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ - name: Install dependencies
26
+ run: bundle install --jobs 4 --retry 3
27
+ - name: Run tests
28
+ run: bundle exec rake test
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
- pkg
2
- doc
1
+ /Gemfile.lock
2
+ /pkg
3
+ /doc
3
4
  .DS_Store
4
5
  .yardoc
5
6
  *.swp
data/.yardopts CHANGED
@@ -1 +1 @@
1
- --markup markdown --title 'OpenNamespace Documentation' --protected --files ChangeLog.md,LICENSE.txt
1
+ --markup markdown --title 'OpenNamespace Documentation' --protected
data/ChangeLog.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 0.4.2 / 2024-01-24
2
+
3
+ * Switched to using `require_relative` to improve load-times.
4
+ * Added `# frozen_string_literal: true` to all files.
5
+
6
+ ### 0.4.1 / 2012-05-27
7
+
8
+ * Replaced ore-tasks with
9
+ [rubygems-tasks](https://github.com/postmodern/rubygems-tasks#readme).
10
+
1
11
  ### 0.4.0 / 2011-11-19
2
12
 
3
13
  * Added {OpenNamespace.const_lookup}.
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake'
7
+ gem 'rubygems-tasks', '~> 0.2'
8
+
9
+ gem 'rspec', '~> 3.0'
10
+
11
+ gem 'kramdown'
12
+ gem 'yard', '~> 0.9'
13
+ end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2011 Hal Brodigan
1
+ Copyright (c) 2010-2024 Hal Brodigan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # OpenNamespace
2
2
 
3
- * [Source](http://github.com/postmodern/open_namespace)
4
- * [Issues](http://github.com/postmodern/open_namespace/issues)
3
+ * [Source](https://github.com/postmodern/open_namespace)
4
+ * [Issues](https://github.com/postmodern/open_namespace/issues)
5
5
  * [Documentation](http://rubydoc.info/gems/open_namespace/frames)
6
- * [Email](mailto:postmodern.mod3 at gmail.com)
7
6
 
8
7
  ## Description
9
8
 
@@ -16,58 +15,76 @@ load plugin modules/classes from other gems.
16
15
  * Provides implicit loading of constants via `const_defined?`.
17
16
  * Provides implicit loading of constants via `const_missing`.
18
17
  * Provides explicit loading of constants via `require_const`.
18
+ * Can auto-load other sub-gems (ex: `foo-bar`) from the main gem's namespace
19
+ (ex: `Foo`).
19
20
 
20
21
  ## Examples
21
22
 
22
- Explicit and implicit loading of constants:
23
+ Include it into a namespace:
23
24
 
24
- require 'open_namespace'
25
+ ```ruby
26
+ require 'open_namespace'
25
27
 
26
- module Project
27
- module Plugins
28
- include OpenNamespace
29
- end
30
- end
28
+ module Project
29
+ module Plugins
30
+ include OpenNamespace
31
+ end
32
+ end
33
+ ```
34
+
35
+ Explicitly load constants via their file name:
36
+
37
+ ```ruby
38
+ Project::Plugins.require_const :foo_bar
39
+ # => Project::Plugins::FooBar
40
+ ```
31
41
 
32
- # explicitly load constants
33
- Project::Plguins.require_const :foo_bar
34
- # => Project::Plugins::FooBar
42
+ Explicitly load constants containing uppercase acronyms:
35
43
 
36
- # explicitly load constants with odd capitalization
37
- Project::Plugins.require_const :tcp_session
38
- # => Project::Plugins::TCPSession
44
+ ```ruby
45
+ Project::Plugins.require_const :tcp_session
46
+ # => Project::Plugins::TCPSession
47
+ ```
39
48
 
40
- # explicitly load constants via sub-paths
41
- Project::Plguins.require_const 'templates/erb'
42
- # => Project::Plugins::Templates::Erb
49
+ Explicitly load constants from nested directories:
43
50
 
44
- # implicitly load constants via const_missing
45
- Project::Plugins::Other
46
- # => Project::Plugins::Other
51
+ ```ruby
52
+ Project::Plugins.require_const 'templates/erb'
53
+ # => Project::Plugins::Templates::Erb
54
+ ```
55
+
56
+ Implicitly load constants via `const_missing`:
57
+
58
+ ```ruby
59
+ Project::Plugins::Other
60
+ # => Project::Plugins::Other
61
+ ```
47
62
 
48
63
  Loading constants from alternate namespace root directories:
49
64
 
50
- module Project
51
- module UI
52
- module CommandLine
53
- module Commands
54
- include OpenNamespace
65
+ ```ruby
66
+ module Project
67
+ module UI
68
+ module CommandLine
69
+ module Commands
70
+ include OpenNamespace
55
71
 
56
- self.namespace_root = File.join('project','ui','command_line','commands')
57
- end
58
- end
72
+ self.namespace_root = File.join(__dir__,'commands')
59
73
  end
60
74
  end
75
+ end
76
+ end
61
77
 
62
- Project::UI::CommandLine::Commands.require_const :help
63
- # => Project::UI::CommandLine::Commands::Help
78
+ Project::UI::CommandLine::Commands.require_const :help
79
+ # => Project::UI::CommandLine::Commands::Help
80
+ ```
64
81
 
65
82
  ## Install
66
83
 
67
- $ gem install open_namespace
84
+ ```shell
85
+ $ gem install open_namespace
86
+ ```
68
87
 
69
88
  ## License
70
89
 
71
- Copyright (c) 2010-2011 Hal Brodigan
72
-
73
90
  See {file:LICENSE.txt} for license information.
data/Rakefile CHANGED
@@ -1,36 +1,12 @@
1
1
  require 'rubygems'
2
- require 'rake'
3
2
 
4
- begin
5
- gem 'ore-tasks', '~> 0.4'
6
- require 'ore/tasks'
3
+ require 'rubygems/tasks'
4
+ Gem::Tasks.new
7
5
 
8
- Ore::Tasks.new
9
- rescue LoadError => e
10
- warn e.message
11
- warn "Run `gem install ore-tasks` to install 'ore/tasks'."
12
- end
13
-
14
- begin
15
- gem 'rspec', '~> 2.4'
16
- require 'rspec/core/rake_task'
17
-
18
- RSpec::Core::RakeTask.new
19
- rescue LoadError => e
20
- task :spec do
21
- abort "Please run `gem install rspec` to install RSpec."
22
- end
23
- end
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new
24
8
  task :test => :spec
25
9
  task :default => :spec
26
10
 
27
- begin
28
- gem 'yard', '~> 0.7'
29
- require 'yard'
30
-
31
- YARD::Rake::YardocTask.new
32
- rescue LoadError => e
33
- task :yard do
34
- abort "Please run `gem install yard` to install YARD."
35
- end
36
- end
11
+ require 'yard'
12
+ YARD::Rake::YardocTask.new
data/gemspec.yml CHANGED
@@ -7,10 +7,15 @@ description:
7
7
  license: MIT
8
8
  authors: Postmodern
9
9
  email: postmodern.mod3@gmail.com
10
- homepage: http://github.com/postmodern/open_namespace
10
+ homepage: https://github.com/postmodern/open_namespace#readme
11
11
  has_yard: true
12
12
 
13
+ metadata:
14
+ documentation_uri: https://rubydoc.info/gems/open_namespace
15
+ source_code_uri: https://github.com/postmodern/open_namespace
16
+ bug_tracker_uri: https://github.com/postmodern/open_namespace/issues
17
+ changelog_uri: https://github.com/postmodern/open_namespace/blob/main/ChangeLog.md
18
+ rubygems_mfa_required: 'true'
19
+
13
20
  development_dependencies:
14
- ore-tasks: ~> 0.4
15
- rspec: ~> 2.4
16
- yard: ~> 0.7
21
+ bundler: ~> 2.0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OpenNamespace
2
4
  module ClassMethods
3
5
  #
@@ -1,4 +1,6 @@
1
- require 'open_namespace/class_methods'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'class_methods'
2
4
 
3
5
  module OpenNamespace
4
6
  def self.included(base)
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OpenNamespace
2
4
  # open_namespace version
3
- VERSION = '0.4.0'
5
+ VERSION = '0.4.2'
4
6
  end
@@ -1,2 +1,4 @@
1
- require 'open_namespace/open_namespace'
2
- require 'open_namespace/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'open_namespace/open_namespace'
4
+ require_relative 'open_namespace/version'
@@ -2,126 +2,57 @@
2
2
 
3
3
  require 'yaml'
4
4
 
5
- Gem::Specification.new do |gemspec|
6
- files = if File.directory?('.git')
7
- `git ls-files`.split($/)
8
- elsif File.directory?('.hg')
9
- `hg manifest`.split($/)
10
- elsif File.directory?('.svn')
11
- `svn ls -R`.split($/).select { |path| File.file?(path) }
12
- else
13
- Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
14
- end
5
+ Gem::Specification.new do |gem|
6
+ gemspec = YAML.load_file('gemspec.yml')
15
7
 
16
- filter_files = lambda { |paths|
17
- case paths
18
- when Array
19
- (files & paths)
20
- when String
21
- (files & Dir[paths])
22
- end
23
- }
24
-
25
- version = {
26
- :file => 'lib/open_namespace/version.rb',
27
- :constant => 'OpenNamespace::VERSION'
28
- }
29
-
30
- defaults = {
31
- 'name' => File.basename(File.dirname(__FILE__)),
32
- 'files' => files,
33
- 'executables' => filter_files['bin/*'].map { |path| File.basename(path) },
34
- 'test_files' => filter_files['{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'],
35
- 'extra_doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}'],
36
- }
8
+ gem.name = gemspec.fetch('name')
9
+ gem.version = gemspec.fetch('version') do
10
+ require_relative 'lib/open_namespace/version'
11
+ OpenNamespace::VERSION
12
+ end
37
13
 
38
- metadata = defaults.merge(YAML.load_file('gemspec.yml'))
14
+ gem.summary = gemspec['summary']
15
+ gem.description = gemspec['description']
16
+ gem.licenses = Array(gemspec['license'])
17
+ gem.authors = Array(gemspec['authors'])
18
+ gem.email = gemspec['email']
19
+ gem.homepage = gemspec['homepage']
20
+ gem.metadata = gemspec['metadata'] if gemspec['metadata']
39
21
 
40
- gemspec.name = metadata['name']
41
- gemspec.version = if metadata['version']
42
- metadata['version']
43
- elsif File.file?(version[:file])
44
- require File.join('.',version[:file])
45
- eval(version[:constant])
46
- end
22
+ glob = lambda { |patterns| gem.files & Dir[*patterns] }
47
23
 
48
- gemspec.summary = metadata.fetch('summary',metadata['description'])
49
- gemspec.description = metadata.fetch('description',metadata['summary'])
24
+ gem.files = `git ls-files`.split($/)
25
+ gem.files = glob[gemspec['files']] if gemspec['files']
50
26
 
51
- case metadata['license']
52
- when Array
53
- gemspec.licenses = metadata['license']
54
- when String
55
- gemspec.license = metadata['license']
27
+ gem.executables = gemspec.fetch('executables') do
28
+ glob['bin/*'].map { |path| File.basename(path) }
56
29
  end
30
+ gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
57
31
 
58
- case metadata['authors']
59
- when Array
60
- gemspec.authors = metadata['authors']
61
- when String
62
- gemspec.author = metadata['authors']
63
- end
64
-
65
- gemspec.email = metadata['email']
66
- gemspec.homepage = metadata['homepage']
32
+ gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
33
+ gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
34
+ gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
67
35
 
68
- case metadata['require_paths']
69
- when Array
70
- gemspec.require_paths = metadata['require_paths']
71
- when String
72
- gemspec.require_path = metadata['require_paths']
73
- end
36
+ gem.require_paths = Array(gemspec.fetch('require_paths') {
37
+ %w[ext lib].select { |dir| File.directory?(dir) }
38
+ })
74
39
 
75
- gemspec.files = filter_files[metadata['files']]
40
+ gem.requirements = gemspec['requirements']
41
+ gem.required_ruby_version = gemspec['required_ruby_version']
42
+ gem.required_rubygems_version = gemspec['required_rubygems_version']
43
+ gem.post_install_message = gemspec['post_install_message']
76
44
 
77
- gemspec.executables = metadata['executables']
78
- gemspec.extensions = metadata['extensions']
79
-
80
- if Gem::VERSION < '1.7.'
81
- gemspec.default_executable = gemspec.executables.first
82
- end
83
-
84
- gemspec.test_files = filter_files[metadata['test_files']]
85
-
86
- unless gemspec.files.include?('.document')
87
- gemspec.extra_rdoc_files = metadata['extra_doc_files']
88
- end
89
-
90
- gemspec.post_install_message = metadata['post_install_message']
91
- gemspec.requirements = metadata['requirements']
92
-
93
- if gemspec.respond_to?(:required_ruby_version=)
94
- gemspec.required_ruby_version = metadata['required_ruby_version']
95
- end
96
-
97
- if gemspec.respond_to?(:required_rubygems_version=)
98
- gemspec.required_rubygems_version = metadata['required_rubygems_version']
99
- end
100
-
101
- parse_versions = lambda { |versions|
102
- case versions
103
- when Array
104
- versions.map { |v| v.to_s }
105
- when String
106
- versions.split(/,\s*/)
107
- end
108
- }
109
-
110
- if metadata['dependencies']
111
- metadata['dependencies'].each do |name,versions|
112
- gemspec.add_dependency(name,parse_versions[versions])
113
- end
114
- end
45
+ split = lambda { |string| string.split(/,\s*/) }
115
46
 
116
- if metadata['runtime_dependencies']
117
- metadata['runtime_dependencies'].each do |name,versions|
118
- gemspec.add_runtime_dependency(name,parse_versions[versions])
47
+ if gemspec['dependencies']
48
+ gemspec['dependencies'].each do |name,versions|
49
+ gem.add_dependency(name,split[versions])
119
50
  end
120
51
  end
121
52
 
122
- if metadata['development_dependencies']
123
- metadata['development_dependencies'].each do |name,versions|
124
- gemspec.add_development_dependency(name,parse_versions[versions])
53
+ if gemspec['development_dependencies']
54
+ gemspec['development_dependencies'].each do |name,versions|
55
+ gem.add_development_dependency(name,split[versions])
125
56
  end
126
57
  end
127
58
  end
@@ -1,160 +1,161 @@
1
- require 'open_namespace/version'
2
-
3
1
  require 'spec_helper'
2
+ require 'open_namespace'
3
+
4
4
  require 'classes/simple_namespace'
5
5
  require 'classes/custom_namespace'
6
6
 
7
7
  describe OpenNamespace do
8
8
  it "should have a VERSION constant" do
9
- OpenNamespace.const_defined?('VERSION').should == true
9
+ expect(OpenNamespace.const_defined?('VERSION')).to be(true)
10
10
  end
11
11
 
12
12
  context "default namespace" do
13
- before(:all) do
14
- @module = Classes::SimpleNamespace
15
- end
13
+ subject { Classes::SimpleNamespace }
16
14
 
17
15
  it "should have the same namespace root as the module's directory" do
18
- @module.namespace_root.should == File.join('classes','simple_namespace')
16
+ expect(subject.namespace_root).to eq(
17
+ File.join('classes','simple_namespace')
18
+ )
19
19
  end
20
20
 
21
21
  it "should load constants into the namespace" do
22
- @module.require_const :constant_one
22
+ subject.require_const :constant_one
23
23
 
24
- @module.should be_const_defined('ConstantOne')
24
+ expect(subject).to be_const_defined('ConstantOne')
25
25
  end
26
26
 
27
27
  it "should find loaded constants in the namespace" do
28
- const = @module.require_const(:constant_one)
28
+ const = subject.require_const(:constant_one)
29
29
 
30
- const.class.should == Class
31
- const.name.should == 'Classes::SimpleNamespace::ConstantOne'
30
+ expect(const.class).to be(Class)
31
+ expect(const.name).to eq('Classes::SimpleNamespace::ConstantOne')
32
32
  end
33
33
 
34
34
  it "should find constants with odd capitalization" do
35
- const = @module.require_const(:odd_constant)
35
+ const = subject.require_const(:odd_constant)
36
36
 
37
- const.class.should == Class
38
- const.name.should == 'Classes::SimpleNamespace::ODDConstant'
37
+ expect(const.class).to be(Class)
38
+ expect(const.name).to eq('Classes::SimpleNamespace::ODDConstant')
39
39
  end
40
40
 
41
41
  it "should load constants via sub-paths" do
42
- @module.require_const File.join('sub','constant_four')
42
+ subject.require_const(File.join('sub','constant_four'))
43
+
44
+ expect(subject).to be_const_defined('Sub')
43
45
 
44
- @module.should be_const_defined('Sub')
45
- @sub = @module.const_get('Sub')
46
+ sub = subject.const_get('Sub')
46
47
 
47
- @sub.should be_const_defined('ConstantFour')
48
+ expect(sub).to be_const_defined('ConstantFour')
48
49
  end
49
50
 
50
51
  it "should find constants loaded via sub-paths" do
51
- const = @module.require_const(File.join('sub','constant_four'))
52
+ const = subject.require_const(File.join('sub','constant_four'))
52
53
 
53
- const.class.should == Class
54
- const.name.should == 'Classes::SimpleNamespace::Sub::ConstantFour'
54
+ expect(const.class).to be(Class)
55
+ expect(const.name).to eq('Classes::SimpleNamespace::Sub::ConstantFour')
55
56
  end
56
57
 
57
58
  it "should return nil on LoadError exceptions" do
58
- const = @module.require_const(:constant_not_found)
59
+ const = subject.require_const(:constant_not_found)
59
60
 
60
- const.should be_nil
61
+ expect(const).to be(nil)
61
62
  end
62
63
 
63
64
  it "should return nil on NameError exceptions" do
64
- const = @module.require_const(:bad_constant)
65
+ const = subject.require_const(:bad_constant)
65
66
 
66
- const.should be_nil
67
+ expect(const).to be(nil)
67
68
  end
68
69
 
69
70
  it "should attempt loading the constant when calling const_defined?" do
70
- @module.const_defined?('ConstantThree').should == true
71
+ expect(subject.const_defined?('ConstantThree')).to be(true)
71
72
  end
72
73
 
73
74
  it "should load constants transparently via const_missing" do
74
- const = @module::ConstantTwo
75
+ const = subject::ConstantTwo
75
76
 
76
- const.class.should == Class
77
- const.name.should == 'Classes::SimpleNamespace::ConstantTwo'
77
+ expect(const.class).to be(Class)
78
+ expect(const.name).to eq('Classes::SimpleNamespace::ConstantTwo')
78
79
  end
79
80
 
80
81
  it "should raise a NameError exception const_missing fails" do
81
- lambda {
82
- @module::BadConstant
83
- }.should raise_error(NameError)
82
+ expect {
83
+ subject::BadConstant
84
+ }.to raise_error(NameError)
84
85
  end
85
86
  end
86
87
 
87
88
  context "custom namespace" do
88
- before(:all) do
89
- @module = Classes::CustomNamespace
90
- end
89
+ subject { Classes::CustomNamespace }
91
90
 
92
91
  it "should have the same namespace root as the module's directory" do
93
- @module.namespace_root.should == File.join('classes','custom')
92
+ expect(subject.namespace_root).to eq(File.join('classes','custom'))
94
93
  end
95
94
 
96
95
  it "should load constants into the namespace" do
97
- @module.require_const :constant_one
98
- @module.should be_const_defined('ConstantOne')
96
+ subject.require_const(:constant_one)
97
+
98
+ expect(subject).to be_const_defined('ConstantOne')
99
99
  end
100
100
 
101
101
  it "should find loaded constants in the namespace" do
102
- const = @module.require_const(:constant_one)
102
+ const = subject.require_const(:constant_one)
103
103
 
104
- const.class.should == Class
105
- const.name.should == 'Classes::CustomNamespace::ConstantOne'
104
+ expect(const.class).to be(Class)
105
+ expect(const.name).to eq('Classes::CustomNamespace::ConstantOne')
106
106
  end
107
107
 
108
108
  it "should find constants with odd capitalization" do
109
- const = @module.require_const(:odd_constant)
109
+ const = subject.require_const(:odd_constant)
110
110
 
111
- const.class.should == Class
112
- const.name.should == 'Classes::CustomNamespace::ODDConstant'
111
+ expect(const.class).to be(Class)
112
+ expect(const.name).to eq('Classes::CustomNamespace::ODDConstant')
113
113
  end
114
114
 
115
115
  it "should load constants via sub-paths" do
116
- @module.require_const File.join('sub','constant_four')
116
+ subject.require_const File.join('sub','constant_four')
117
+
118
+ expect(subject).to be_const_defined('Sub')
117
119
 
118
- @module.should be_const_defined('Sub')
119
- @sub = @module.const_get('Sub')
120
+ sub = subject.const_get('Sub')
120
121
 
121
- @sub.should be_const_defined('ConstantFour')
122
+ expect(sub).to be_const_defined('ConstantFour')
122
123
  end
123
124
 
124
125
  it "should find constants loaded via sub-paths" do
125
- const = @module.require_const(File.join('sub','constant_four'))
126
+ const = subject.require_const(File.join('sub','constant_four'))
126
127
 
127
- const.class.should == Class
128
- const.name.should == 'Classes::CustomNamespace::Sub::ConstantFour'
128
+ expect(const.class).to be(Class)
129
+ expect(const.name).to eq('Classes::CustomNamespace::Sub::ConstantFour')
129
130
  end
130
131
 
131
132
  it "should return nil on LoadError exceptions" do
132
- const = @module.require_const(:constant_not_found)
133
+ const = subject.require_const(:constant_not_found)
133
134
 
134
- const.should be_nil
135
+ expect(const).to be_nil
135
136
  end
136
137
 
137
138
  it "should return nil on NameError exceptions" do
138
- const = @module.require_const(:bad_constant)
139
+ const = subject.require_const(:bad_constant)
139
140
 
140
- const.should be_nil
141
+ expect(const).to be_nil
141
142
  end
142
143
 
143
144
  it "should attempt loading the constant when calling const_defined?" do
144
- @module.const_defined?('ConstantThree').should == true
145
+ expect(subject.const_defined?('ConstantThree')).to be(true)
145
146
  end
146
147
 
147
148
  it "should load constants transparently via const_missing" do
148
- const = @module::ConstantTwo
149
+ const = subject::ConstantTwo
149
150
 
150
- const.class.should == Class
151
- const.name.should == 'Classes::CustomNamespace::ConstantTwo'
151
+ expect(const.class).to be(Class)
152
+ expect(const.name).to eq('Classes::CustomNamespace::ConstantTwo')
152
153
  end
153
154
 
154
155
  it "should raise a NameError exception const_missing fails" do
155
- lambda {
156
- @module::BadConstant
157
- }.should raise_error(NameError)
156
+ expect {
157
+ subject::BadConstant
158
+ }.to raise_error(NameError)
158
159
  end
159
160
  end
160
161
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,4 @@
1
- gem 'rspec', '~> 2.4'
2
1
  require 'rspec'
3
-
4
2
  require 'open_namespace/version'
5
3
 
6
4
  include OpenNamespace
metadata CHANGED
@@ -1,49 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_namespace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
5
- prerelease:
4
+ version: 0.4.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Postmodern
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-11-20 00:00:00.000000000 Z
11
+ date: 2024-01-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: ore-tasks
16
- requirement: &10491560 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0.4'
19
+ version: '2.0'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *10491560
25
- - !ruby/object:Gem::Dependency
26
- name: rspec
27
- requirement: &10494620 !ruby/object:Gem::Requirement
28
- none: false
22
+ version_requirements: !ruby/object:Gem::Requirement
29
23
  requirements:
30
- - - ~>
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '2.4'
33
- type: :development
34
- prerelease: false
35
- version_requirements: *10494620
36
- - !ruby/object:Gem::Dependency
37
- name: yard
38
- requirement: &10370760 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- version: '0.7'
44
- type: :development
45
- prerelease: false
46
- version_requirements: *10370760
26
+ version: '2.0'
47
27
  description: OpenNamespace allows namespaces to require and find classes and modules
48
28
  from other RubyGems.
49
29
  email: postmodern.mod3@gmail.com
@@ -54,11 +34,14 @@ extra_rdoc_files:
54
34
  - LICENSE.txt
55
35
  - README.md
56
36
  files:
57
- - .gemtest
58
- - .gitignore
59
- - .rspec
60
- - .yardopts
37
+ - ".document"
38
+ - ".gemtest"
39
+ - ".github/workflows/ruby.yml"
40
+ - ".gitignore"
41
+ - ".rspec"
42
+ - ".yardopts"
61
43
  - ChangeLog.md
44
+ - Gemfile
62
45
  - LICENSE.txt
63
46
  - README.md
64
47
  - Rakefile
@@ -84,31 +67,32 @@ files:
84
67
  - spec/classes/simple_namespace/sub/constant_four.rb
85
68
  - spec/open_namespace_spec.rb
86
69
  - spec/spec_helper.rb
87
- homepage: http://github.com/postmodern/open_namespace
70
+ homepage: https://github.com/postmodern/open_namespace#readme
88
71
  licenses:
89
72
  - MIT
90
- post_install_message:
73
+ metadata:
74
+ documentation_uri: https://rubydoc.info/gems/open_namespace
75
+ source_code_uri: https://github.com/postmodern/open_namespace
76
+ bug_tracker_uri: https://github.com/postmodern/open_namespace/issues
77
+ changelog_uri: https://github.com/postmodern/open_namespace/blob/main/ChangeLog.md
78
+ rubygems_mfa_required: 'true'
79
+ post_install_message:
91
80
  rdoc_options: []
92
81
  require_paths:
93
82
  - lib
94
83
  required_ruby_version: !ruby/object:Gem::Requirement
95
- none: false
96
84
  requirements:
97
- - - ! '>='
85
+ - - ">="
98
86
  - !ruby/object:Gem::Version
99
87
  version: '0'
100
88
  required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
89
  requirements:
103
- - - ! '>='
90
+ - - ">="
104
91
  - !ruby/object:Gem::Version
105
92
  version: '0'
106
93
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 1.8.10
109
- signing_key:
110
- specification_version: 3
94
+ rubygems_version: 3.4.10
95
+ signing_key:
96
+ specification_version: 4
111
97
  summary: Allows namespaces to load constants on-demand
112
- test_files:
113
- - spec/open_namespace_spec.rb
114
- has_rdoc:
98
+ test_files: []