pixelflut 0.0.13 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/rakefile.rb CHANGED
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
 
3
- task :default do
4
- exec 'rake --tasks'
5
- end
5
+ $stdout.sync = $stderr.sync = true
6
+
7
+ task(:default) { exec 'rake --tasks' }
metadata CHANGED
@@ -1,69 +1,78 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixelflut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Blumtritt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-26 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
- name: gosu
14
+ name: rmagick
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.13.2
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.13.2
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mini-cli
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: 1.16.0
47
+ version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: 1.16.0
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: 12.3.0
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: 12.3.0
68
+ version: '0'
55
69
  description: |
56
- Based on the idea of a simple server protocol to collaborate on a shared canvas named
57
- [Pixel Flut](https://cccgoe.de/wiki/Pixelflut) this gem implements a Ruby version.
58
- email: mike.blumtritt@invision.de
70
+ Based on the idea of a simple server protocol to collaborate on a shared
71
+ canvas named [Pixelflut](https://cccgoe.de/wiki/Pixelflut) this gem
72
+ implements a fast Ruby client version.
73
+ email:
59
74
  executables:
60
75
  - pxf
61
- - pxf-generate
62
- - pxf-server
63
- - pxf-convert
64
- - pxf-help
65
- - pxf-send
66
- - pxf-version
67
76
  - pxf-info
68
77
  extensions: []
69
78
  extra_rdoc_files:
@@ -71,37 +80,21 @@ extra_rdoc_files:
71
80
  files:
72
81
  - ".gitignore"
73
82
  - README.md
74
- - TODO.md
75
83
  - bin/pxf
76
- - bin/pxf-convert
77
- - bin/pxf-generate
78
- - bin/pxf-help
79
84
  - bin/pxf-info
80
- - bin/pxf-send
81
- - bin/pxf-server
82
- - bin/pxf-version
83
85
  - gems.rb
84
86
  - lib/pixelflut.rb
85
- - lib/pixelflut/app.rb
86
- - lib/pixelflut/canvas.rb
87
- - lib/pixelflut/canvas/base.rb
88
- - lib/pixelflut/canvas/buffered.rb
89
- - lib/pixelflut/canvas/streamed.rb
90
- - lib/pixelflut/client.rb
91
- - lib/pixelflut/client/socket.rb
92
- - lib/pixelflut/converter.rb
93
- - lib/pixelflut/server.rb
94
- - lib/pixelflut/server/configuration.rb
95
- - lib/pixelflut/server/connection.rb
96
- - lib/pixelflut/text_image.rb
87
+ - lib/pixelflut/image.rb
88
+ - lib/pixelflut/sender.rb
97
89
  - lib/pixelflut/version.rb
98
90
  - pixelflut.gemspec
99
91
  - rakefile.rb
100
92
  homepage: https://github.com/mblumtritt/pixelflut
101
93
  licenses: []
102
94
  metadata:
103
- issue_tracker: https://github.com/mblumtritt/pixelflut/issues
104
- post_install_message:
95
+ source_code_uri: https://github.com/mblumtritt/pixelflut
96
+ bug_tracker_uri: https://github.com/mblumtritt/pixelflut/issues
97
+ post_install_message:
105
98
  rdoc_options: []
106
99
  require_paths:
107
100
  - lib
@@ -109,15 +102,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
102
  requirements:
110
103
  - - ">="
111
104
  - !ruby/object:Gem::Version
112
- version: 2.5.0
105
+ version: 2.7.2
113
106
  required_rubygems_version: !ruby/object:Gem::Requirement
114
107
  requirements:
115
108
  - - ">="
116
109
  - !ruby/object:Gem::Version
117
- version: 1.3.6
110
+ version: '0'
118
111
  requirements: []
119
- rubygems_version: 3.0.1
120
- signing_key:
112
+ rubygems_version: 3.2.9
113
+ signing_key:
121
114
  specification_version: 4
122
- summary: A Pixelflut server & client tool collection written in Ruby.
115
+ summary: A fast Pixelflut client written in Ruby.
123
116
  test_files: []
data/TODO.md DELETED
@@ -1,11 +0,0 @@
1
- # Pixelflut
2
-
3
- ## Todo
4
-
5
- - [x] limit connections _per IP_
6
- - [x] allow 10 (pixel-)actions per client
7
- - [ ] extend `pxf generate`
8
- - [x] add a pre-processor for images
9
- - [ ] mention the Gosu gem in the README
10
- - [ ] add `pxf info` command to get some server information
11
- - [ ] clarify that `pxf convert` require RMagick
data/bin/pxf-convert DELETED
@@ -1,55 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- def options(cfg)
5
- require 'optparse'
6
- OptionParser.new do |opts|
7
- opts.summary_indent = ' '
8
- opts.banner = 'usage: pxf convert [options] IMAGE'
9
- opts.separator(nil)
10
- opts.separator('valid options:')
11
- opts.on('-x', '--transpose-x X', Integer, 'transpose image X pixels'){ |v| cfg[:offset_x] = v }
12
- opts.on('-y', '--transpose-y Y', Integer, 'transpose image Y pixels'){ |v| cfg[:offset_y] = v }
13
- opts.on('-w', '--width WIDTH', Integer, 'resize the image to given WIDTH'){ |v| cfg[:width] = v }
14
- opts.on('-h', '--height HEIGHT', Integer, 'resize the image to given HEIGHT'){ |v| cfg[:height] = v }
15
- end
16
- end
17
-
18
- def help(short)
19
- puts(options(nil), nil) unless short
20
- puts('Convert given IMAGE file to Pixelflut format.')
21
- exit
22
- end
23
-
24
- def err(msg, code = 1)
25
- $stderr.puts("pxf: #{msg}")
26
- exit(code)
27
- end
28
-
29
- def create_options
30
- {}.tap{ |cfg| options(cfg).parse! }
31
- rescue OptionParser::ParseError => e
32
- err(e)
33
- end
34
-
35
- help(false) if '--help' == ARGV[0]
36
- help(true) if '--short-help' == ARGV[0]
37
- options = create_options
38
- err('too few arguments') if ARGV.empty?
39
- require File.realdirpath('../../lib/pixelflut/converter.rb', __FILE__)
40
- err('unable to load library - RMagick') unless Pixelflut::Converter::AVAIL
41
- require File.realdirpath('../../lib/pixelflut/canvas/streamed.rb', __FILE__)
42
- begin
43
- canvas = Pixelflut::Canvas::Streamed.new($stdout)
44
- canvas.offset_x = options[:offset_x] if options[:offset_x]
45
- canvas.offset_y = options[:offset_y] if options[:offset_y]
46
- ARGV.each do |file_name|
47
- cvt = Pixelflut::Converter.new(file_name)
48
- cvt.resize_to(options[:width], options[:height]) if options[:width]
49
- cvt.draw(canvas)
50
- end
51
- rescue Pixelflut::Converter::Error => e
52
- err(e.message, 2)
53
- rescue Interrupt
54
- exit
55
- end
data/bin/pxf-generate DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- def help(short)
5
- puts('usage: pxf generate FILE [FILE2, ...]', nil) unless short
6
- puts('Execute given generator FILEs.')
7
- end
8
-
9
- def extract_options(args)
10
- files, options = [], {}
11
- while !args.empty?
12
- arg = args.shift
13
- next files << arg unless arg[0] == '-'
14
- next options.merge!(Hash[arg[1..-1].chars.map!{ |c| [c.to_sym, true] }]) unless arg[1] == '-'
15
- options[arg[2..-1].to_sym] = args.shift
16
- end
17
- args[0, 0] = files
18
- options
19
- end
20
-
21
- case ARGV[0]
22
- when '--help'
23
- help(false)
24
- when '--short-help'
25
- help(true)
26
- else
27
- $options = extract_options(ARGV)
28
- require File.realdirpath('../../lib/pixelflut/canvas/streamed.rb', __FILE__)
29
- begin
30
- ARGV.each{ |file| Pixelflut::Canvas::Streamed.new.instance_eval(IO.read(file), file, 0) }
31
- print "QUIT\n"
32
- rescue Interrupt
33
- exit
34
- end
35
- end
data/bin/pxf-help DELETED
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- def help(short)
5
- puts('usage: pxf help COMMAND', nil) unless short
6
- puts('Print help for given COMMAND.')
7
- exit
8
- end
9
-
10
- def err(msg)
11
- $stderr.puts("pxf: #{msg}")
12
- exit(1)
13
- end
14
-
15
- help(false) if ARGV[0] == '--help'
16
- help(true) if ARGV[0] == '--short-help'
17
- root = File.realdirpath('../', __FILE__).freeze
18
- exec(File.join(root, 'pxf')) if ARGV.empty?
19
- ARGV.each do |cmd|
20
- fname = File.join(root, 'pxf-' + cmd)
21
- err("no such command - #{cmd}") unless File.executable?(fname)
22
- system(fname, '--help')
23
- end
data/bin/pxf-send DELETED
@@ -1,44 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- def options(cfg)
5
- require 'optparse'
6
- OptionParser.new do |opts|
7
- opts.summary_indent = ' '
8
- opts.banner = 'usage: pxf send [options] FILE'
9
- opts.separator(nil)
10
- opts.separator('valid options:')
11
- opts.on('-h', '--host HOST', String, 'target host name (default localhost)'){ |v| cfg[:host] = v }
12
- opts.on('-p', '--port PORT', Integer, 'target port (default 1234)'){ |v| cfg[:port] = v }
13
- opts.on('-c', '--connections COUNT', Integer, 'count of connections (default 8)'){ |v| cfg[:count] = v }
14
- end
15
- end
16
-
17
- def help(short)
18
- puts(options(nil), nil) unless short
19
- puts('Send given Pixelflut ASCII file to a server.')
20
- exit
21
- end
22
-
23
- def err(msg, code = 1)
24
- $stderr.puts("pxf: #{msg}")
25
- exit(code)
26
- end
27
-
28
- def create_options
29
- {port: 1234, count: 8}.tap{ |cfg| options(cfg).parse! }
30
- rescue OptionParser::ParseError => e
31
- err(e)
32
- end
33
-
34
- help(false) if '--help' == ARGV[0]
35
- help(true) if '--short-help' == ARGV[0]
36
- options = create_options
37
- require File.realdirpath('../../lib/pixelflut/client.rb', __FILE__)
38
- begin
39
- Pixelflut::Client.new(options[:host], options[:port], ARGF.readlines, options[:count]).run
40
- rescue SystemCallError => e
41
- err(e.message, 2)
42
- rescue Interrupt
43
- exit
44
- end
data/bin/pxf-server DELETED
@@ -1,64 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- def options(cfg)
5
- require 'optparse'
6
- OptionParser.new do |opts|
7
- opts.summary_indent = ' '
8
- opts.banner = 'usage: pxf server [options]'
9
- opts.separator(nil)
10
- opts.separator('valid options:')
11
- opts.on('-b', '--bind ADDR', String, 'bind address') do |v|
12
- cfg.server.host = v
13
- end
14
- opts.on('-p', '--port PORT', Integer, 'bind port(default: 1234)') do |v|
15
- cfg.server.port = v
16
- end
17
- opts.on('-k', '--keep-alive', Float, 'set maximum keep-alive time') do |v|
18
- cfg.server.keep_alive_time = v
19
- end
20
- opts.on('-r', '--read_buffer SIZE', Integer, 'set read buffer size (default: 1024)') do |v|
21
- cfg.server.read_buffer_size = v
22
- end
23
- opts.on('-l', '--peer-limit NUMBER', Integer, 'limit number of connections per peer (default: 8)') do |v|
24
- cfg.server.peer_limit = v
25
- end
26
- opts.on('-c', '--command-limit NUMBER', Integer, 'limit of continious processed commands (default: 10)') do |v|
27
- cfg.server.command_limit = v
28
- end
29
- opts.on('-w', '--width WIDTH', Integer, 'set canvas width (default: 800)') do |v|
30
- cfg.width = v
31
- end
32
- opts.on('-h', '--height HEIGHT', Integer, 'set canvas height (default: 600)') do |v|
33
- cfg.height = v
34
- end
35
- opts.on('-f', '--[no-]fullscreen', 'run in fullscreen mode') do |v|
36
- cfg.fullscreen = v
37
- end
38
- end
39
- end
40
-
41
- def help(short)
42
- puts(options(nil), nil) unless short
43
- puts('Start Pixelflut server.')
44
- exit
45
- end
46
-
47
- help(false) if ARGV[0] == '--help'
48
- help(true) if ARGV[0] == '--short-help'
49
-
50
- def create_configuration
51
- cfg = Pixelflut::App::Configuration.default
52
- options(cfg).parse!
53
- cfg
54
- rescue OptionParser::ParseError => e
55
- $stderr.puts("pxf: #{e}")
56
- exit(1)
57
- end
58
-
59
- begin
60
- require File.realdirpath('../../lib/pixelflut.rb', __FILE__)
61
- Pixelflut::App.run(create_configuration)
62
- rescue Interrupt
63
- exit
64
- end
data/bin/pxf-version DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- def help(short)
5
- puts('usage: pxf version', nil) unless short
6
- puts('Print version information.')
7
- end
8
-
9
- case ARGV[0]
10
- when '--help'
11
- help(false)
12
- when '--short-help'
13
- help(true)
14
- else
15
- require File.realdirpath('../../lib/pixelflut/version.rb', __FILE__).freeze
16
- puts("pxf #{Pixelflut::VERSION}")
17
- end
data/lib/pixelflut/app.rb DELETED
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'gosu'
4
- require_relative 'server'
5
- require_relative 'text_image'
6
-
7
- module Pixelflut
8
- class App < Gosu::Window
9
- Configuration = Struct.new(:width, :height, :fullscreen, :server) do
10
- def self.default
11
- new(nil, nil, false, Server::Configuration.default)
12
- end
13
- end
14
-
15
- def self.run(configuration = Configuration.default)
16
- new(configuration).show
17
- end
18
-
19
- def initialize(configuration)
20
- if configuration.fullscreen
21
- super(configuration.width || Gosu.screen_width, configuration.height || Gosu.screen_height, fullscreen: true)
22
- else
23
- super(configuration.width || 800, configuration.height || 600)
24
- end
25
- Process.setproctitle('pxflut')
26
- @image = TextImage.new(width, height)
27
- @server = Server.new(@image, configuration.server)
28
- log(self.caption = "Pixelflut@#{configuration.server.host}:#{configuration.server.port}")
29
- log(configuration.server)
30
- reset!
31
- end
32
-
33
- def show
34
- @server.run
35
- super
36
- end
37
-
38
- def reset!
39
- @image.clear
40
- log("clean image: #{@image.width}x#{@image.height}")
41
- end
42
-
43
- def update
44
- # self.caption = @image.changes
45
- @draw_image = nil unless @image.changes.zero?
46
- end
47
-
48
- def draw
49
- (@draw_image ||= Gosu::Image.new(@image.changed, tileable: true, retro: true)).draw(0, 0, 0)
50
- end
51
-
52
- def log(*args)
53
- print("[#{Time.now}] ")
54
- puts(*args)
55
- end
56
-
57
- def button_down(id)
58
- return close! if Gosu::Button::KbEscape == id
59
- return reset! if Gosu::Button::KbSpace == id
60
- return log("connections: #{@server.connection_count}") if Gosu::Button::KbC == id
61
- end
62
-
63
- def close
64
- close!
65
- end
66
-
67
- def needs_redraw?
68
- @draw_image.nil?
69
- end
70
-
71
- def needs_cursor?
72
- false
73
- end
74
- end
75
- end
76
-
77
- begin
78
- Pixelflut::App.run
79
- rescue Interrupt
80
- exit
81
- end if __FILE__ == $PROGRAM_NAME