namo.rb 0.32.2 → 0.32.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cdcd36cc0d3b94a3d75d935ec816993f2b11946b53934f93225ec24f38b9567
4
- data.tar.gz: 3f6359e0309eadfe76a206e4324918567b3b097704dba6a502d1e20eacd36e6f
3
+ metadata.gz: 53b03d4045a0b90e48ab18b834da6989c9ef3f2312201980bcf237e2eb59e524
4
+ data.tar.gz: f553c3f071bab22000a02cc7a177a23209eee2a85f29fe6cd98f718238311542
5
5
  SHA512:
6
- metadata.gz: 8218b30ec72a118656fcadd27af5a9213b2785d62642712a7c5bcc5cddc4195c01983a0477326a582d4657fe7f1c3b3a4842534121407d53a2183de41b661f58
7
- data.tar.gz: 2ed7ed7d9ca94c3cba1c878c56c4319cad59c04e2d1d7f50f82e78174bbc2cb3c8a826098d3e3fb509b7584b8efba2471b942b145390b1d6c0d868b5545ce866
6
+ metadata.gz: 19da5053f77a492572812811375007b4f3b91bcfd56335b6ae011c22e60c09ab6a30cbb393d5ef78ce42ed493be5afdff73a692db02769c026a4063fed4dfaf0
7
+ data.tar.gz: 379ebab7255ecc861e16b95fb076a949736ccdad3f22d3c97f42168ef7f9c77bb1d2f45014cb047fe7ecf24f0e233c139ba5da1e84a3a51f61813142552f7e3c
data/CHANGELOG CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  ## 20260828
4
4
 
5
+ 0.32.4: ~ README.md: + Console, the command the gem has shipped since 0.32.0 going unmentioned until now.
6
+
7
+ 1. ~ README.md: + Console. `namo console` and `namo setup` had appeared nowhere: the gem gained an executable at 0.32.0 and the README named install.sh once, in the curl line, and the command not at all. Someone taking `gem install namo`, the first line of Installation, arrived at the library without learning that the console existed.
8
+ 2. ~ README.md: + the clone route, `git clone` and ./install.sh, which is the route the adjacent-bin/namo handover of 0.32.3 was written for and the one route no line described.
9
+ 3. ~ README.md: `gem install` and the Gemfile line say what they leave undone — the command is on the PATH only where gem's own directory is, which Homebrew's Ruby is the case against, and measurand arrives by `namo setup` rather than with the gem, a gemspec having no way to name a companion which is optional.
10
+ 4. ~ CHANGELOG: the 20260828 releases gather under one heading, as 20260824 and 20260826 gather theirs. Four releases in a day had taken a heading each.
11
+ 5. ~ Namo::VERSION: /0.32.3/0.32.4/
12
+
13
+
14
+ 0.32.3: ~ install.sh: + ruby-install, for a machine with no package manager at all; the handover is to a clone's own bin/namo where the script was run from one.
15
+
16
+ 1. ~ install.sh: + install_ruby_install, + ruby_from_ruby_install. Where no package manager is found and Homebrew is declined, ruby-install is offered — fetched from its latest release rather than a pinned version, built with make as root, and used to build Ruby. It is the last thing tried and the only route here which builds Ruby rather than fetching it.
17
+ 2. ~ install.sh: ruby-install leaves its Ruby under ~/.rubies, which nothing puts on the PATH — chruby's job, and chruby is not there either — so that directory is added to the PATH of the run and offered to the shell's configuration, as the gem's own directory is.
18
+ 3. ~ install.sh: + wants_on_path, and add_to_path takes none. A machine taking the ruby-install route has a Ruby under ~/.rubies and its gems elsewhere, so two directories want adding; they are gathered as they are found and the shell configuration is written to once, naming both, rather than the same question being asked twice seconds apart. Each is put on the running PATH as it is found, so that `namo setup` happens whether or not the file is written to.
19
+ 4. ~ install.sh: install_namo runs gem install rather than skipping where the command is present. gem install is idempotent for a version already installed and fetches a newer one where there is one, so this is what makes a second run an upgrade.
20
+ 5. ~ bin/namo: + gem_version, + report. Each check states the gem, its version and its status on one line, where the announcement had been a sentence carrying no version — the version being the part neither script had said. install.sh reports in the same shape, and its namo step speaks only where something changed — installed, or upgraded from a version — since gem install says "Successfully installed" whether or not it did anything, and `namo setup` reports the gem and its version a moment later regardless.
21
+ 6. ~ install.sh: + repository, and hand_over takes the clone it was given. install_namo is the bootstrap for the handover and nothing else — a way to have a namo command to run — so a script run from a checkout hands over to that checkout's bin/namo and leaves the gem to `namo setup`, which installs it as its own first act. A checkout with the gem not yet installed now works as it stands, and the gem is named once rather than by both scripts in turn. 0.32.1 had taken the path lookup out for being unconditional, which failed piped from curl where the working directory is not a checkout; it is guarded now on $0 being a readable file beside both bin/namo and the gemspec, none of which holds for the shell's own name, so the curl route finds nothing and installs the gem as it did.
22
+ 7. ~ Namo::VERSION: /0.32.2/0.32.3/
23
+
24
+
5
25
  0.32.2: ~ install.sh: the one command ends with namo runnable from anywhere.
6
26
 
7
27
  1. ~ install.sh: + add_to_path, + gem_bin_directory, + shell_configuration_file. gem puts the command in a directory which is on the PATH on some machines and not on others — Homebrew's ruby puts it somewhere which is not — so the run ended by naming the directory and stopping. It now offers to add it to the shell's configuration file, and adds it to the PATH of the run itself so that `namo setup` happens rather than being left as a further instruction.
@@ -11,8 +31,6 @@
11
31
  5. ~ Namo::VERSION: /0.32.1/0.32.2/
12
32
 
13
33
 
14
- ## 20260828
15
-
16
34
  0.32.1: ~ install.sh: it runs the same piped from curl as from a clone, and forces no package manager; ~ README.md: + the one-line install.
17
35
 
18
36
  1. ~ install.sh: the handover is to `namo setup` on the PATH rather than to bin/namo beside the script. It had found bin/namo by its own path, so piped from curl it looked in the working directory and failed there. It now finds nothing by its path and so runs from anywhere. The check is for the namo command rather than for the gem, that being what the next step needs: an older namo installs no executable.
@@ -22,8 +40,6 @@
22
40
  5. ~ Namo::VERSION: /0.32.0/0.32.1/
23
41
 
24
42
 
25
- ## 20260828
26
-
27
43
  0.32.0: + bin/namo, the gem's first executable, and the gems it installs.
28
44
 
29
45
  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.
data/README.md CHANGED
@@ -18,12 +18,42 @@ Or in your Gemfile:
18
18
  gem 'namo'
19
19
  ```
20
20
 
21
- Or from nothing at all — Ruby, the gem, and the gems its scripts want, each step skipped where it is already there. Where Ruby is missing, whichever package manager is already installed supplies it Homebrew, MacPorts, apt, dnf, pacman or zypper; where none is, you are asked before Homebrew is installed; `-y` answers yes in advance, and a machine with nobody at the keyboard is taken to have said no. Where the gem's own directory is not on the PATH, it offers to add it to your shell's configuration, so that a new shell has `namo` in it:
21
+ Either brings the `namo` command with it, where the directory gem installs commands into is one your PATH reaches it is on a Ruby from ruby-install or rbenv, and is not on Homebrew's. `namo setup` then adds measurand, which the uncertainty examples want and which nothing else does.
22
+
23
+ Or from a clone, which wants none of it installed first:
24
+
25
+ ```
26
+ git clone https://github.com/thoran/namo.git
27
+ cd namo
28
+ ./install.sh
29
+ ```
30
+
31
+ Or from nothing at all — Ruby, the gem, and the gems its scripts want, each step skipped where it is already there. Where Ruby is missing, whichever package manager is already installed supplies it — Homebrew, MacPorts, apt, dnf, pacman or zypper; where none is, you are asked before Homebrew is installed, and then before ruby-install is built from source; `-y` answers yes in advance, and a machine with nobody at the keyboard is taken to have said no. Where the gem's own directory is not on the PATH, it offers to add it to your shell's configuration, so that a new shell has `namo` in it:
22
32
 
23
33
  ```
24
34
  sh -c "$(curl -fsSL https://raw.githubusercontent.com/thoran/namo/master/install.sh)"
25
35
  ```
26
36
 
37
+ The two which run `install.sh` end at a `namo` which runs from anywhere. The first ends at one which runs where your PATH already reaches it.
38
+
39
+ ## Console
40
+
41
+ The gem ships one command.
42
+
43
+ ```
44
+ namo console
45
+ ```
46
+
47
+ An irb session with Namo loaded, for asking a question of the library without writing a file first.
48
+
49
+ ```
50
+ namo setup
51
+ ```
52
+
53
+ Installs the gems the scripts want — namo itself, and measurand — skipping whichever is already there and naming each and its version either way. `install.sh` runs it as the last of its own work, so it is here for a gem which arrived by `gem install`, and for adding measurand to an installation which went without it.
54
+
55
+ `namo` alone prints the usage, as `namo --help` does.
56
+
27
57
  ## Usage
28
58
 
29
59
  Create a Namo instance from an array of hashes:
data/bin/namo CHANGED
@@ -31,20 +31,31 @@ def gem_installed?(name)
31
31
  system("gem list -i #{name} > /dev/null 2>&1")
32
32
  end
33
33
 
34
+ def gem_version(name)
35
+ Gem::Specification.find_all_by_name(name).map(&:version).max
36
+ rescue StandardError
37
+ nil
38
+ end
39
+
40
+ def report(name, status)
41
+ puts format(' %-11s %-8s %s', name, gem_version(name) || '-', status)
42
+ end
43
+
44
+ # The status and the version, one line per check. "already installed" on its own
45
+ # was the second script announcing what install.sh had just done; the version is
46
+ # what neither script has said, and is the reason to look.
34
47
  def install_gem(name)
35
48
  if gem_installed?(name)
36
- puts "#{name} is already installed!"
49
+ report(name, 'already installed')
37
50
  else
38
51
  run("gem install #{name}")
52
+ report(name, 'installed')
39
53
  end
40
54
  end
41
55
 
42
- # Namo itself first: arriving by `git clone` leaves the source on disk and nothing
43
- # on the load path, so the gem is what makes `require 'namo'` work from anywhere
44
- # else. Arriving by `gem install namo` has it already, and the step says so.
45
- #
46
- # measurand is the one the demo asks for and does without: its uncertainty section
47
- # skips itself when it is missing, and every other section runs regardless.
56
+ # namo itself first: arriving by `git clone`, or by install.sh before the gem is
57
+ # there, leaves nothing on the load path. measurand the demo asks for and does
58
+ # without, its uncertainty section skipping itself where it is missing.
48
59
  def setup
49
60
  install_gem('namo')
50
61
  install_gem('measurand')
data/lib/Namo/VERSION.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # Namo::VERSION
3
3
 
4
4
  class Namo
5
- VERSION = '0.32.2'
5
+ VERSION = '0.32.4'
6
6
  end
@@ -22,11 +22,15 @@ describe 'bin/namo' do
22
22
  _(output).must_match(/console/)
23
23
  end
24
24
 
25
- it "reports rather than acts where a gem is already there" do
25
+ # A line per check carrying the status and the version. "already installed" on
26
+ # its own repeated what install.sh had just done; the version is the part
27
+ # neither script has said, and the reason to read the line at all.
28
+ it "reports the status and version of each gem it checks" do
26
29
  output = namo('setup')
27
30
  _($?.success?).must_equal true
28
- _(output).must_match(/namo is already installed!/)
29
- _(output).must_match(/measurand is already installed!/)
31
+ _(output.lines.length).must_equal 2
32
+ _(output).must_match(/^\s+namo\s+\d+\.\d+\.\d+\s+already installed$/)
33
+ _(output).must_match(/^\s+measurand\s+\d+\.\d+\.\d+\s+already installed$/)
30
34
  end
31
35
 
32
36
  # install.sh is the part a Ruby script cannot do — the Ruby the script would be
@@ -34,8 +38,11 @@ describe 'bin/namo' do
34
38
  # syntax is asserted and its body is not run: a test which executed it on a
35
39
  # machine without Ruby would install Ruby.
36
40
  #
37
- # It hands over by name rather than by path, which is what lets it run piped
38
- # from curl an assertion that it finds nothing by SCRIPT_DIR.
41
+ # It hands over to a clone's own bin/namo where it was run from one, and fetches
42
+ # the gem only where it was not: the gem is the bootstrap for the handover rather
43
+ # than a second opinion about what wants installing. Piped from curl there is no
44
+ # clone to find, the guard being that $0 is a readable file at all, which the
45
+ # shell's own name is not.
39
46
  #
40
47
  # It installs Homebrew only through `agreed`, which answers no unless -y was
41
48
  # given or somebody is there to say yes. What is asserted is that the curl of
@@ -52,8 +59,18 @@ describe 'bin/namo' do
52
59
  _(body).must_match(/command -v #{manager}/)
53
60
  end
54
61
  _(body).must_match(/ruby_routes/)
62
+ _(body).must_match(/install_ruby_install/)
63
+ # One prompt and one line however many directories want adding: the shell
64
+ # configuration is written to once, not once per directory.
65
+ _(body).must_match(/wants_on_path/)
66
+ _(body.scan(/>> "\$file"/).length).must_equal 1
67
+ # The tag is resolved from the latest release rather than pinned, so that the
68
+ # branch does not rot against a version.
69
+ _(body).wont_match(/ruby-install-0\.\d+\.\d+\.tar\.gz/)
55
70
  _(body).must_match(/namo setup/)
56
- _(body).wont_match(/SCRIPT_DIR/)
71
+ _(body).must_match(/repository\(\) \{\n\s+\[ -f "\$0" \]/)
72
+ _(body).must_match(%r{"\$clone/bin/namo" setup})
73
+ _(body).must_match(/\[ -n "\$clone" \] \|\| install_namo/)
57
74
  _(body).must_match(/elif agreed .*Install Homebrew\?.*; then\n\s+\/bin\/bash -c/)
58
75
  end
59
76
 
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.32.2
4
+ version: 0.32.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran