exsys 0.5 → 0.6

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.
@@ -0,0 +1,61 @@
1
+ require_relative 'helper'
2
+
3
+ # The README documents the executable by name and by example. Both can
4
+ # drift away from the tool without anything saying so -- the name did,
5
+ # and sat wrong through four releases -- so both are checked here.
6
+ class TestReadme < Minitest::Test
7
+ include CLI
8
+
9
+ README = File.read(File.join(ROOT, 'README.md')).freeze
10
+
11
+ # Regression: every example named `exsys-hub`, which has never been
12
+ # the name of anything this gem installs.
13
+ def test_the_shell_examples_name_the_real_executable
14
+ named = shell_commands.map {|line| line.split.first }.uniq
15
+ .grep(/\Aexsys/)
16
+
17
+ refute_empty named, 'no exsys command appears in the README'
18
+ assert_equal [ File.basename(EXE) ], named
19
+ end
20
+
21
+ # And each example must still be one the tool accepts, so that a
22
+ # renamed action or a changed argument syntax cannot sit in the
23
+ # documentation unnoticed.
24
+ def test_every_documented_example_is_accepted
25
+ examples = documented_examples
26
+ assert_operator examples.size, :>=, 6, 'README examples went missing'
27
+
28
+ examples.each do |line, argv|
29
+ _, err, st = exsys_usb_raw(argv)
30
+ assert_equal 0, st.exitstatus,
31
+ "README example is not accepted: #{line}\n#{err}"
32
+ end
33
+ end
34
+
35
+ def test_the_documented_test_command_is_the_one_that_runs
36
+ assert_includes shell_commands, 'rake test'
37
+ end
38
+
39
+ private
40
+
41
+ # Command lines from the README's shell blocks, comments and blank
42
+ # lines removed.
43
+ def shell_commands
44
+ README.scan(/^~~~sh$(.*?)^~~~$/m).flatten.join("\n")
45
+ .lines.map {|l| l.sub(/#.*/, '').strip }.reject(&:empty?)
46
+ end
47
+
48
+ # Those that invoke the executable, as [ line, argv ]. The shell
49
+ # variable the README uses for the device is replaced by one that
50
+ # exists everywhere, and anything the shell would interpret rather
51
+ # than pass on -- a pipe, a conditional, a redirection -- is cut
52
+ # off, since these run the executable directly and not under a
53
+ # shell. What is checked is the invocation, not the plumbing.
54
+ def documented_examples
55
+ shell_commands.filter_map do |line|
56
+ next unless line.start_with?(File.basename(EXE))
57
+ cmd = line.split(/\s(?:\|\||&&|\||;|>>?)\s/).first
58
+ [ line, Shellwords.split(cmd.sub('${dev}', '/dev/null'))[1..] ]
59
+ end
60
+ end
61
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exsys
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: '0.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stéphane D'Alu
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: uart
@@ -24,6 +23,20 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: minitest
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '5'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '5'
27
40
  - !ruby/object:Gem::Dependency
28
41
  name: yard
29
42
  requirement: !ruby/object:Gem::Requirement
@@ -64,16 +77,22 @@ extensions: []
64
77
  extra_rdoc_files: []
65
78
  files:
66
79
  - README.md
80
+ - Rakefile
67
81
  - bin/exsys-usb
68
82
  - exsys.gemspec
69
83
  - lib/exsys.rb
70
84
  - lib/exsys/managed-usb.rb
71
85
  - lib/exsys/version.rb
86
+ - test/helper.rb
87
+ - test/support/fake_hub.rb
88
+ - test/support/uart.rb
89
+ - test/test_exsys_usb.rb
90
+ - test/test_managed_usb.rb
91
+ - test/test_readme.rb
72
92
  homepage: https://github.com/sdalu/ruby-exsys
73
93
  licenses:
74
94
  - MIT
75
95
  metadata: {}
76
- post_install_message:
77
96
  rdoc_options: []
78
97
  require_paths:
79
98
  - lib
@@ -88,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
107
  - !ruby/object:Gem::Version
89
108
  version: '0'
90
109
  requirements: []
91
- rubygems_version: 3.5.19
92
- signing_key:
110
+ rubygems_version: 4.0.16
93
111
  specification_version: 4
94
112
  summary: ExSYS managed USB hub support
95
113
  test_files: []