pixelflut 1.0.4 → 1.0.5

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: df7b03c15db9310c8b374b0aef1fb328bbf01c82da1d69b657f133081af8d475
4
- data.tar.gz: bcf596c6c8b92c7645e29c67e409b31ff3cd452798228db177214401a3494877
3
+ metadata.gz: 72c6df29c81c54b5819636736f404a2179a60fdb9ba3d957fa3b466c54963aae
4
+ data.tar.gz: cdc9fbbbe2c5dffb605429e0a2ba27be38c1411f074e1c883462780723a99176
5
5
  SHA512:
6
- metadata.gz: ba17e1b0ad958f79d284e9156c5f28969c7bca19444f8e59c7c4064fafd130bf3765acdc828a449ab0026fc36e4f04006bb8dcfc9c569bc81ce9db993f14ba44
7
- data.tar.gz: 95ec9eaa9f0772a71f4de9fa0b2382f83cf11cd34a0985da5d6334454e53db3ee1ad2a8232e9d74450f21cf32c0dfa01b4cc81df1a439a1483d4d4f0768d6e95
6
+ metadata.gz: 5fb329f94c5e744dc5b25aaabf85351f5bad4593ecc46331240a5a22ecdcae67ce8ac5e3b496440092953c27d1f789170cd394371a25d5145d1b8c08128f4f45
7
+ data.tar.gz: ac537008fa8257540dac638117e5925a83a5ab4176f35ba30e7e2ad418b890e79ffc29b12fee41d6a83d07de9bea6e64436044dfb37f609307eeaf23c8e1d925
data/bin/pxf CHANGED
@@ -4,36 +4,29 @@
4
4
  $stdout.sync = $stderr.sync = true
5
5
  $name = Process.setproctitle(File.basename(Process.argv0))
6
6
 
7
- if ARGV.index('-h') || ARGV.index('--help')
8
- puts <<~HELP
9
- Usage: #{$name} [options] <png_image>
10
-
11
- Options:
12
- --host <address> target host address (default 127.0.0.1)
13
- -p, --port <port> target port (default 1234)
14
- -c, --connections <count> count of connections (default 4)
15
- -x, --transpose-x <x> transpose image <x> pixels
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
21
- -h, --help print this help
22
- -v, --version print version information
23
- HELP
24
- exit
25
- end
7
+ puts(<<~HELP) || exit if ARGV.index('-h') || ARGV.index('--help')
8
+ Usage: #{$name} [options] <png_image>
9
+
10
+ Options:
11
+ --host <address> target host address (default 127.0.0.1)
12
+ -p, --port <port> target port (default 1234)
13
+ -c, --connections <count> count of connections (default 4)
14
+ -x, --transpose-x <x> transpose image <x> pixels
15
+ -y, --transpose-y <y> transpose image <y> pixels
16
+ --encode-text encode pixel in text format (default)
17
+ --encode-bin encode pixel in binary format
18
+ --use-processes use seperate processes (default)
19
+ --use-threads use threads instead of processes
20
+ -h, --help print this help
21
+ -v, --version print version information
22
+ HELP
26
23
 
27
24
  if ARGV.index('-v') || ARGV.index('--version')
28
25
  require_relative('../lib/pixelflut/version')
29
- puts("#{$name} - Pixelflut v#{Pixelflut::VERSION}")
30
- exit
26
+ puts("#{$name} - Pixelflut v#{Pixelflut::VERSION}") || exit
31
27
  end
32
28
 
33
- def die!(msg, code: 1)
34
- $stderr.puts("#{$name}: #{msg}")
35
- exit(code)
36
- end
29
+ def die!(msg, code: 1) = $stderr.puts("#{$name}: #{msg}") || exit(code)
37
30
 
38
31
  die!("argument missing - try `#{$name} --help`") if ARGV.empty?
39
32
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pixelflut
4
- VERSION = '1.0.4'
4
+ VERSION = '1.0.5'
5
5
  end
data/lib/pixelflut.rb CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Pixelflut
4
4
  class << self
5
- attr_accessor :file_name, :count, :encoding, :delta_x, :delta_y
5
+ attr_accessor :file_name, :encoding, :delta_x, :delta_y
6
+ attr_writer :count
6
7
 
7
- def data
8
- sliced(convert(*load).shuffle!, @count).map!(&:join)
9
- end
8
+ def data = sliced(convert(*load).shuffle!, count).map!(&:join)
9
+ def count = (@count ||= find_suggested_thread_count)
10
10
 
11
11
  private
12
12
 
@@ -87,10 +87,19 @@ module Pixelflut
87
87
  end
88
88
  ret
89
89
  end
90
+
91
+ def find_suggested_thread_count
92
+ count = ENV['TC'].to_i
93
+ return count if count > 0
94
+ begin
95
+ require('etc') unless defined?(Etc)
96
+ Etc.nprocessors
97
+ rescue LoadError
98
+ 4
99
+ end
100
+ end
90
101
  end
91
102
 
92
- @count = ENV['TC'].to_i
93
- @count = 4 unless @count.positive?
94
103
  @encoding = 'text'
95
104
  @delta_x = @delta_y = 0
96
105
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixelflut
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Blumtritt
@@ -53,7 +53,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 2.7.2
56
+ version: '3.0'
57
57
  required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="