namo.rb 0.31.7 → 0.32.1
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 +22 -0
- data/README.md +6 -0
- data/bin/console +19 -0
- data/bin/namo +69 -0
- data/lib/Namo/VERSION.rb +1 -1
- data/namo.rb.gemspec +4 -0
- data/test/namo_command_test.rb +76 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 761839d0eae1156db148dffa532a094b3863721739b1ec62ef402014b05d1941
|
|
4
|
+
data.tar.gz: 6401e2a0ff2821478b540a73cb994e879fcb90207441f8e2c5e399c4b773bd24
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94533d7f08bb438468911e069cea7d2c106f39587ab563af57b4327524f0fc14caf4ffb9aeda69915fc81ddf4493f47f327f3657a34e931f42406686765cd52f
|
|
7
|
+
data.tar.gz: d432f9e57b6f505749e135b2abd35e2e49e5523e67b37c4842f74886c887cd2a1f640e9dc89b16118fe1afaf43fdb2e0d1121ff360f332eb8b0e67faca6bc066
|
data/CHANGELOG
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 20260828
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
2. ~ install.sh: + agreed, + parse_arguments, + usage, and install_homebrew is reached only where Ruby is missing and neither Homebrew nor MacPorts is present — a package manager already installed being used before one is installed, so a MacPorts machine is never asked about Homebrew. Homebrew is used where it is already installed, and installed only on a yes — -y answers in advance, and a script piped into a shell, having nobody able to refuse, is taken to have refused. Where Ruby is missing and Homebrew is declined, + ruby_routes names the ways to get Ruby — Homebrew as the command it is, MacPorts and ruby-install as pages, and a distribution's own package manager on Linux — rather than reporting only that no package manager was found.
|
|
9
|
+
3. ~ install.sh: + report_path. gem puts the command in its own directory, which is on the PATH on some machines and not on others; where it is not, the directory is named rather than somebody's shell configuration being written to.
|
|
10
|
+
4. ~ README.md: + the one-line install, for a machine with neither Ruby nor the gem.
|
|
11
|
+
5. ~ Namo::VERSION: /0.32.0/0.32.1/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 20260828
|
|
15
|
+
|
|
16
|
+
0.32.0: + bin/namo, the gem's first executable, and the gems it installs.
|
|
17
|
+
|
|
18
|
+
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.
|
|
19
|
+
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.
|
|
20
|
+
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.
|
|
21
|
+
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.
|
|
22
|
+
5. ~ Namo::VERSION: /0.31.7/0.32.0/
|
|
23
|
+
|
|
24
|
+
|
|
3
25
|
## 20260827
|
|
4
26
|
|
|
5
27
|
0.31.7: + namo.rb.gemspec, so that the gem resolves under both names.
|
data/README.md
CHANGED
|
@@ -18,6 +18,12 @@ 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, Homebrew or MacPorts supplies it if either is already installed; where neither 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:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
sh -c "$(curl -fsSL https://raw.githubusercontent.com/thoran/namo/master/install.sh)"
|
|
25
|
+
```
|
|
26
|
+
|
|
21
27
|
## Usage
|
|
22
28
|
|
|
23
29
|
Create a Namo instance from an array of hashes:
|
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,69 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# namo
|
|
3
|
+
|
|
4
|
+
# Description: Install the gems Namo's own scripts want, and hand you a prompt
|
|
5
|
+
# with Namo loaded.
|
|
6
|
+
#
|
|
7
|
+
# Homebrew and Ruby are install.sh's business, not this file's: a Ruby script
|
|
8
|
+
# cannot install the Ruby it is running on, and saying "Ruby is already
|
|
9
|
+
# installed!" is the only thing it could ever truthfully report. Every step here
|
|
10
|
+
# asks first and says so when there is nothing to do, so running it twice is not
|
|
11
|
+
# a mistake.
|
|
12
|
+
|
|
13
|
+
def usage
|
|
14
|
+
puts 'namo - Get a machine ready to run Namo.'
|
|
15
|
+
puts
|
|
16
|
+
puts 'Usage: namo [setup | console]'
|
|
17
|
+
puts
|
|
18
|
+
puts ' setup install the gems the scripts want, skipping whatever is there'
|
|
19
|
+
puts ' console an irb session with Namo loaded'
|
|
20
|
+
puts
|
|
21
|
+
puts 'The comparison scripts want two gems beyond these — sqlite3 and monotonic.rb —'
|
|
22
|
+
puts 'and a database which is not in this repository, so setup leaves them alone.'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def run(command)
|
|
26
|
+
puts '', command, ''
|
|
27
|
+
system(command)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def gem_installed?(name)
|
|
31
|
+
system("gem list -i #{name} > /dev/null 2>&1")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def install_gem(name)
|
|
35
|
+
if gem_installed?(name)
|
|
36
|
+
puts "#{name} is already installed!"
|
|
37
|
+
else
|
|
38
|
+
run("gem install #{name}")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
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.
|
|
48
|
+
def setup
|
|
49
|
+
install_gem('namo')
|
|
50
|
+
install_gem('measurand')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def console
|
|
54
|
+
exec(File.join(__dir__, 'console'))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def main
|
|
58
|
+
case ARGV[0]
|
|
59
|
+
when 'setup'; setup
|
|
60
|
+
when 'console'; console
|
|
61
|
+
when '--help', '-h', 'help', nil; usage
|
|
62
|
+
else
|
|
63
|
+
puts "Error: unknown command '#{ARGV[0]}'"
|
|
64
|
+
puts 'Use --help for usage'
|
|
65
|
+
exit 1
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
main
|
data/lib/Namo/VERSION.rb
CHANGED
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,76 @@
|
|
|
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 part a Ruby script cannot do — the Ruby the script would be
|
|
33
|
+
# running on, and the gem which carries the command it hands over to. Its
|
|
34
|
+
# syntax is asserted and its body is not run: a test which executed it on a
|
|
35
|
+
# machine without Ruby would install Ruby.
|
|
36
|
+
#
|
|
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.
|
|
39
|
+
#
|
|
40
|
+
# It installs Homebrew only through `agreed`, which answers no unless -y was
|
|
41
|
+
# given or somebody is there to say yes. What is asserted is that the curl of
|
|
42
|
+
# Homebrew's installer sits behind that gate: an unguarded call is the failure
|
|
43
|
+
# this is written against.
|
|
44
|
+
it "has a shell bootstrap which parses, hands over by name, and gates the one install it forces" do
|
|
45
|
+
root = File.expand_path('..', __dir__)
|
|
46
|
+
system("sh -n #{File.join(root, 'install.sh')}")
|
|
47
|
+
_($?.success?).must_equal true
|
|
48
|
+
body = File.read(File.join(root, 'install.sh'))
|
|
49
|
+
_(body).must_match(/install_ruby/)
|
|
50
|
+
_(body).must_match(/install_namo/)
|
|
51
|
+
_(body).must_match(/command -v port/)
|
|
52
|
+
_(body).must_match(/ruby_routes/)
|
|
53
|
+
_(body).must_match(/namo setup/)
|
|
54
|
+
_(body).wont_match(/SCRIPT_DIR/)
|
|
55
|
+
_(body).must_match(/elif agreed .*Install Homebrew\?.*; then\n\s+\/bin\/bash -c/)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "declines to install anything where nothing can answer" do
|
|
59
|
+
root = File.expand_path('..', __dir__)
|
|
60
|
+
output = IO.popen([File.join(root, 'install.sh'), '--help'], chdir: root, err: [:child, :out]){|io| io.read}
|
|
61
|
+
_($?.success?).must_equal true
|
|
62
|
+
_(output).must_match(/-y, --yes/)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "refuses a subcommand it does not have" do
|
|
66
|
+
namo('nonsense')
|
|
67
|
+
_($?.success?).must_equal false
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "needs nothing but the gem's own dependencies" do
|
|
71
|
+
root = File.expand_path('..', __dir__)
|
|
72
|
+
output = IO.popen({'RUBYLIB' => nil}, [File.join(root, 'bin', 'namo'), '--help'],
|
|
73
|
+
chdir: root, err: [:child, :out]){|io| io.read}
|
|
74
|
+
_(output).wont_match(/LoadError/)
|
|
75
|
+
end
|
|
76
|
+
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.
|
|
4
|
+
version: 0.32.1
|
|
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
|