namo.rb 0.31.7 → 0.32.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 929afa1d55a647d886b7bd2aa61865223c187d0ce4b961063366b11190090edd
4
- data.tar.gz: 9087955ffb7d10e85c95ad67646085895ff2ed1d0e12d7dc3c0ecee9142b141c
3
+ metadata.gz: 394855a4344fa3257333f89bcf0422fb7916d7e0fc517c1d5afcb9f19f7a72f4
4
+ data.tar.gz: 9efd44d4d29889d11631f0cb7d0a0669e2614cb6b667ce5e8abaf65cb652785a
5
5
  SHA512:
6
- metadata.gz: 3973ae39888e5ff688206292d9523f31a89bd0bbe771be02c6dbbf2655311abe38234fd34d44ee6de8d74e16e6df43da1acc6d490a1308824ddbc67216319b67
7
- data.tar.gz: e5485f7223ab6c78d952fd8bbec07b1d0ce029401e9c6be2430485144e16d6e2844ade74bbccadda6c0c51bf0815fb13c819eabb90ca53ba20893a1026db85f0
6
+ metadata.gz: 0a49de0c3b6a29e5a44151065038c4b63c6645fcffca299a6b7a3efa93ee8fb27ead37eb387373a7f0c211bc53fe5925b675aabf45e14fb0595de9e6693a00ef
7
+ data.tar.gz: 2241f0e878f16f6dfd32a97b91645212c0b85c3e75f53c0fb3491c270a62239b402926f862fe908a1648a518bf29a3727476559dbc1ffecdf6655a6d72949b28
data/CHANGELOG CHANGED
@@ -1,5 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 20260828
4
+
5
+ 0.32.0: + bin/namo, the gem's first executable, and the gems it installs.
6
+
7
+ 1. + bin/namo: a setup subcommand which installs the gems Namo's scripts want — Namo itself, so that a clone leaves require 'namo' working, and measurand, which the demo's uncertainty section does without when it is missing — and a console subcommand which is bin/console. Each step asks first and says so when there is nothing to do.
8
+ 2. + install.sh: the two things a Ruby script cannot do for itself, Homebrew and the Ruby it would be running on, handed over to bin/namo for the rest. It is not shipped: a bootstrap for a machine without the gem cannot arrive by way of the gem.
9
+ 3. ~ namo.gemspec, namo.rb.gemspec: + Dir['bin/*'] to spec.files, + spec.bindir, + spec.executables. Shipping bin/namo without declaring it would carry a script nobody could run.
10
+ 4. + test/namo_command_test.rb: the subcommands are named, setup reports rather than acts where a gem is present, an unknown subcommand fails, and it runs with RUBYLIB unset.
11
+ 5. ~ Namo::VERSION: /0.31.7/0.32.0/
12
+
13
+
3
14
  ## 20260827
4
15
 
5
16
  0.31.7: + namo.rb.gemspec, so that the gem resolves under both names.
data/bin/console ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # console
3
+
4
+ # 20260826
5
+ # 0.0.0
6
+
7
+ # An irb session with Namo loaded, for asking a question of the library without
8
+ # writing a file first. require_relative rather than bundler/setup, so that it
9
+ # runs on a clean clone as script/demo and script/sizing do.
10
+ #
11
+ # The demo's own prompt is elsewhere: pressing i at a pause in script/demo opens
12
+ # irb on the binding that run has been using, which is the better tool for asking
13
+ # a question of what is on the screen — the objects themselves rather than a
14
+ # second process holding equal ones.
15
+
16
+ require_relative '../lib/namo'
17
+ require 'irb'
18
+
19
+ IRB.start
data/bin/namo ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+ # namo
3
+
4
+ # 20260827
5
+ # 0.0.0
6
+
7
+ # Description: Install the gems Namo's own scripts want, and hand you a prompt
8
+ # with Namo loaded.
9
+ #
10
+ # Homebrew and Ruby are install.sh's business, not this file's: a Ruby script
11
+ # cannot install the Ruby it is running on, and saying "Ruby is already
12
+ # installed!" is the only thing it could ever truthfully report. Every step here
13
+ # asks first and says so when there is nothing to do, so running it twice is not
14
+ # a mistake.
15
+
16
+ def usage
17
+ puts 'namo - Get a machine ready to run Namo.'
18
+ puts
19
+ puts 'Usage: namo [setup | console]'
20
+ puts
21
+ puts ' setup install the gems the scripts want, skipping whatever is there'
22
+ puts ' console an irb session with Namo loaded'
23
+ puts
24
+ puts 'The comparison scripts want two gems beyond these — sqlite3 and monotonic.rb —'
25
+ puts 'and a database which is not in this repository, so setup leaves them alone.'
26
+ end
27
+
28
+ def run(command)
29
+ puts '', command, ''
30
+ system(command)
31
+ end
32
+
33
+ def gem_installed?(name)
34
+ system("gem list -i #{name} > /dev/null 2>&1")
35
+ end
36
+
37
+ def install_gem(name)
38
+ if gem_installed?(name)
39
+ puts "#{name} is already installed!"
40
+ else
41
+ run("gem install #{name}")
42
+ end
43
+ end
44
+
45
+ # Namo itself first: arriving by `git clone` leaves the source on disk and nothing
46
+ # on the load path, so the gem is what makes `require 'namo'` work from anywhere
47
+ # else. Arriving by `gem install namo` has it already, and the step says so.
48
+ #
49
+ # measurand is the one the demo asks for and does without: its uncertainty section
50
+ # skips itself when it is missing, and every other section runs regardless.
51
+ def setup
52
+ install_gem('namo')
53
+ install_gem('measurand')
54
+ end
55
+
56
+ def console
57
+ exec(File.join(__dir__, 'console'))
58
+ end
59
+
60
+ def main
61
+ case ARGV[0]
62
+ when 'setup'; setup
63
+ when 'console'; console
64
+ when '--help', '-h', 'help', nil; usage
65
+ else
66
+ puts "Error: unknown command '#{ARGV[0]}'"
67
+ puts 'Use --help for usage'
68
+ exit 1
69
+ end
70
+ end
71
+
72
+ main
data/lib/Namo/VERSION.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # Namo::VERSION
3
3
 
4
4
  class Namo
5
- VERSION = '0.31.7'
5
+ VERSION = '0.32.0'
6
6
  end
data/namo.rb.gemspec CHANGED
@@ -21,9 +21,13 @@ Gem::Specification.new do |spec|
21
21
  spec.license = 'MIT'
22
22
 
23
23
  spec.required_ruby_version = '>= 2.7'
24
+
25
+ spec.bindir = 'bin'
26
+ spec.executables = ['namo']
24
27
  spec.require_paths = ['lib']
25
28
 
26
29
  spec.files = [
30
+ Dir['bin/*'],
27
31
  Dir['lib/**/*.rb'],
28
32
  Dir['test/**/*.rb'],
29
33
  'CHANGELOG',
@@ -0,0 +1,56 @@
1
+ # test/namo_command_test.rb
2
+
3
+ require 'minitest/autorun'
4
+ require 'minitest-spec-context'
5
+
6
+ # bin/namo is the setup subcommand in the shape startor, shellac and mercurial use
7
+ # it: a predicate per prerequisite, an install which says so when there is nothing
8
+ # to do, and setup calling them in order. What is worth asserting is the surface —
9
+ # that it reports rather than acts when everything is present, and that it refuses
10
+ # what it does not know — not that it can install Homebrew.
11
+
12
+ describe 'bin/namo' do
13
+ def namo(*arguments)
14
+ root = File.expand_path('..', __dir__)
15
+ IO.popen([File.join(root, 'bin', 'namo'), *arguments],
16
+ chdir: root, err: [:child, :out]){|io| io.read}
17
+ end
18
+
19
+ it "names its subcommands" do
20
+ output = namo('--help')
21
+ _(output).must_match(/setup/)
22
+ _(output).must_match(/console/)
23
+ end
24
+
25
+ it "reports rather than acts where a gem is already there" do
26
+ output = namo('setup')
27
+ _($?.success?).must_equal true
28
+ _(output).must_match(/namo is already installed!/)
29
+ _(output).must_match(/measurand is already installed!/)
30
+ end
31
+
32
+ # install.sh is the half a Ruby script cannot do — Homebrew, and the Ruby the
33
+ # script would be running on. Its syntax is asserted and its body is not run:
34
+ # a test which executed it on a machine lacking Homebrew would install Homebrew.
35
+ it "has a shell bootstrap which parses, and which hands over to this" do
36
+ root = File.expand_path('..', __dir__)
37
+ system("sh -n #{File.join(root, 'install.sh')}")
38
+ _($?.success?).must_equal true
39
+ body = File.read(File.join(root, 'install.sh'))
40
+ _(body).must_match(/install_homebrew/)
41
+ _(body).must_match(/install_ruby/)
42
+ _(body).must_match(%r{bin/namo" setup})
43
+ end
44
+
45
+ it "refuses a subcommand it does not have" do
46
+ namo('nonsense')
47
+ _($?.success?).must_equal false
48
+ end
49
+
50
+ it "needs nothing but the gem's own dependencies" do
51
+ root = File.expand_path('..', __dir__)
52
+ output = IO.popen({'RUBYLIB' => nil}, [File.join(root, 'bin', 'namo'), '--help'],
53
+ chdir: root, err: [:child, :out]){|io| io.read}
54
+ _(output).wont_match(/LoadError/)
55
+ end
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namo.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.7
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
@@ -55,7 +55,8 @@ description: A Ruby library for working with multi-dimensional data using named
55
55
  Initialise from an array of hashes making it trivial to use with databases, CSV,
56
56
  JSON, and YAML. Dimensions and coordinates are inferred automatically.
57
57
  email: code@thoran.com
58
- executables: []
58
+ executables:
59
+ - namo
59
60
  extensions: []
60
61
  extra_rdoc_files: []
61
62
  files:
@@ -64,6 +65,8 @@ files:
64
65
  - LICENSE
65
66
  - README.md
66
67
  - Rakefile
68
+ - bin/console
69
+ - bin/namo
67
70
  - lib/Namo/Collection.rb
68
71
  - lib/Namo/Enumerable.rb
69
72
  - lib/Namo/Formulae.rb
@@ -81,6 +84,7 @@ files:
81
84
  - test/Symbol_test.rb
82
85
  - test/console_test.rb
83
86
  - test/demo_test.rb
87
+ - test/namo_command_test.rb
84
88
  - test/namo_test.rb
85
89
  - test/sizing_test.rb
86
90
  homepage: https://github.com/thoran/namo