pixelflut 1.0.2 → 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: e8019d928da022280882ac14842f29fd955e91741aa33fc9bfa3ca4e9706dc96
4
- data.tar.gz: 0adfa74f15e70a8052555991814b017f86892251ad5e0b4d55b9df74d4063533
3
+ metadata.gz: df7b03c15db9310c8b374b0aef1fb328bbf01c82da1d69b657f133081af8d475
4
+ data.tar.gz: bcf596c6c8b92c7645e29c67e409b31ff3cd452798228db177214401a3494877
5
5
  SHA512:
6
- metadata.gz: ca1a224e787fcb547cde5cb19fe8707cca753b80bfed6b7ed4ec7a762e079f44e3ce93360a416b5d1d973fafece3f0fa7538cc62ae90bb91164905542886aea2
7
- data.tar.gz: cda338e7116fd4a777a068a53c25fab94f69c2173d2ce282498fd4cd395cefb254c9f88e61bd8a86c244e944337b62ae27f2c517c5c3beadfaae439b025b78cc
6
+ metadata.gz: ba17e1b0ad958f79d284e9156c5f28969c7bca19444f8e59c7c4064fafd130bf3765acdc828a449ab0026fc36e4f04006bb8dcfc9c569bc81ce9db993f14ba44
7
+ data.tar.gz: 95ec9eaa9f0772a71f4de9fa0b2382f83cf11cd34a0985da5d6334454e53db3ee1ad2a8232e9d74450f21cf32c0dfa01b4cc81df1a439a1483d4d4f0768d6e95
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Mike Blumtritt
3
+ Copyright (c) 2024-2025 Mike Blumtritt
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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.
@@ -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
@@ -39,7 +41,7 @@ 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.2'
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.2
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: 2024-05-09 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,12 @@ 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:
36
- - README.md
37
34
  - LICENSE
35
+ - README.md
38
36
  files:
39
37
  - LICENSE
40
38
  - README.md
@@ -48,7 +46,6 @@ metadata:
48
46
  source_code_uri: https://github.com/mblumtritt/pixelflut
49
47
  bug_tracker_uri: https://github.com/mblumtritt/pixelflut/issues
50
48
  rubygems_mfa_required: 'true'
51
- post_install_message:
52
49
  rdoc_options: []
53
50
  require_paths:
54
51
  - lib
@@ -63,8 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
60
  - !ruby/object:Gem::Version
64
61
  version: '0'
65
62
  requirements: []
66
- rubygems_version: 3.5.10
67
- signing_key:
63
+ rubygems_version: 3.6.9
68
64
  specification_version: 4
69
65
  summary: A fast Pixelflut client written in Ruby.
70
66
  test_files: []