journeta 0.2.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 58914fb52b9c0ff666f210c3b43902562d998ceb
4
+ data.tar.gz: f86a683c47170bfbb08e9126800758ae475c05a6
5
+ SHA512:
6
+ metadata.gz: 9b1ca3e75bcca0bd2f66c6383216f7ec1eedde3cff75bcd325e476540cb345d9921d6087c5170060651cd2199ca191cf1eca61db4a027ce88335d6178f792bd8
7
+ data.tar.gz: de3744b710bae8fdaded942d9efd9d20a01f7633efa86b4c4fc42f17b06530b77dec668d0d8195f0440773a91491066afb6ab3116b5e2929848de9a71c8860c8
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .project
2
+ pkg/
3
+ .DS_Store
data/Rakefile CHANGED
@@ -1,57 +1,13 @@
1
- require 'rubygems'
2
- require 'bundler'
1
+ require "bundler/gem_tasks"
3
2
 
4
- begin
5
- Bundler.setup(:default, :development)
6
- rescue Bundler::BundlerError => e
7
- $stderr.puts e.message
8
- $stderr.puts "Run `bundle install` to install missing gems"
9
- exit e.status_code
10
- end
11
- require 'rake'
12
3
 
13
- require 'jeweler'
14
- Jeweler::Tasks.new do |gem|
15
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
16
- gem.name = "journeta"
17
- gem.homepage = "http://github.com/preston/journeta"
18
- gem.license = "Apache 2.0"
19
- gem.summary = %Q{A zero-configuration-required peer-to-peer (P2P) discovery and communications library for closed networks.}
20
- gem.description = %Q{Journeta is a dirt simple peer discovery and message passing library for processes on the same LAN, requiring no advanced networking knowledge to use. Only core Ruby libraries are required, making the library fairly light. As all data is sent across the wire in YAML form, so any arbitrary Ruby object can be sent to peers, written in any language.}
21
- gem.email = "conmotto@gmail.com"
22
- gem.authors = ["Preston Lee"]
23
- # Include your dependencies below. Runtime dependencies are required when using your gem,
24
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
25
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
26
- # gem.add_development_dependency 'rspec', '> 1.2.3'
27
- end
28
- Jeweler::RubygemsDotOrgTasks.new
29
4
 
30
5
  require 'rake/testtask'
31
- Rake::TestTask.new(:test) do |test|
32
- test.libs << 'lib' << 'test'
33
- test.pattern = 'test/**/test_*.rb'
34
- test.verbose = true
35
- end
36
-
37
- require 'rcov/rcovtask'
38
- Rcov::RcovTask.new do |test|
39
- test.libs << 'test'
40
- test.pattern = 'test/**/test_*.rb'
41
- test.verbose = true
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.libs << 'lib/sms-easy'
9
+ t.test_files = FileList['test/lib/sms-easy/*_test.rb']
10
+ t.verbose = true
42
11
  end
43
-
12
+
44
13
  task :default => :test
45
-
46
- require 'rake/rdoctask'
47
- Rake::RDocTask.new do |rdoc|
48
- # version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
- require File.dirname(__FILE__) + '/lib/journeta/version'
50
- version =
51
-
52
-
53
- rdoc.rdoc_dir = 'rdoc'
54
- rdoc.title = "journeta #{version}"
55
- rdoc.rdoc_files.include('README*')
56
- rdoc.rdoc_files.include('lib/**/*.rb')
57
- end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts <<EOF
4
+
5
+ Slides for the Journeta P2P lightning talk given Friday, March 18th, 2011
6
+ at MountainWest RubyConf in Salt Lake City, Utah, USA.
7
+
8
+ Author: Preston Lee
9
+ http://prestonlee.com
10
+ https://github.com/preston/journeta
11
+
12
+ EOF
13
+
14
+
15
+
16
+ [
17
+ 'rvm use (1.9.2 || jruby)',
18
+ 'gem install journeta',
19
+ 'get on the "XMission" wifi network"',
20
+ 'run "journeta_network_status.rb" in another tab',
21
+ "warning: it's a public network don't sue me k!",
22
+ "let's write a distributed 'irc'-like client ('journeta_instant_messenger.rb')",
23
+
24
+ ].each_with_index do |l,i| puts "#{i}: #{l}" end
data/journeta.gemspec CHANGED
@@ -1,153 +1,24 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'journeta/version'
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{journeta}
8
- s.version = "0.2.2"
6
+ Gem::Specification.new do |spec|
7
+ spec.authors = ["Preston Lee"]
8
+ spec.email = "preston.lee@prestonlee.com"
9
+ spec.description = %q{Journeta is a dirt simple peer discovery and message passing library for processes on the same LAN, requiring no advanced networking knowledge to use. Only core Ruby libraries are required, making the library fairly light. As all data is sent across the wire in YAML form, so any arbitrary Ruby object can be sent to peers, written in any language.}
10
+ spec.summary = %q{A zero-configuration-required peer-to-peer (P2P) discovery and communications library for closed networks.}
11
+ spec.homepage = "https://github.com/preston/journeta"
9
12
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Preston Lee"]
12
- s.date = %q{2011-03-17}
13
- s.description = %q{Journeta is a dirt simple peer discovery and message passing library for processes on the same LAN, requiring no advanced networking knowledge to use. Only core Ruby libraries are required, making the library fairly light. As all data is sent across the wire in YAML form, so any arbitrary Ruby object can be sent to peers, written in any language.}
14
- s.email = %q{conmotto@gmail.com}
15
- s.executables = ["journeta_instant_messenger.rb", "journeta_mock_peers.rb", "journeta_network_status.rb", "journeta_peer_fuzzer.rb", "journeta_queue_client.rb", "journeta_queue_server.rb", "journeta_thread_leak_check.rb", "journeta_top.rb"]
16
- s.extra_rdoc_files = [
17
- "LICENSE",
18
- "README.rdoc"
19
- ]
20
- s.files = [
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "HISTORY",
24
- "LICENSE",
25
- "License.txt",
26
- "README.rdoc",
27
- "Rakefile",
28
- "VERSION",
29
- "bin/journeta_instant_messenger.rb",
30
- "bin/journeta_mock_peers.rb",
31
- "bin/journeta_network_status.rb",
32
- "bin/journeta_peer_fuzzer.rb",
33
- "bin/journeta_queue_client.rb",
34
- "bin/journeta_queue_server.rb",
35
- "bin/journeta_thread_leak_check.rb",
36
- "bin/journeta_top.rb",
37
- "broken/journeta_instant_messenger_gui.rb",
38
- "broken/journeta_instant_messenger_shoes.rb",
39
- "journeta.gemspec",
40
- "lib/diff.rb",
41
- "lib/journeta.rb",
42
- "lib/journeta/asynchronous.rb",
43
- "lib/journeta/common/basic_message.rb",
44
- "lib/journeta/common/dummy_peer_handler.rb",
45
- "lib/journeta/common/job.rb",
46
- "lib/journeta/common/shutdown.rb",
47
- "lib/journeta/exception.rb",
48
- "lib/journeta/journeta_engine.rb",
49
- "lib/journeta/logger.rb",
50
- "lib/journeta/peer_connection.rb",
51
- "lib/journeta/peer_handler.rb",
52
- "lib/journeta/peer_listener.rb",
53
- "lib/journeta/peer_registry.rb",
54
- "lib/journeta/presence_broadcaster.rb",
55
- "lib/journeta/presence_listener.rb",
56
- "lib/journeta/presence_message.rb",
57
- "lib/journeta/version.rb",
58
- "rdoc/Array.html",
59
- "rdoc/Diff.html",
60
- "rdoc/Diffable.html",
61
- "rdoc/Journeta.html",
62
- "rdoc/Journeta/Asynchronous.html",
63
- "rdoc/Journeta/Common.html",
64
- "rdoc/Journeta/Common/BasicMessage.html",
65
- "rdoc/Journeta/Common/DummyPeerHandler.html",
66
- "rdoc/Journeta/Common/Job.html",
67
- "rdoc/Journeta/Common/Shutdown.html",
68
- "rdoc/Journeta/DefaultPeerHandler.html",
69
- "rdoc/Journeta/DefaultPeerRegisteredHandler.html",
70
- "rdoc/Journeta/DefaultPeerUnregisteredHandler.html",
71
- "rdoc/Journeta/DefaultPeerUpdatedHandler.html",
72
- "rdoc/Journeta/Engine.html",
73
- "rdoc/Journeta/Logger.html",
74
- "rdoc/Journeta/NotImplementedException.html",
75
- "rdoc/Journeta/PeerConnection.html",
76
- "rdoc/Journeta/PeerListener.html",
77
- "rdoc/Journeta/PeerRegistry.html",
78
- "rdoc/Journeta/PresenceBroadcaster.html",
79
- "rdoc/Journeta/PresenceListener.html",
80
- "rdoc/Journeta/PresenceMessage.html",
81
- "rdoc/Journeta/VERSION.html",
82
- "rdoc/README_rdoc.html",
83
- "rdoc/String.html",
84
- "rdoc/created.rid",
85
- "rdoc/index.html",
86
- "rdoc/lib/diff_rb.html",
87
- "rdoc/lib/journeta/asynchronous_rb.html",
88
- "rdoc/lib/journeta/common/basic_message_rb.html",
89
- "rdoc/lib/journeta/common/dummy_peer_handler_rb.html",
90
- "rdoc/lib/journeta/common/job_rb.html",
91
- "rdoc/lib/journeta/common/shutdown_rb.html",
92
- "rdoc/lib/journeta/exception_rb.html",
93
- "rdoc/lib/journeta/journeta_engine_rb.html",
94
- "rdoc/lib/journeta/logger_rb.html",
95
- "rdoc/lib/journeta/peer_connection_rb.html",
96
- "rdoc/lib/journeta/peer_handler_rb.html",
97
- "rdoc/lib/journeta/peer_listener_rb.html",
98
- "rdoc/lib/journeta/peer_registry_rb.html",
99
- "rdoc/lib/journeta/presence_broadcaster_rb.html",
100
- "rdoc/lib/journeta/presence_listener_rb.html",
101
- "rdoc/lib/journeta/presence_message_rb.html",
102
- "rdoc/lib/journeta/version_rb.html",
103
- "rdoc/lib/journeta_rb.html",
104
- "rdoc/rdoc.css",
105
- "scripts/txt2html",
106
- "setup.rb",
107
- "test/helper.rb",
108
- "test/test_lifecycle.rb",
109
- "website/images/arrow.png",
110
- "website/images/banner.jpg",
111
- "website/images/content_shadow.png",
112
- "website/images/content_side.png",
113
- "website/images/header.jpg",
114
- "website/images/header_side.jpg",
115
- "website/index.html",
116
- "website/index.txt",
117
- "website/javascripts/rounded_corners_lite.inc.js",
118
- "website/stylesheets/reset.css",
119
- "website/stylesheets/screen.css",
120
- "website/template.rhtml"
121
- ]
122
- s.homepage = %q{http://github.com/preston/journeta}
123
- s.licenses = ["Apache 2.0"]
124
- s.require_paths = ["lib"]
125
- s.rubygems_version = %q{1.6.2}
126
- s.summary = %q{A zero-configuration-required peer-to-peer (P2P) discovery and communications library for closed networks.}
127
- s.test_files = [
128
- "test/helper.rb",
129
- "test/test_lifecycle.rb"
130
- ]
13
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
+ spec.files = `git ls-files`.split("\n")
15
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ spec.name = "journeta"
17
+ spec.require_paths = ["lib"]
18
+ spec.licenses = ["Apache 2.0"]
19
+ spec.version = Journeta::VERSION
131
20
 
132
- if s.respond_to? :specification_version then
133
- s.specification_version = 3
134
-
135
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
136
- s.add_development_dependency(%q<shoulda>, [">= 2.11.3"])
137
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
138
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
139
- s.add_development_dependency(%q<rcov>, [">= 0.9.9"])
140
- else
141
- s.add_dependency(%q<shoulda>, [">= 2.11.3"])
142
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
143
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
144
- s.add_dependency(%q<rcov>, [">= 0.9.9"])
145
- end
146
- else
147
- s.add_dependency(%q<shoulda>, [">= 2.11.3"])
148
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
149
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
150
- s.add_dependency(%q<rcov>, [">= 0.9.9"])
151
- end
21
+ spec.add_development_dependency 'curses', '>= 1.0.1'
22
+ spec.add_development_dependency 'bundler', '>= 1.7.3'
23
+ spec.add_development_dependency 'rake', '10.3.2'
152
24
  end
153
-
@@ -1,11 +1,3 @@
1
- module Journeta #:nodoc:
2
- module VERSION #:nodoc:
3
-
4
- STRING = File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION'))
5
-
6
- MAJOR = STRING.split('.')[0]
7
- MINOR = STRING.split('.')[1]
8
- TINY = STRING.split('.')[2]
9
-
10
- end
1
+ module Journeta
2
+ VERSION = '1.0.0'
11
3
  end
metadata CHANGED
@@ -1,67 +1,67 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: journeta
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.2.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Preston Lee
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-03-17 00:00:00 -07:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: shoulda
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
11
+ date: 2014-10-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: curses
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
21
17
  - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 2.11.3
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.1
24
20
  type: :development
25
21
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.1
27
+ - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ~>
33
- - !ruby/object:Gem::Version
34
- version: 1.0.0
35
- type: :development
36
- prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: jeweler
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.5.2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.7.3
46
34
  type: :development
47
35
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: rcov
51
- requirement: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
54
38
  - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 0.9.9
39
+ - !ruby/object:Gem::Version
40
+ version: 1.7.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 10.3.2
57
48
  type: :development
58
49
  prerelease: false
59
- version_requirements: *id004
60
- description: Journeta is a dirt simple peer discovery and message passing library for processes on the same LAN, requiring no advanced networking knowledge to use. Only core Ruby libraries are required, making the library fairly light. As all data is sent across the wire in YAML form, so any arbitrary Ruby object can be sent to peers, written in any language.
61
- email: conmotto@gmail.com
62
- executables:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 10.3.2
55
+ description: Journeta is a dirt simple peer discovery and message passing library
56
+ for processes on the same LAN, requiring no advanced networking knowledge to use.
57
+ Only core Ruby libraries are required, making the library fairly light. As all data
58
+ is sent across the wire in YAML form, so any arbitrary Ruby object can be sent to
59
+ peers, written in any language.
60
+ email: preston.lee@prestonlee.com
61
+ executables:
63
62
  - journeta_instant_messenger.rb
64
63
  - journeta_mock_peers.rb
64
+ - journeta_mwrc_slides.rb
65
65
  - journeta_network_status.rb
66
66
  - journeta_peer_fuzzer.rb
67
67
  - journeta_queue_client.rb
@@ -69,29 +69,23 @@ executables:
69
69
  - journeta_thread_leak_check.rb
70
70
  - journeta_top.rb
71
71
  extensions: []
72
-
73
- extra_rdoc_files:
74
- - LICENSE
75
- - README.rdoc
76
- files:
77
- - Gemfile
78
- - Gemfile.lock
72
+ extra_rdoc_files: []
73
+ files:
74
+ - ".gitignore"
79
75
  - HISTORY
80
76
  - LICENSE
81
77
  - License.txt
82
78
  - README.rdoc
83
79
  - Rakefile
84
- - VERSION
85
80
  - bin/journeta_instant_messenger.rb
86
81
  - bin/journeta_mock_peers.rb
82
+ - bin/journeta_mwrc_slides.rb
87
83
  - bin/journeta_network_status.rb
88
84
  - bin/journeta_peer_fuzzer.rb
89
85
  - bin/journeta_queue_client.rb
90
86
  - bin/journeta_queue_server.rb
91
87
  - bin/journeta_thread_leak_check.rb
92
88
  - bin/journeta_top.rb
93
- - broken/journeta_instant_messenger_gui.rb
94
- - broken/journeta_instant_messenger_shoes.rb
95
89
  - journeta.gemspec
96
90
  - lib/diff.rb
97
91
  - lib/journeta.rb
@@ -174,37 +168,31 @@ files:
174
168
  - website/stylesheets/reset.css
175
169
  - website/stylesheets/screen.css
176
170
  - website/template.rhtml
177
- has_rdoc: true
178
- homepage: http://github.com/preston/journeta
179
- licenses:
171
+ homepage: https://github.com/preston/journeta
172
+ licenses:
180
173
  - Apache 2.0
174
+ metadata: {}
181
175
  post_install_message:
182
176
  rdoc_options: []
183
-
184
- require_paths:
177
+ require_paths:
185
178
  - lib
186
- required_ruby_version: !ruby/object:Gem::Requirement
187
- none: false
188
- requirements:
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
189
181
  - - ">="
190
- - !ruby/object:Gem::Version
191
- hash: -4144825528497460317
192
- segments:
193
- - 0
194
- version: "0"
195
- required_rubygems_version: !ruby/object:Gem::Requirement
196
- none: false
197
- requirements:
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
198
186
  - - ">="
199
- - !ruby/object:Gem::Version
200
- version: "0"
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
201
189
  requirements: []
202
-
203
190
  rubyforge_project:
204
- rubygems_version: 1.6.2
191
+ rubygems_version: 2.2.2
205
192
  signing_key:
206
- specification_version: 3
207
- summary: A zero-configuration-required peer-to-peer (P2P) discovery and communications library for closed networks.
208
- test_files:
193
+ specification_version: 4
194
+ summary: A zero-configuration-required peer-to-peer (P2P) discovery and communications
195
+ library for closed networks.
196
+ test_files:
209
197
  - test/helper.rb
210
198
  - test/test_lifecycle.rb
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- group :development do
4
- gem "shoulda", ">= 2.11.3"
5
- gem "bundler", "~> 1.0.0"
6
- gem "jeweler", "~> 1.5.2"
7
- gem "rcov", ">= 0.9.9"
8
- end
data/Gemfile.lock DELETED
@@ -1,20 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- git (1.2.5)
5
- jeweler (1.5.2)
6
- bundler (~> 1.0.0)
7
- git (>= 1.2.5)
8
- rake
9
- rake (0.8.7)
10
- rcov (0.9.9)
11
- shoulda (2.11.3)
12
-
13
- PLATFORMS
14
- ruby
15
-
16
- DEPENDENCIES
17
- bundler (~> 1.0.0)
18
- jeweler (~> 1.5.2)
19
- rcov (>= 0.9.9)
20
- shoulda (>= 2.11.3)
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.2
@@ -1,164 +0,0 @@
1
- #!/usr/bin/env ruby
2
- current_dir = File.dirname(File.expand_path(__FILE__))
3
- lib_path = File.join(current_dir, '..', 'lib')
4
- $LOAD_PATH.unshift lib_path
5
-
6
- puts 'A GUI instant messenger demo which can also talk to the command-line version! (Requires the "wxruby" gem.)'
7
- # Load up the library!
8
- require 'journeta'
9
- include Journeta
10
- include Journeta::Common
11
-
12
-
13
- # Use UTF-8.
14
- $KCODE = 'u'
15
-
16
- # Library to get character lengths (as opposed to byte lengths) from Ruby strings.
17
- require 'jcode'
18
-
19
- # Load the wxruby GUI library.
20
- require 'wx'
21
-
22
- class JournetaGUIHandler
23
-
24
- def initialize(control)
25
- @control = control
26
- end
27
-
28
- def call(message)
29
- if message.class == BasicMessage
30
- text = @control.get_value
31
- text.chop!
32
- text += "\n#{message.name.chop}: #{message.text}"
33
- @control.set_value text
34
- else
35
- putsd("Unsupported message type received from peer. (#{message})")
36
- end
37
- end
38
- end
39
-
40
-
41
- class PeerTextControl < Wx::TextCtrl
42
-
43
- DEFAULT_TEXT = "(joined chat at #{Time.now})\n\n"
44
-
45
- def initialize(parent, text = DEFAULT_TEXT)
46
- super(parent, -1, text,
47
- Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::TE_MULTILINE)
48
- end
49
-
50
- end
51
-
52
- # A read-only text ctrl useful for displaying output
53
- class MessageTextControl < Wx::TextCtrl
54
- STYLE = Wx::TE_READONLY|Wx::TE_MULTILINE
55
- def initialize(parent)
56
- super(parent, -1, '', Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, STYLE)
57
- end
58
- end
59
-
60
- class IConvFrame < Wx::Frame
61
-
62
- @name = 'anonymous'
63
-
64
- # Ruby stdlib for converting strings between encodings
65
- begin
66
- require 'iconv'
67
- ICONV_LOADED = 1
68
- rescue LoadError
69
- end
70
-
71
-
72
-
73
- def initialize(title, pos, size)
74
- super(nil, -1, title, pos, size)
75
- panel = Wx::Panel.new(self)
76
-
77
- # TODO Ask user for name.
78
- dialog = Wx::TextEntryDialog.new(self, "What's your name?",
79
- "Please enter text",
80
- "anonymous",
81
- Wx::OK ,
82
- Wx::DEFAULT_POSITION)
83
- dialog.show_modal
84
- @name = dialog.get_value
85
-
86
- sizer = Wx::BoxSizer.new(Wx::VERTICAL)
87
-
88
- # The text input and display
89
- @peer_control = PeerTextControl.new(panel)
90
- sizer.add(@peer_control, 3, Wx::GROW|Wx::ALL, 2)
91
- @peer_control.set_editable(false)
92
- # TODO set background color so it's obviously read-only.
93
- # @peer_control.set_background_colour('888888')
94
-
95
- @message_control = MessageTextControl.new(panel)
96
- @message_control.set_editable(true)
97
- sizer.add(@message_control, 1, Wx::GROW|Wx::ALL, 2)
98
-
99
- # The button to show what's selected
100
- button = Wx::Button.new(panel, -1, 'Send')
101
- sizer.add(button, 0, Wx::ADJUST_MINSIZE|Wx::ALL, 2 )
102
- evt_button(button.get_id) { | e | on_click(e) }
103
-
104
- panel.set_sizer_and_fit( sizer )
105
-
106
- peer_port = (2048 + rand( 2 ** 8))
107
- @journeta = Journeta::Engine.new(:peer_port => peer_port, :peer_handler => JournetaGUIHandler.new(@peer_control), :groups => ['im_example'])
108
- @journeta.start
109
- end
110
-
111
-
112
- def construct_menus()
113
- menu_bar = Wx::MenuBar.new()
114
-
115
- menu_file = Wx::Menu.new()
116
- menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
117
- evt_menu(Wx::ID_EXIT) { on_quit() }
118
- menu_bar.append(menu_file, "&File")
119
- if self.class.const_defined?(:ICONV_LOADED)
120
- construct_import_export_menus(menu_bar)
121
- end
122
-
123
- menu_help = Wx::Menu.new()
124
- menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
125
- evt_menu(Wx::ID_ABOUT) { on_about() }
126
- menu_bar.append(menu_help, "&Help")
127
-
128
- set_menu_bar(menu_bar)
129
- end
130
-
131
- def on_click(e)
132
- text = @message_control.get_value
133
- msg = BasicMessage.new
134
- msg.name = @name
135
- msg.text = text
136
- @journeta.send_to_known_peers(msg)
137
- @message_control.set_value('')
138
- @peer_control.set_value "#{@peer_control.get_value}\n#{@name}: #{text}"
139
- end
140
-
141
- def on_quit()
142
- @journeta.stop
143
- close(TRUE)
144
- end
145
-
146
- def on_about()
147
- msg = "A GUI demo. Wx version #{Wx::VERSION_STRING}"
148
- Wx::message_box(msg, "About Minimal", Wx::OK|Wx::ICON_INFORMATION, self)
149
- end
150
- end
151
-
152
-
153
- class InstantMessengerApplication < Wx::App
154
-
155
- def on_init()
156
- frame = IConvFrame.new("Journeta Instant Messenger",
157
- Wx::Point.new(50, 50),
158
- Wx::Size.new(450, 450) )
159
-
160
- frame.show(true)
161
- end
162
- end
163
-
164
- InstantMessengerApplication.new().main_loop()
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env ruby
2
- current_dir = File.dirname(File.expand_path(__FILE__))
3
- lib_path = File.join(current_dir, '..', 'lib')
4
- $LOAD_PATH.unshift lib_path
5
-
6
- #require File.dirname(__FILE__) + '/../lib/journeta'
7
- # require 'shoes'
8
-
9
- Shoes.setup do
10
- gem 'journeta'
11
- gem 'hoe'
12
- end
13
-
14
-
15
-
16
- class EditorEvent
17
- attr_accessor :diff
18
- end
19
-
20
- class EditorEventHandler
21
-
22
- def call(event)
23
- if data && data.class == EditorEvent && data.diff.class == Diff
24
- d = event.diff
25
- # @edit_box.text = ''
26
- else
27
- # ignore it
28
- end
29
- end
30
- end
31
-
32
- peer_port = (2048 + rand( 2 ** 8))
33
- @journeta = ::Journeta::Engine.new(:peer_port => peer_port, :peer_handler => EditorEventHandler.new, :groups => ['shoes_editor'])
34
- @journeta.start
35
-
36
- #Shoes.app :title => 'Shoes Instant Messenger' do
37
- #
38
- #
39
- # stack :margin => '20' do
40
- #
41
- # @edit_box = edit_box :width => '100%' do |t|
42
- # pp t
43
- # e = EditorEvent.new
44
- # e.diff = t.text
45
- ## @edit_box2.text = t.text
46
- # end
47
- #
48
- # end
49
- #
50
- #end
51
-
52
- @journeta.stop