sevgi-showcase 0.98.2 → 1.0.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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sevgi-showcase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.98.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Recai Oktaş
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.98.2
18
+ version: 1.0.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.98.2
25
+ version: 1.0.0
26
26
  description: Packages tested .sevgi examples and documentation site support.
27
27
  email: roktas@gmail.com
28
28
  executables: []
@@ -36,10 +36,12 @@ files:
36
36
  - lib/sevgi/showcase/dark.rb
37
37
  - lib/sevgi/showcase/minitest.rb
38
38
  - lib/sevgi/showcase/minitest/script.rb
39
- - lib/sevgi/showcase/minitest/shell.rb
40
39
  - lib/sevgi/showcase/minitest/suite.rb
41
40
  - lib/sevgi/showcase/passive.rb
42
41
  - lib/sevgi/showcase/version.rb
42
+ - srv/arc.sevgi
43
+ - srv/arc.svg
44
+ - srv/arc.yml
43
45
  - srv/checkers.sevgi
44
46
  - srv/checkers.svg
45
47
  - srv/checkers.yml
@@ -55,6 +57,9 @@ files:
55
57
  - srv/grid.sevgi
56
58
  - srv/grid.svg
57
59
  - srv/grid.yml
60
+ - srv/hatch.sevgi
61
+ - srv/hatch.svg
62
+ - srv/hatch.yml
58
63
  - srv/heart.sevgi
59
64
  - srv/heart.svg
60
65
  - srv/heart.yml
@@ -67,15 +72,18 @@ files:
67
72
  - srv/meter.sevgi
68
73
  - srv/meter.svg
69
74
  - srv/meter.yml
75
+ - srv/orb.sevgi
76
+ - srv/orb.svg
77
+ - srv/orb.yml
70
78
  - srv/pacman.sevgi
71
79
  - srv/pacman.svg
72
80
  - srv/pacman.yml
73
81
  - srv/pokey.sevgi
74
82
  - srv/pokey.svg
75
83
  - srv/pokey.yml
76
- - srv/ruler-.sevgi
77
- - srv/ruler-.svg
78
- - srv/ruler-.yml
84
+ - srv/protractor.sevgi
85
+ - srv/protractor.svg
86
+ - srv/protractor.yml
79
87
  - srv/ruler.sevgi
80
88
  - srv/ruler.svg
81
89
  - srv/ruler.yml
@@ -113,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
121
  - !ruby/object:Gem::Version
114
122
  version: '0'
115
123
  requirements: []
116
- rubygems_version: 4.0.16
124
+ rubygems_version: 4.0.20
117
125
  specification_version: 4
118
126
  summary: Executable examples and user documentation for Sevgi.
119
127
  test_files: []
@@ -1,170 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "open3"
4
- require "sevgi/function"
5
-
6
- module Sevgi
7
- module Showcase
8
- # Minitest helpers used by the showcase component.
9
- # @api private
10
- module Test
11
- # Shell runner helpers for showcase tests.
12
- # @api private
13
- module Shell
14
- # Shared process-global SIGINT state.
15
- # @api private
16
- Signals = ::Sevgi::Function::Shell.const_get(:Signals, false)
17
-
18
- private_constant :Signals
19
-
20
- # Shell command result.
21
- # @api private
22
- Result = Data.define(:args, :out, :err, :exit_code) do
23
- private_class_method :[]
24
-
25
- # Returns the command string.
26
- # @return [String]
27
- def cmd = args.join(" ")
28
-
29
- # Reports whether the command failed.
30
- # @return [Boolean]
31
- def notok? = !ok?
32
-
33
- # Reports whether the command exited successfully.
34
- # @return [Boolean]
35
- def ok? = exit_code&.zero?
36
-
37
- # Returns the first stdout line.
38
- # @return [String, nil]
39
- def outline = out.first
40
-
41
- # Returns stdout as a newline-joined string.
42
- # @return [String]
43
- def to_s = out.join("\n")
44
- end
45
-
46
- # Adapted to popen3 from github.com/mina-deploy/mina
47
- # Shell command runner.
48
- # @api private
49
- class Runner
50
- # Creates a runner.
51
- # @return [void]
52
- def initialize
53
- @coathooks = 0
54
- end
55
-
56
- # Runs a command and captures stdout, stderr, and exit status.
57
- # @param args [Array<String>] command and arguments
58
- # @yield optional stdin writer evaluated with stdin as receiver
59
- # @yieldreturn [Object]
60
- # @return [Sevgi::Showcase::Test::Shell::Result]
61
- # @raise [StandardError] when the input block raises; the child is terminated and reaped before propagation
62
- # @note The first SIGINT sends TERM and the second sends KILL outside trap context. The handler is restored after
63
- # the last active run.
64
- def run(*args, &block)
65
- @coathooks = 0
66
- out, err, status = Open3.popen3(*args) do |stdin, stdout, stderr, thread|
67
- capture(stdin, stdout, stderr, thread, &block)
68
- end
69
-
70
- Result.new(args:, out:, err:, exit_code: status.exitstatus)
71
- end
72
-
73
- private
74
-
75
- # rubocop:disable Lint/RescueException
76
- def capture(stdin, stdout, stderr, thread, &block)
77
- register_capture(thread)
78
- registered = true
79
- readers = outputs(stdout, stderr)
80
-
81
- collect_capture(stdin, thread, readers, &block)
82
- rescue Exception
83
- cleanup_failed_capture(stdin, thread, readers)
84
- raise
85
- ensure
86
- finish_capture(stdin, registered)
87
- end
88
- # rubocop:enable Lint/RescueException
89
-
90
- def finish_capture(stdin, registered)
91
- close_input(stdin)
92
- Signals.unregister(self) if registered
93
- end
94
-
95
- def register_capture(thread)
96
- Signals.register(self, thread.pid)
97
- end
98
-
99
- def cleanup_failed_capture(stdin, thread, readers)
100
- close_input(stdin)
101
- stop_process(thread)
102
- Array(readers).each(&:join)
103
- end
104
-
105
- def close_input(stdin)
106
- stdin.close unless stdin.closed?
107
- rescue IOError
108
- nil
109
- end
110
-
111
- def collect_capture(stdin, thread, readers, &block)
112
- inputs(stdin, thread, &block)
113
- close_input(stdin)
114
-
115
- [readers[0].value, readers[1].value, thread.value]
116
- end
117
-
118
- def handle_sigint(pid)
119
- @coathooks += 1
120
- message, signal = if @coathooks > 1
121
- ["SIGINT received again. Force quitting...", "KILL"]
122
- else
123
- ["SIGINT received.", "TERM"]
124
- end
125
-
126
- warn("\n#{message}")
127
- ::Process.kill(signal, pid)
128
- rescue Errno::ESRCH
129
- warn("No process to kill.")
130
- end
131
-
132
- def inputs(stdin, thread, &block)
133
- stdin.instance_exec(thread, &block) if block
134
- end
135
-
136
- def kill_process(signal, pid)
137
- ::Process.kill(signal, pid)
138
- rescue Errno::ESRCH
139
- nil
140
- end
141
-
142
- def outputs(stdout, stderr)
143
- [
144
- Thread.new { stdout.readlines.map(&:chomp) },
145
- Thread.new { stderr.readlines.map(&:chomp) }
146
- ]
147
- end
148
-
149
- def stop_process(thread)
150
- return unless thread&.alive?
151
-
152
- kill_process("TERM", thread.pid)
153
- return if thread.join(1)
154
-
155
- kill_process("KILL", thread.pid)
156
- thread.join
157
- end
158
- end
159
-
160
- extend self
161
-
162
- # @overload run(*args)
163
- # Runs a command through a fresh runner.
164
- # @param args [Array<String>] command and arguments
165
- # @return [Sevgi::Showcase::Test::Shell::Result]
166
- def run(...) = Runner.new.run(...)
167
- end
168
- end
169
- end
170
- end
data/srv/ruler-.sevgi DELETED
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env -S ruby -S sevgi
2
- # frozen_string_literal: true
3
-
4
- WIDTH = 150 # 15 cm width (ruler's length)
5
- HEIGHT = 20 # 2 cm height
6
-
7
- STYLE = {
8
- ".labels" => { fill: "black", font: "3pt monospace" },
9
- ".majors" => { stroke: "black", "stroke-width": 0.2 },
10
- ".halves" => { stroke: "black", "stroke-width": 0.1 },
11
- ".minors" => { stroke: "black", "stroke-width": 0.1 },
12
- ".frame" => { stroke: "black", "stroke-width": 0.05, fill: "none" }
13
- }.freeze
14
-
15
- SVG width: "210mm", height: "50mm", viewBox: "0 0 210 50" do
16
- css STYLE
17
-
18
- rect id: "frame", width: WIDTH, height: HEIGHT, class: "frame"
19
-
20
- layer id: "minors" do
21
- length = 2
22
-
23
- (0..WIDTH).step(1) do |x|
24
- line x1: x, y1: 0, x2: x, y2: length, class: "minors"
25
- line x1: x, y1: HEIGHT, x2: x, y2: HEIGHT - length, class: "minors"
26
- end
27
- end
28
-
29
- layer id: "halves" do
30
- length = 4
31
-
32
- (0..WIDTH).step(5) do |x|
33
- line x1: x, y1: 0, x2: x, y2: length, class: "halves"
34
- line x1: x, y1: HEIGHT, x2: x, y2: HEIGHT - length, class: "halves"
35
- end
36
- end
37
-
38
- layer id: "majors" do
39
- length = 6
40
-
41
- (10..(WIDTH - 10)).step(10) do |x|
42
- line x1: x, y1: 0, x2: x, y2: length, class: "majors"
43
- line x1: x, y1: HEIGHT, x2: x, y2: HEIGHT - length, class: "majors"
44
- end
45
-
46
- layer id: "labels" do
47
- (10..(WIDTH - 10)).step(10).each_with_index do |x, i|
48
- text (i + 1).to_s, "text-anchor": "middle", x:, y: length + 5.5, class: "labels"
49
- end
50
- end
51
- end
52
- end.Save