switches.rb 0.10.2 → 0.10.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 +19 -0
- data/Gemfile +0 -4
- data/lib/Switches/VERSION.rb +6 -0
- data/lib/Switches.rb +5 -7
- data/spec/all.rb +41 -0
- data/switches.rb.gemspec +27 -10
- metadata +17 -4
- data/lib/Kernel/require_gem.rb +0 -7
- data/lib/Thoran/Kernel/RequireGem/require_gem.rb +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ea74840ee7d4c44d9a22e7e6c4464eb0417fd4ac0d65e0683465600188e2d903
|
|
4
|
+
data.tar.gz: 7f68a8a35001b0ff0445d605f276b3205c0651e3ab5a582e970fe5d4a771ea0a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 284df213837788db6c63752a357d763e16a84ea37331eb405365a6754335e8372a70a7dc880caddd3f6220d4530ccf901a4bfff12e3e9482ebbc7b22433e0bf2
|
|
7
|
+
data.tar.gz: 2b067b99909da06acaa0e366dae1ac41307f5347cd44383a3a036bac06e21eac521b6d670ac2ff07b6eac6f3332f9b07ddcee590c51e1466f039823569465f94
|
data/CHANGELOG
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 20260816
|
|
4
|
+
|
|
5
|
+
0.10.4: Declare ostruct as a runtime dependency, in place of installing it at require time.
|
|
6
|
+
|
|
7
|
+
1. ~ lib/Switches.rb: require 'ostruct', in place of the require_gem 'ostruct' introduced in 0.10.0. require_gem rescues the LoadError and shells out to gem install, so the dependency went unannounced and was satisfied silently into whatever GEM_HOME was set — which, under a Homebrew formula's wrapper, means the program installing a gem into its own keg. A library should announce what it needs and fail loudly without it.
|
|
8
|
+
2. ~ switches.rb.gemspec: + s.dependencies = ['ostruct'], declared as data via a dependencies= setter added to the local Gem::Specification reopening, alongside the development_dependencies= setter added in 0.10.3.
|
|
9
|
+
3. - lib/Kernel/require_gem.rb and - lib/Thoran/Kernel/RequireGem/require_gem.rb, vendored in 0.10.0 for the require above and with no remaining user.
|
|
10
|
+
4. ~ Gemfile: - gem 'ostruct', which the gemspec now supplies.
|
|
11
|
+
5. ~ spec/all.rb: the gemspec spec asserted that no runtime dependencies were declared, and now asserts that ostruct is the only one.
|
|
12
|
+
6. ~ lib/Switches.rb: the header's Dependencies section names ostruct, since the Standard Ruby Library no longer covers it.
|
|
13
|
+
7. ~ .gitignore: + a header, + .claude, ~ /tmp/ to tmp/, and - /test/tmp/, which tmp/ now covers.
|
|
14
|
+
|
|
3
15
|
## 20260812
|
|
4
16
|
|
|
17
|
+
0.10.3: Move the version into a constant, and add the standard version and gemspec tests.
|
|
18
|
+
|
|
19
|
+
1. + lib/Switches/VERSION.rb: Switches::VERSION, required from lib/Switches.rb. The version now lives in a constant the gemspec reads, in place of the '0.10.2' literal it declared.
|
|
20
|
+
2. ~ switches.rb.gemspec: s.version from Switches::VERSION; development_dependencies declared as data — s.development_dependencies = [...], via a setter added in a local Gem::Specification reopening — in place of the add_development_dependency calls; - s.date, which was a stale literal, letting RubyGems' default stand.
|
|
21
|
+
3. + spec/all.rb: the standard version and gemspec specs — VERSION is a string, an anchored X.Y.Z, and matches the newest CHANGELOG entry; the gemspec loads and validates, pins no date, takes its version from Switches::VERSION, declares no runtime dependencies, and declares rake and rspec for development.
|
|
22
|
+
4. - lib/Switches.rb: the "# 20260809 / # 0.10.1" date-and-version stamp in the header, now redundant since VERSION.rb carries the version.
|
|
23
|
+
|
|
5
24
|
0.10.2: Recover the in-source change log into the CHANGELOG, and move the Notes to the README.
|
|
6
25
|
|
|
7
26
|
1. + CHANGELOG: the 0.9.0 to 0.9.13 series, recovered from the "Changes since 0.8:" log that lived in the lib/Switches.rb header. The items are reproduced as written; the versions carry no reliable dates and are left undated.
|
data/Gemfile
CHANGED
data/lib/Switches.rb
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
# Switches.rb
|
|
2
2
|
# Switches
|
|
3
3
|
|
|
4
|
-
# 20260809
|
|
5
|
-
# 0.10.1
|
|
6
|
-
|
|
7
4
|
# Description: Switches provides for a nice wrapper to OptionParser to also act as a store for switches supplied.
|
|
8
5
|
|
|
9
6
|
# Todo:
|
|
@@ -15,13 +12,14 @@
|
|
|
15
12
|
# 2. Do away with optional arguments entirely. Since when does anyone want to specify a non-boolean switch and then supply no arguments anyway?... OK, maybe sometimes, but this is pretty obscure IMO. OK, bad idea. These can be used as action oriented sub-commands.
|
|
16
13
|
# 3. Allow for any one of the switches OpenStruct methods to assign values for any of the other associated methods, so as it is more than a read once switch and can be used for storage through out the application; although this might be stepping on Attributes.rb's toes?...
|
|
17
14
|
|
|
18
|
-
# Dependencies:
|
|
19
|
-
# 1. Standard Ruby Library.
|
|
15
|
+
# Dependencies:
|
|
16
|
+
# 1. Standard Ruby Library.
|
|
17
|
+
# 2. ostruct, which ceased to be a default gem as of Ruby 4.0 and so is declared in the gemspec.
|
|
20
18
|
|
|
21
19
|
require 'optparse'
|
|
22
|
-
require '
|
|
20
|
+
require 'ostruct'
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
require_relative './Switches/VERSION'
|
|
25
23
|
|
|
26
24
|
class OpenStruct
|
|
27
25
|
|
data/spec/all.rb
CHANGED
|
@@ -224,3 +224,44 @@ describe Switches do
|
|
|
224
224
|
end
|
|
225
225
|
end
|
|
226
226
|
end
|
|
227
|
+
|
|
228
|
+
describe Switches do
|
|
229
|
+
describe "VERSION" do
|
|
230
|
+
it "is a string" do
|
|
231
|
+
expect(Switches::VERSION).to be_a(String)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
it "is three numbers separated by dots" do
|
|
235
|
+
expect(Switches::VERSION).to match(/\A\d+\.\d+\.\d+\z/)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
it "matches the newest entry in the CHANGELOG" do
|
|
239
|
+
changelog = File.read(File.expand_path('../CHANGELOG', __dir__))
|
|
240
|
+
expect(changelog[/^(\d+\.\d+\.\d+):/, 1]).to eq(Switches::VERSION)
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
describe 'switches.rb.gemspec' do
|
|
246
|
+
let(:spec){Gem::Specification.load(File.expand_path('../switches.rb.gemspec', __dir__))}
|
|
247
|
+
|
|
248
|
+
it "is a valid specification" do
|
|
249
|
+
expect(spec.validate).to eq(true)
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
it "does not pin a date" do
|
|
253
|
+
expect(spec.date).to eq(Gem::Specification.new.date)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
it "takes its version from Switches::VERSION" do
|
|
257
|
+
expect(spec.version.to_s).to eq(Switches::VERSION)
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
it "declares ostruct as its only runtime dependency" do
|
|
261
|
+
expect(spec.runtime_dependencies.map(&:name).sort).to eq(%w{ostruct})
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
it "declares its development dependencies" do
|
|
265
|
+
expect(spec.development_dependencies.map(&:name).sort).to eq(%w{rake rspec})
|
|
266
|
+
end
|
|
267
|
+
end
|
data/switches.rb.gemspec
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require_relative './lib/Switches/VERSION'
|
|
2
|
+
|
|
3
|
+
class Gem::Specification
|
|
4
|
+
def dependencies=(gems)
|
|
5
|
+
gems.each{|gem| add_dependency(*gem)}
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def development_dependencies=(gems)
|
|
9
|
+
gems.each{|gem| add_development_dependency(*gem)}
|
|
10
|
+
end
|
|
11
|
+
end
|
|
3
12
|
|
|
4
|
-
|
|
5
|
-
s.
|
|
13
|
+
Gem::Specification.new do |s|
|
|
14
|
+
s.name = 'switches.rb'
|
|
15
|
+
s.version = Switches::VERSION
|
|
6
16
|
|
|
7
17
|
s.summary = "The easiest way to provide switches to a Ruby program."
|
|
8
18
|
s.description = "Switches provides for a nice wrapper to OptionParser to also act as a store for switches supplied."
|
|
19
|
+
|
|
9
20
|
s.author = 'thoran'
|
|
10
21
|
s.email = 'code@thoran.com'
|
|
11
22
|
s.homepage = "https://github.com/thoran/switches"
|
|
12
23
|
s.license = 'MIT'
|
|
13
|
-
s.required_ruby_version = ">= 2.7.0"
|
|
14
24
|
|
|
15
|
-
s.
|
|
16
|
-
s.
|
|
25
|
+
s.required_ruby_version = ">= 2.7.0"
|
|
26
|
+
s.require_paths = ['lib']
|
|
17
27
|
|
|
18
28
|
s.files = [
|
|
19
29
|
'CHANGELOG',
|
|
@@ -23,15 +33,22 @@ Gem::Specification.new do |s|
|
|
|
23
33
|
'README.md',
|
|
24
34
|
'switches.rb.gemspec',
|
|
25
35
|
Dir['lib/**/*.rb'],
|
|
26
|
-
Dir['spec/**/*.rb']
|
|
36
|
+
Dir['spec/**/*.rb'],
|
|
27
37
|
].flatten
|
|
28
38
|
|
|
29
|
-
s.
|
|
39
|
+
s.dependencies = [
|
|
40
|
+
'ostruct'
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
s.development_dependencies = [
|
|
44
|
+
'rake',
|
|
45
|
+
'rspec'
|
|
46
|
+
]
|
|
30
47
|
|
|
31
48
|
s.metadata = {
|
|
32
49
|
"bug_tracker_uri" => "https://github.com/thoran/switches/issues",
|
|
33
50
|
"changelog_uri" => "https://github.com/thoran/switches/blob/master/CHANGELOG",
|
|
34
51
|
"source_code_uri" => "https://github.com/thoran/switches",
|
|
35
|
-
"documentation_uri" => "https://github.com/thoran/switches/blob/master/README.md"
|
|
52
|
+
"documentation_uri" => "https://github.com/thoran/switches/blob/master/README.md",
|
|
36
53
|
}
|
|
37
54
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: switches.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.10.
|
|
4
|
+
version: 0.10.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: ostruct
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
12
26
|
- !ruby/object:Gem::Dependency
|
|
13
27
|
name: rake
|
|
14
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -49,9 +63,8 @@ files:
|
|
|
49
63
|
- LICENSE.txt
|
|
50
64
|
- README.md
|
|
51
65
|
- Rakefile
|
|
52
|
-
- lib/Kernel/require_gem.rb
|
|
53
66
|
- lib/Switches.rb
|
|
54
|
-
- lib/
|
|
67
|
+
- lib/Switches/VERSION.rb
|
|
55
68
|
- spec/all.rb
|
|
56
69
|
- switches.rb.gemspec
|
|
57
70
|
homepage: https://github.com/thoran/switches
|
data/lib/Kernel/require_gem.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# Thoran/Kernel/RequireGem/require_gem.rb
|
|
2
|
-
# Thoran::Kernel::RequireGem#require_gem.rb
|
|
3
|
-
|
|
4
|
-
# 20240613
|
|
5
|
-
# 0.0.0
|
|
6
|
-
|
|
7
|
-
module Thoran
|
|
8
|
-
module Kernel
|
|
9
|
-
module RequireGem
|
|
10
|
-
|
|
11
|
-
def require_gem(load_string, gem_name: nil)
|
|
12
|
-
require load_string
|
|
13
|
-
rescue LoadError
|
|
14
|
-
if gem_name
|
|
15
|
-
system("gem install #{gem_name}")
|
|
16
|
-
else
|
|
17
|
-
system("gem install #{load_string}")
|
|
18
|
-
end
|
|
19
|
-
Gem.clear_paths
|
|
20
|
-
require load_string
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
Kernel.include(Thoran::Kernel::RequireGem)
|