pixelflut 1.0.0 → 1.0.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: b91c341d7ba55f35b968b3a35c31cb4e676b2055c2f86bd6a94e3f5a4847c788
4
- data.tar.gz: 700e3fae41c985852236339eca7381f05d383e55c74e9948b2f7935b2f7bf69e
3
+ metadata.gz: df7b03c15db9310c8b374b0aef1fb328bbf01c82da1d69b657f133081af8d475
4
+ data.tar.gz: bcf596c6c8b92c7645e29c67e409b31ff3cd452798228db177214401a3494877
5
5
  SHA512:
6
- metadata.gz: 68bbebdd53d083cf10e6bc5c76a18b81ac43347f929166d61493a4e8a54b07263f7ae18c1b23eb5c26317a8d02a33aea18f26740c0cb3f9f387338bb4322a2f5
7
- data.tar.gz: c045bd205847f450c924c2e0f2485737af956f6f419e99b78dadd7b8ab101972f0b251bd09eb62bd39024f60c4f00b34830ccf367a718e71395d037696f735ea
6
+ metadata.gz: ba17e1b0ad958f79d284e9156c5f28969c7bca19444f8e59c7c4064fafd130bf3765acdc828a449ab0026fc36e4f04006bb8dcfc9c569bc81ce9db993f14ba44
7
+ data.tar.gz: 95ec9eaa9f0772a71f4de9fa0b2382f83cf11cd34a0985da5d6334454e53db3ee1ad2a8232e9d74450f21cf32c0dfa01b4cc81df1a439a1483d4d4f0768d6e95
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2025 Mike Blumtritt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  A Pixelflut client written in Ruby.
4
4
 
5
+ - Gem: [rubygems.org](https://rubygems.org/gems/pixelflut)
6
+ - Source: [codeberg.org](https://codeberg.org/mblumtritt/pixelflut)
7
+
5
8
  ## Description
6
9
 
7
10
  Based on the idea of a simple server protocol to collaborate on a shared canvas named [Pixelflut](https://cccgoe.de/wiki/Pixelflut) this gem implements a Ruby version of a client.
@@ -10,7 +13,7 @@ This gem is an open experiment. You are welcome to fork or create pull requests
10
13
 
11
14
  ### Installation
12
15
 
13
- Use [Bundler](http://gembundler.com/) to install the gem:
16
+ Use the Ruby package manager to install the gem:
14
17
 
15
18
  ```sh
16
19
  gem install pixelflut
@@ -36,5 +39,4 @@ Options:
36
39
  -t, --threads use threads instead of processes
37
40
  -h, --help print this help
38
41
  -v, --version print version information
39
-
40
42
  ```
data/bin/pxf CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env ruby --jit
2
2
  # frozen_string_literal: true
3
3
 
4
4
  $stdout.sync = $stderr.sync = true
@@ -12,10 +12,12 @@ if ARGV.index('-h') || ARGV.index('--help')
12
12
  --host <address> target host address (default 127.0.0.1)
13
13
  -p, --port <port> target port (default 1234)
14
14
  -c, --connections <count> count of connections (default 4)
15
- -m, --mode <mode> select pixel encoding (TEXT | BIN)
16
- -t, --threads use threads instead of processes
17
15
  -x, --transpose-x <x> transpose image <x> pixels
18
16
  -y, --transpose-y <y> transpose image <y> pixels
17
+ --encode-text encode pixel in text format (default)
18
+ --encode-bin encode pixel in binary format
19
+ --use-processes use seperate processes (default)
20
+ --use-threads use threads instead of processes
19
21
  -h, --help print this help
20
22
  -v, --version print version information
21
23
  HELP
@@ -33,13 +35,13 @@ def die!(msg, code: 1)
33
35
  exit(code)
34
36
  end
35
37
 
36
- die!('argument missing') if ARGV.empty?
38
+ die!("argument missing - try `#{$name} --help`") if ARGV.empty?
37
39
 
38
40
  require_relative('../lib/pixelflut')
39
41
 
40
42
  module Configuration
41
43
  class << self
42
- attr_reader :use_threads
44
+ attr_reader :scheduler
43
45
 
44
46
  def address
45
47
  require_relative('../lib/pixelflut/sender')
@@ -60,10 +62,6 @@ module Configuration
60
62
  def as_uint(value, name)
61
63
  (ret = value.to_i).positive? ? ret : invalid(value, name)
62
64
  end
63
-
64
- def as_mode(value, name)
65
- %w[text bin].include?(v = value.downcase) ? v : invalid(value, name)
66
- end
67
65
  end
68
66
 
69
67
  until ARGV.empty?
@@ -75,16 +73,20 @@ module Configuration
75
73
  when '-c', '--connections'
76
74
  Pixelflut.count = as_uint(ARGV.shift, 'connections')
77
75
  die!("too many connections - #{Pixelflut.count}") if Pixelflut.count > 255
78
- when '-m', '--mode', '--pixel'
79
- Pixelflut.mode = as_mode(ARGV.shift, 'mode')
80
- when '-t', '--use-threads'
81
- @use_threads = true
76
+ when '--encode-text'
77
+ Pixelflut.encoding = 'text'
78
+ when '--encode-bin'
79
+ Pixelflut.encoding = 'bin'
80
+ when '--use-threads'
81
+ @scheduler = :threads
82
+ when '--use-processes'
83
+ @scheduler = :processes
82
84
  when '-x', '--transpose-x'
83
85
  Pixelflut.delta_x = ARGV.shift.to_i
84
86
  when '-y', '--transpose-y'
85
87
  Pixelflut.delta_y = ARGV.shift.to_i
86
88
  else
87
- die!("invalid option - #{arg}") if Pixelflut.file_name
89
+ die!("invalid option - #{arg}") if arg[0] == '-' || Pixelflut.file_name
88
90
  Pixelflut.file_name = arg
89
91
  end
90
92
  end
@@ -92,6 +94,14 @@ module Configuration
92
94
  die!('<image> missing') unless Pixelflut.file_name
93
95
  end
94
96
 
97
+ def use_threads(address, data)
98
+ puts("#{$name}: start #{data.size} threads for #{data.sum(&:size)} bytes")
99
+ Thread.report_on_exception = false
100
+ data.map! { Thread.start { Pixelflut::Sender.send(address, it) } }
101
+ GC.start
102
+ data.each(&:join)
103
+ end
104
+
95
105
  def use_processes(address, data)
96
106
  puts("#{$name}: start #{data.size} processes for #{data.sum(&:size)} bytes")
97
107
  data.size.times do |i|
@@ -99,22 +109,13 @@ def use_processes(address, data)
99
109
  data = data[i]
100
110
  GC.start
101
111
  $name = Process.setproctitle("#{$name}-#{'0' if i < 9}#{i + 1}")
102
- Pixelflut::Sender.send(address, data) do |size|
103
- puts("#{$name}: #{size} bytes")
104
- end
112
+ Pixelflut::Sender.send(address, data) { puts("#{$name}: #{it} bytes") }
105
113
  end
106
- end
107
-
108
- def use_threads(address, data)
109
- puts("#{$name}: start #{data.size} threads for #{data.sum(&:size)} bytes")
110
- Thread.report_on_exception = false
111
- data.map! { |slice| Thread.start { Pixelflut::Sender.send(address, slice) } }
112
114
  GC.start
113
- data.each(&:join)
114
115
  end
115
116
 
116
117
  begin
117
- if Configuration.use_threads
118
+ if Configuration.scheduler == :threads
118
119
  use_threads(Configuration.address, Pixelflut.data)
119
120
  else
120
121
  use_processes(Configuration.address, Pixelflut.data)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pixelflut
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.4'
5
5
  end
data/lib/pixelflut.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Pixelflut
4
4
  class << self
5
- attr_accessor :file_name, :count, :mode, :delta_x, :delta_y
5
+ attr_accessor :file_name, :count, :encoding, :delta_x, :delta_y
6
6
 
7
7
  def data
8
8
  sliced(convert(*load).shuffle!, @count).map!(&:join)
@@ -44,11 +44,8 @@ module Pixelflut
44
44
  end
45
45
 
46
46
  def convert(width, height, blob)
47
- if @mode == 'bin'
48
- to_bin_format(width, height, blob)
49
- else
50
- to_text_format(width, height, blob)
51
- end
47
+ return to_bin_format(width, height, blob) if @encoding == 'bin'
48
+ to_text_format(width, height, blob)
52
49
  end
53
50
 
54
51
  def to_text_format(width, height, blob)
@@ -94,6 +91,6 @@ module Pixelflut
94
91
 
95
92
  @count = ENV['TC'].to_i
96
93
  @count = 4 unless @count.positive?
97
- @mode = 'text'
94
+ @encoding = 'text'
98
95
  @delta_x = @delta_y = 0
99
96
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixelflut
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Blumtritt
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-12-14 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: chunky_png
@@ -28,13 +27,14 @@ description: |
28
27
  Based on the idea of a simple server protocol to collaborate on a shared
29
28
  canvas named [Pixelflut](https://cccgoe.de/wiki/Pixelflut) this gem
30
29
  implements a fast Ruby client version.
31
- email:
32
30
  executables:
33
31
  - pxf
34
32
  extensions: []
35
33
  extra_rdoc_files:
34
+ - LICENSE
36
35
  - README.md
37
36
  files:
37
+ - LICENSE
38
38
  - README.md
39
39
  - bin/pxf
40
40
  - lib/pixelflut.rb
@@ -46,7 +46,6 @@ metadata:
46
46
  source_code_uri: https://github.com/mblumtritt/pixelflut
47
47
  bug_tracker_uri: https://github.com/mblumtritt/pixelflut/issues
48
48
  rubygems_mfa_required: 'true'
49
- post_install_message:
50
49
  rdoc_options: []
51
50
  require_paths:
52
51
  - lib
@@ -61,8 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
60
  - !ruby/object:Gem::Version
62
61
  version: '0'
63
62
  requirements: []
64
- rubygems_version: 3.4.22
65
- signing_key:
63
+ rubygems_version: 3.6.9
66
64
  specification_version: 4
67
65
  summary: A fast Pixelflut client written in Ruby.
68
66
  test_files: []