pixelflut 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d060b7c6e1888c61141aa6f24fae4e2255f4335d8e63ff8dcf1a8710f6d749a4
4
- data.tar.gz: 81cb2846a78285887dab175ab3cb45bc9dcb4d9b0cf7d01add3d607431d537c5
3
+ metadata.gz: a4b1d4d4f5be08766e694539cf82507427f901f71ae1ec4c5568cec7344d1345
4
+ data.tar.gz: 65d9ebde1aa48a5989c28340d3da137b8d99d3952a85fbfb904ad7af64420df8
5
5
  SHA512:
6
- metadata.gz: d30c42ab6b714404eff2f5dfb3c861c96010266086a497ba2684acb7e6c8ca2b3d79999e41fc10b44fb89a62c1375ed0b68b6da74afa79dfe40cc775c0031d47
7
- data.tar.gz: 58ab45066aeff1c2b1162ff225ba24498a966a7a75caae0219f849695c1cf7d1b997ddbfba605ed118ffea2c9a72a222e666525b2936a618c6563b083b8f4208
6
+ metadata.gz: 377feb36cdde2221e3d6c7739acc9773d771d15cf319e93e379c6f86248189c286af91a25e13acda88fc40e030b956761ffa205215e4bb37ddd9ee64e805e748
7
+ data.tar.gz: 910cd772cedf70ddd4cb01445821ccf360f54d96a3c4076b9845886a0e5e1a232a0b153e640b574e6540c490c77691bd515a6b42bb74ade60f0970e2e201c9f9
data/bin/pxf CHANGED
@@ -1,9 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'mini-cli'
5
- include MiniCli
6
-
7
4
  help <<~end, 'IMAGE'
8
5
  --host ADDRESS target host address
9
6
  -p, --port PORT target port (default 1234)
@@ -16,31 +13,8 @@ help <<~end, 'IMAGE'
16
13
  -h, --help print this help
17
14
  end
18
15
 
19
- Process.setproctitle(name)
20
- $stderr.sync = $stdout.sync = true
21
-
22
- parse_argv do |args|
23
- Struct.new(:host, :port, :count, :bytes, :x, :y, :mode, :scale, :source) do
24
- def to_h
25
- { source: source, x: x, y: y, scale: scale, mode: mode }
26
- end
27
- end.new(
28
- args['ADDRESS'] || '127.0.0.1',
29
- (args['PORT'] || 1234).to_i,
30
- (args['CONN'] || 4).to_i,
31
- args['BYTES'].to_i,
32
- args['X'].to_i,
33
- args['Y'].to_i,
34
- { 'RGBA' => :rgba, 'RGB' => :rgb }[args['MODE']] || :rgbx,
35
- args.key?('SCALE') ? args['SCALE'].to_f : nil,
36
- args['IMAGE']
37
- )
38
- end
39
-
40
16
  main do |opts|
41
- require_relative '../lib/pixelflut'
42
- address = Pixelflut::Sender.address(opts.host, opts.port)
43
- data = create_data(opts)
17
+ data = create_junks(opts)
44
18
  print("spawn #{data.size}")
45
19
  data.size.times do |i|
46
20
  next unless fork
@@ -48,7 +22,7 @@ main do |opts|
48
22
  data = data[i].join
49
23
  GC.start
50
24
  GC.disable
51
- Pixelflut::Sender.send(address, data) { print('.') }
25
+ Pixelflut::Sender.send(opts.address, data) { print('.') }
52
26
  end
53
27
  rescue SocketError => e
54
28
  error(3, e)
@@ -60,8 +34,36 @@ rescue Errno::EPIPE
60
34
  error(2, 'connection lost')
61
35
  end
62
36
 
63
- def create_data(opts)
64
- data = Pixelflut.convert(**opts.to_h)
65
- return Pixelflut.slices(data, count: opts.count) if opts.bytes.zero?
66
- Pixelflut.packages(data, bytes: opts.bytes)
37
+ def create_junks(opts)
38
+ lines = Pixelflut.convert(**opts.to_h)
39
+ return Pixelflut.slices(lines, count: opts.count) if opts.bytes.zero?
40
+ Pixelflut.junks(lines, bytes: opts.bytes)
67
41
  end
42
+
43
+ before do
44
+ $stderr.sync = $stdout.sync = true
45
+ Process.setproctitle(name)
46
+ require_relative('../lib/pixelflut')
47
+ end
48
+
49
+ parse_argv do |args|
50
+ Struct.new(:address, :count, :bytes, :x, :y, :mode, :scale, :source) do
51
+ def to_h
52
+ { source: source, x: x, y: y, scale: scale, mode: mode }
53
+ end
54
+ end.new(
55
+ Pixelflut::Sender.address(
56
+ args['ADDRESS'] || '127.0.0.1',
57
+ (args['PORT'] || 1234).to_i
58
+ ),
59
+ (args['CONN'] || 4).to_i,
60
+ args['BYTES'].to_i,
61
+ args['X'].to_i,
62
+ args['Y'].to_i,
63
+ { 'RGBA' => :rgba, 'RGB' => :rgb }[args['MODE']] || :rgbx,
64
+ args.key?('SCALE') ? args['SCALE'].to_f : nil,
65
+ args['IMAGE']
66
+ )
67
+ end
68
+
69
+ BEGIN { require('mini-cli') and include(MiniCli) }
data/lib/pixelflut.rb CHANGED
@@ -15,9 +15,8 @@ module Pixelflut
15
15
  end
16
16
  end
17
17
 
18
- def packages(lines, bytes:)
19
- ret = [current = []]
20
- size = 0
18
+ def junks(lines, bytes:)
19
+ size, ret = 0, [current = []]
21
20
  lines.each do |line|
22
21
  next current << line if (size += line.bytesize) < bytes
23
22
  ret << (current = [line])
@@ -25,6 +24,7 @@ module Pixelflut
25
24
  end
26
25
  ret
27
26
  end
27
+ alias packages junks # backward compatibility
28
28
 
29
29
  private
30
30
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pixelflut
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
data/pixelflut.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  'https://github.com/mblumtritt/pixelflut/issues'
23
23
 
24
24
  spec.add_runtime_dependency 'rmagick'
25
- spec.add_runtime_dependency 'mini-cli'
25
+ spec.add_runtime_dependency 'mini-cli', '>= 0.4.0'
26
26
  spec.add_development_dependency 'bundler'
27
27
  spec.add_development_dependency 'rake'
28
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixelflut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Blumtritt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-14 00:00:00.000000000 Z
11
+ date: 2021-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.4.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.4.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement