life_game_viewer 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +25 -8
- data/lib/life_game_viewer/version.rb +1 -1
- data/lib/life_game_viewer.rb +13 -3
- metadata +3 -3
data/README.md
CHANGED
@@ -28,7 +28,7 @@ problems running the program.)
|
|
28
28
|
JRuby and Java
|
29
29
|
==============
|
30
30
|
|
31
|
-
This program will only run in [JRuby] [3]
|
31
|
+
This program will only run in [JRuby] [3],which needs the Java Runtime Environment,
|
32
32
|
so you'll need to make sure you have both installed.
|
33
33
|
The easiest way to install and use JRuby is with [rvm] [4], which you
|
34
34
|
can only do with a Unix-like shell. Linux or Mac OS will easily work; for Windows,
|
@@ -40,19 +40,28 @@ you might be able to get it to work with [Cygwin] [5].
|
|
40
40
|
|
41
41
|
This program requires that JRuby be run in 1.9 mode. In JRuby versions 1.7
|
42
42
|
and above, this is the default setting, but for earlier versions
|
43
|
-
you'll have to specify this mode by passing the
|
44
|
-
|
43
|
+
you'll have to specify this mode by passing the _--1.9_ option to JRuby.
|
44
|
+
Here are three ways to do that:
|
45
|
+
|
46
|
+
1) Put the following into your startup
|
45
47
|
shell's initialization file (e.g. .bashrc or .zshrc):
|
46
48
|
|
47
49
|
```
|
48
50
|
export JRUBY_OPTS=--1.9
|
49
51
|
```
|
50
52
|
|
51
|
-
|
53
|
+
2) Execute the above command in your shell
|
54
|
+
|
55
|
+
3) Precede the command with the variable/value setting, e.g.:
|
56
|
+
|
57
|
+
You could do this for just the one command on your command line instead by preceding your JRuby commands with
|
52
58
|
the setting, as in:
|
53
59
|
|
54
60
|
```
|
55
|
-
JRUBY_OPTS=--1.9 jruby
|
61
|
+
JRUBY_OPTS=--1.9 jruby irb # or
|
62
|
+
JRUBY_OPTS=--1.9 jruby # or
|
63
|
+
JRUBY_OPTS=--1.9 jruby irb # or
|
64
|
+
|
56
65
|
```
|
57
66
|
|
58
67
|
|
@@ -75,6 +84,14 @@ You can experiment with different data sets by:
|
|
75
84
|
1) using the clipboard copy and paste feature
|
76
85
|
(see _Reading and Writing Game Data Via the Clipboard_ below)
|
77
86
|
|
87
|
+
2) instantiating a model yourself, e.g.:
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
require 'life_game_viewer'
|
91
|
+
model = SampleLifeModel.create(5,5) { |r,c| r.even? } # as an example
|
92
|
+
LifeGameViewer::Main.view(model)
|
93
|
+
```
|
94
|
+
|
78
95
|
3) (of course) modifying the source code
|
79
96
|
|
80
97
|
|
@@ -86,14 +103,14 @@ In order to do the exercise, you will need to replace the
|
|
86
103
|
[SampleLifeModel] [6] implementation with your own. Your model will need to
|
87
104
|
respond appropriately to the SampleLifeModel's public method names, because
|
88
105
|
they are called by the viewer, but you can implement them any way you
|
89
|
-
want, even using
|
106
|
+
want, even using your MyLifeModel as a minimal adapter to a completely
|
90
107
|
different design. (To take this to the extreme, the model could even
|
91
108
|
be implemented in Java, with a thin JRuby adapter around it; or, as
|
92
109
|
a RESTful web service in any arbitrary language with the adapter
|
93
110
|
making calls to it.)
|
94
111
|
|
95
112
|
A [MyLifeModel] [7] skeleton file is provided in the
|
96
|
-
lib/model directory as a convenient starting point for you.
|
113
|
+
lib/life_game_viewer/model directory as a convenient starting point for you.
|
97
114
|
You can copy this file into your own working area.
|
98
115
|
|
99
116
|
In your program, all you would need to do is to require life_game_viewer
|
@@ -102,7 +119,7 @@ For example:
|
|
102
119
|
|
103
120
|
```ruby
|
104
121
|
require 'life_game_viewer'
|
105
|
-
model =
|
122
|
+
model = MyLifeModel.create(5,5) { |r,c| r.even? } # as an example
|
106
123
|
LifeGameViewer::Main.view(model)
|
107
124
|
```
|
108
125
|
|
data/lib/life_game_viewer.rb
CHANGED
@@ -3,11 +3,21 @@
|
|
3
3
|
|
4
4
|
module LifeGameViewer
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
platform_ok = /java$/ === RUBY_PLATFORM
|
7
|
+
version_ok = ! (/^1.8/ === RUBY_VERSION)
|
8
|
+
|
9
|
+
unless platform_ok
|
10
|
+
raise "This program must be run in JRuby running in 1.9 mode.\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
unless version_ok
|
14
|
+
raise \
|
15
|
+
"""This program must be run in JRuby in 1.9 mode.
|
16
|
+
Make sure the environment variable JRUBY_OPTS is set to include '--1.9'.
|
17
|
+
"""
|
9
18
|
end
|
10
19
|
|
20
|
+
|
11
21
|
require 'java'
|
12
22
|
|
13
23
|
%w(
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: life_game_viewer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.9.
|
5
|
+
version: 0.9.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Keith Bennett
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-12 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Game of Life Viewer written in JRuby using Java Swing
|
15
15
|
email:
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
none: false
|
67
67
|
requirements: []
|
68
68
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.8.
|
69
|
+
rubygems_version: 1.8.15
|
70
70
|
signing_key:
|
71
71
|
specification_version: 3
|
72
72
|
summary: Game of Life Viewer
|