fit 1.1
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.
- data/README.txt +203 -0
- data/Rakefile +111 -0
- data/bin/FitServer.rb +6 -0
- data/bin/fit +10 -0
- data/bin/fit.cgi +36 -0
- data/doc/examples/AllCombinations.html +55 -0
- data/doc/examples/AllFiles.html +60 -0
- data/doc/examples/AllPairs/function/cosine.html +57 -0
- data/doc/examples/AllPairs/function/sine.html +57 -0
- data/doc/examples/AllPairs/magnitude/180+30.html +45 -0
- data/doc/examples/AllPairs/magnitude/30.html +33 -0
- data/doc/examples/AllPairs/magnitude/360+30.html +45 -0
- data/doc/examples/AllPairs/magnitude/90-30.html +45 -0
- data/doc/examples/AllPairs/sign/change-sign.html +27 -0
- data/doc/examples/AllPairs/sign/multiply.html +31 -0
- data/doc/examples/AllPairs/sign/no-change.html +23 -0
- data/doc/examples/AllPairs.html +51 -0
- data/doc/examples/BinaryChop.html +89 -0
- data/doc/examples/CalculatorExample.html +108 -0
- data/doc/examples/ColumnIndex.html +43 -0
- data/doc/examples/ExampleTests.html +43 -0
- data/doc/examples/FitAcceptanceTests.html +53 -0
- data/doc/examples/GeoCoordinate.html +87 -0
- data/doc/examples/MusicExample.html +143 -0
- data/doc/examples/MusicExampleWithErrors.html +128 -0
- data/doc/examples/NetworkExample.html +47 -0
- data/doc/examples/WebPageExample.html +92 -0
- data/doc/examples/arithmetic.html +211 -0
- data/doc/examples/files/hp35bk.jpg +0 -0
- data/doc/examples/logo.gif +0 -0
- data/doc/fitnesse/FitNesse.RubY.AcceptanceTests.FixtureParameters.html +81 -0
- data/doc/fitnesse/FitNesse.RubY.AcceptanceTests.GracefulFixtureNames.html +87 -0
- data/doc/fitnesse/FitNesse.RubY.AcceptanceTests.GracefulMemberNames.html +73 -0
- data/doc/fitnesse/FitNesse.RubY.AcceptanceTests.ImportFixture.html +61 -0
- data/doc/fitnesse/FitNesse.RubY.AcceptanceTests.WaysToSpecifyaFixtureNamespace.html +81 -0
- data/doc/spec/annotation.html +3833 -0
- data/doc/spec/extensions.html +302 -0
- data/doc/spec/fixtures.html +5181 -0
- data/doc/spec/index.html +947 -0
- data/doc/spec/parse.html +3094 -0
- data/lib/eg/all_combinations.rb +44 -0
- data/lib/eg/all_files.rb +94 -0
- data/lib/eg/all_pairs.rb +172 -0
- data/lib/eg/arithmetic_column_fixture.rb +35 -0
- data/lib/eg/arithmetic_fixture.rb +29 -0
- data/lib/eg/binary_chop.rb +100 -0
- data/lib/eg/calculator.rb +69 -0
- data/lib/eg/column_index.rb +85 -0
- data/lib/eg/division.rb +13 -0
- data/lib/eg/echo_args_fixture.rb +9 -0
- data/lib/eg/example_tests.rb +84 -0
- data/lib/eg/music/Music.txt +38 -0
- data/lib/eg/music/browser.rb +60 -0
- data/lib/eg/music/display.rb +24 -0
- data/lib/eg/music/music.rb +67 -0
- data/lib/eg/music/music_library.rb +70 -0
- data/lib/eg/music/music_player.rb +77 -0
- data/lib/eg/music/realtime.rb +39 -0
- data/lib/eg/music/simulator.rb +81 -0
- data/lib/eg/nested/bob.rb +12 -0
- data/lib/eg/nested/bob_the_builder_fixture.rb +11 -0
- data/lib/eg/net/simulator.rb +69 -0
- data/lib/eg/page.rb +91 -0
- data/lib/eg/sqrt.rb +19 -0
- data/lib/fat/annotation_fixture.rb +83 -0
- data/lib/fat/color.rb +45 -0
- data/lib/fat/divide.rb +13 -0
- data/lib/fat/document_parse_fixture.rb +67 -0
- data/lib/fat/equals.rb +59 -0
- data/lib/fat/fixture_name_fixture.rb +67 -0
- data/lib/fat/html_to_text_fixture.rb +20 -0
- data/lib/fat/money.rb +18 -0
- data/lib/fat/output_fixture.rb +32 -0
- data/lib/fat/parse_fixture.rb +92 -0
- data/lib/fat/reference_fixture.rb +31 -0
- data/lib/fat/standard_annotation_fixture.rb +58 -0
- data/lib/fat/string_writer.rb +12 -0
- data/lib/fat/table.rb +23 -0
- data/lib/fat/table_parse_fixture.rb +33 -0
- data/lib/fat/text_to_html_fixture.rb +21 -0
- data/lib/fit/action_fixture.rb +65 -0
- data/lib/fit/column_fixture.rb +104 -0
- data/lib/fit/file_runner.rb +80 -0
- data/lib/fit/fit_protocol.rb +62 -0
- data/lib/fit/fit_server.rb +173 -0
- data/lib/fit/fixture.rb +309 -0
- data/lib/fit/fixture_loader.rb +75 -0
- data/lib/fit/import_fixture.rb +9 -0
- data/lib/fit/parse.rb +206 -0
- data/lib/fit/primitive_fixture.rb +52 -0
- data/lib/fit/row_fixture.rb +188 -0
- data/lib/fit/scientific_double.rb +70 -0
- data/lib/fit/summary.rb +46 -0
- data/lib/fit/timed_action_fixture.rb +35 -0
- data/lib/fit/type_adapter.rb +95 -0
- data/lib/fit/wiki_runner.rb +15 -0
- data/lib/fittask.rb +184 -0
- data/test/all_tests.rb +13 -0
- data/test/file_runner_test.rb +52 -0
- data/test/fit_server_test.rb +214 -0
- data/test/fixture_loader_test.rb +71 -0
- data/test/fixture_test.rb +41 -0
- data/test/fixtures/fail_fixture.rb +9 -0
- data/test/fixtures/pass_fixture.rb +9 -0
- data/test/framework_test.rb +51 -0
- data/test/parse_test.rb +101 -0
- data/test/row_fixture_test.rb +44 -0
- data/test/scientific_double_test.rb +35 -0
- data/test/type_adapter_test.rb +120 -0
- metadata +165 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Copyright (c) 2002 Cunningham & Cunningham, Inc.
|
|
2
|
+
# Released under the terms of the GNU General Public License version 2 or later.
|
|
3
|
+
|
|
4
|
+
require 'fit/column_fixture'
|
|
5
|
+
|
|
6
|
+
module Eg
|
|
7
|
+
|
|
8
|
+
class ExampleTests < Fit::ColumnFixture
|
|
9
|
+
attr_accessor :file, :wiki
|
|
10
|
+
attr_accessor :tables, :fixture, :run_counts, :input, :footnote
|
|
11
|
+
protected :tables, :tables=, :fixture, :fixture=, :run_counts, :run_counts=
|
|
12
|
+
attr_accessor :footnote, :input
|
|
13
|
+
protected :footnote, :footnote=, :input, :input=
|
|
14
|
+
|
|
15
|
+
def initialize
|
|
16
|
+
@run_counts = Fit::Counts.new
|
|
17
|
+
@footnote = nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def wiki?; @wiki; end
|
|
21
|
+
|
|
22
|
+
def run
|
|
23
|
+
input = File.open("../../examples/#@file") {|f| f.read}
|
|
24
|
+
@fixture = Fit::Fixture.new
|
|
25
|
+
if wiki?
|
|
26
|
+
@tables = Fit::Parse.new input, ['wiki', 'table', 'tr', 'td']
|
|
27
|
+
@fixture.do_tables @tables.parts
|
|
28
|
+
else
|
|
29
|
+
@tables = Fit::Parse.new input, ['table', 'tr', 'td']
|
|
30
|
+
@fixture.do_tables @tables
|
|
31
|
+
end
|
|
32
|
+
@run_counts.tally @fixture.counts
|
|
33
|
+
@summary['counts run'] = @run_counts.to_s
|
|
34
|
+
end
|
|
35
|
+
protected :run
|
|
36
|
+
|
|
37
|
+
# The right method is more complicated than the one in the original
|
|
38
|
+
# Java FIT version because Ruby does not see different methods based
|
|
39
|
+
# on the number of their arguments: here, ExampleTests#right shadows
|
|
40
|
+
# Fixture#right, so it must serve two roles at the same time.
|
|
41
|
+
def right arg0 = nil
|
|
42
|
+
unless arg0.nil?
|
|
43
|
+
super
|
|
44
|
+
else
|
|
45
|
+
run
|
|
46
|
+
@fixture.counts.right
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def ignores
|
|
51
|
+
@fixture.counts.ignores
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def exceptions
|
|
55
|
+
@fixture.counts.exceptions
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Footnote
|
|
59
|
+
|
|
60
|
+
def do_row row
|
|
61
|
+
@file_cell = row.leaf
|
|
62
|
+
super
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# The wrong method is more complicated than the one (two, actually)
|
|
66
|
+
# in the original Java FIT version because Ruby does not see different
|
|
67
|
+
# methods based based on the number of their arguments: here, the
|
|
68
|
+
# method ExampleTests#wrong shadows Fixture#wrong, so it must serve
|
|
69
|
+
# two (three, actually) roles at the same time.
|
|
70
|
+
def wrong cell = nil, actual = nil
|
|
71
|
+
if cell.nil?
|
|
72
|
+
@fixture.counts.wrong
|
|
73
|
+
else
|
|
74
|
+
super
|
|
75
|
+
if @footnote.nil?
|
|
76
|
+
@footnote = @tables.footnote
|
|
77
|
+
@file_cell.add_to_body footnote
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Name Artist Album Genre Size Time Track Number Track Count Year Date
|
|
2
|
+
Akila Toure Kunda The Toure Kunda Collection World 5306074 265 9 10 1996 9/9/02 9:01 AM
|
|
3
|
+
American Tango Weather Report Mysterious Traveller Jazz 4446151 222 2 7 1974 9/7/02 9:26 PM
|
|
4
|
+
Ananas James Taylor Hourglass Pop 6897450 344 5 13 1997 9/7/02 11:47 PM
|
|
5
|
+
Another Grey Morning James Taylor JT Pop 3284199 164 4 12 1977 9/7/02 11:32 PM
|
|
6
|
+
Cellohachi Part 1 Gideon Freudmann Sound Of Distant Deer New Age 4893909 244 4 9 1998 9/8/02 1:27 AM
|
|
7
|
+
Cellohachi Part 2 Gideon Freudmann Sound Of Distant Deer New Age 4303019 215 5 9 1998 9/8/02 1:27 AM
|
|
8
|
+
Cellohachi Part 3 Gideon Freudmann Sound Of Distant Deer New Age 2500570 124 6 9 1998 9/8/02 1:27 AM
|
|
9
|
+
Coolsville Laurie Anderson Strange Angels Alternative 5542243 277 3 10 1989 9/9/02 8:30 AM
|
|
10
|
+
Copperline James Taylor New Moon Shine Pop 5248087 262 1 12 1991 9/7/02 9:52 PM
|
|
11
|
+
Dice Are Rolling Andrew Lloyd Webber Evita Soundtrack 6161383 307 10 13 1979 9/7/02 5:51 PM
|
|
12
|
+
El Vals De Tomas Pepe & The Bottle Blondes Latenight Betty Latin 4889706 244 7 12 2000 9/9/02 12:23 AM
|
|
13
|
+
Guerrilla Toure Kunda The Toure Kunda Collection World 6097588 304 3 10 1996 9/9/02 9:01 AM
|
|
14
|
+
Handy Man James Taylor JT Pop 3976956 198 7 12 1977 9/7/02 11:36 PM
|
|
15
|
+
Hiawatha Laurie Anderson Strange Angels Alternative 8248005 412 10 10 1989 9/9/02 8:30 AM
|
|
16
|
+
High Flying, Adored Andrew Lloyd Webber Evita Soundtrack 4492160 224 2 13 1979 9/7/02 5:30 PM
|
|
17
|
+
I've Got The Blues Lyle Lovett I Love Everybody Country 4272161 213 16 18 1994 9/8/02 8:02 PM
|
|
18
|
+
Licorice Particleboard Gideon Freudmann Hologram Crackers New Age 3306675 165 14 17 1999 9/8/02 12:24 AM
|
|
19
|
+
Mhaire Bruineall Clannad Clannad In Concert Celtic 1656778 82 4 8 1987 9/9/02 1:15 AM
|
|
20
|
+
Muddy River Laurie Anderson Bright Red Alternative 3733522 186 7 14 1994 9/7/02 8:29 PM
|
|
21
|
+
Night In Baghdad Laurie Anderson Bright Red Alternative 4064760 203 12 14 1994 9/7/02 8:38 PM
|
|
22
|
+
Nil Se'n La Clannad Clannad In Concert Celtic 13821475 690 8 8 1987 9/9/02 1:15 AM
|
|
23
|
+
No Woman No Cry Bob Marley Legend Reggae 8552070 427 2 14 1984 9/9/02 12:06 AM
|
|
24
|
+
1. Allegro ma non troppo Emerson Quartet Dvorak Op. 96 Classical 10956970 547 1 8 1986 9/9/02 8:34 AM
|
|
25
|
+
2. Lento Emerson Quartet Dvorak Op. 96 Classical 9336790 466 2 8 1986 9/8/02 12:38 AM
|
|
26
|
+
3. Molto vivace Emerson Quartet Dvorak Op. 96 Classical 4383458 219 3 8 1986 9/8/02 12:38 AM
|
|
27
|
+
4. Finale. Vivace, ma non troppo Emerson Quartet Dvorak Op. 96 Classical 6476928 323 4 8 1986 9/8/02 12:38 AM
|
|
28
|
+
Penguins Lyle Lovett I Love Everybody Country 3025066 151 10 18 1994 9/8/02 7:54 PM
|
|
29
|
+
Rainbow Country Ziggy Marley Jahmekya Reggae 4068927 203 3 16 1991 9/8/02 10:32 PM
|
|
30
|
+
Redemption Song Bob Marley Legend Reggae 4589289 229 11 14 1984 9/9/02 12:23 AM
|
|
31
|
+
Robin Hood Changes His Oil Gideon Freudmann Hologram Crackers New Age 5236082 261 3 17 1999 9/8/02 12:24 AM
|
|
32
|
+
Rumba De 5 Kilos Pepe & The Bottle Blondes Latenight Betty Latin 3661951 182 1 12 2000 9/9/02 12:23 AM
|
|
33
|
+
Sailing To Philadelphia James Taylor October Rose Pop 6581911 328 3 3 2001 9/7/02 10:45 PM
|
|
34
|
+
Scarlet Woman Weather Report Mysterious Traveller Jazz 6880762 343 6 7 1974 9/7/02 9:44 PM
|
|
35
|
+
Sing Sing Sing Pepe & The Bottle Blondes Latenight Betty Latin 4425770 221 11 12 2000 9/9/02 12:23 AM
|
|
36
|
+
Slippery Lettuce Gideon Freudmann Sound Of Distant Deer New Age 5731393 286 2 9 1998 9/8/02 1:27 AM
|
|
37
|
+
Ti Mon Bo Tito Puente Mondobeat World 7878131 393 2 12 1998 9/9/02 8:52 AM
|
|
38
|
+
Zahrafat A Sa'ld Musicians Of The Nile Mondobeat World 8546887 427 6 12 1998 9/9/02 8:54 AM
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Copyright (c) 2002 Cunningham & Cunningham, Inc.
|
|
2
|
+
# Released under the terms of the GNU General Public License version 2 or later.
|
|
3
|
+
|
|
4
|
+
require 'fit/fixture'
|
|
5
|
+
require 'eg/music/music_library'
|
|
6
|
+
require 'eg/music/music_player'
|
|
7
|
+
|
|
8
|
+
module Eg
|
|
9
|
+
module Music
|
|
10
|
+
|
|
11
|
+
class Browser < Fit::Fixture
|
|
12
|
+
|
|
13
|
+
# Library
|
|
14
|
+
|
|
15
|
+
def library path
|
|
16
|
+
filename = path[path.rindex('/')..-1]
|
|
17
|
+
MusicLibrary.load File.join(File.dirname(__FILE__), filename)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def total_songs
|
|
21
|
+
MusicLibrary.library.size
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Select details
|
|
25
|
+
|
|
26
|
+
def playing; MusicPlayer.playing.title; end
|
|
27
|
+
|
|
28
|
+
def select index
|
|
29
|
+
MusicLibrary.select MusicLibrary.library[index - 1]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def title; MusicLibrary.looking.title; end
|
|
33
|
+
def artist; MusicLibrary.looking.artist; end
|
|
34
|
+
def album; MusicLibrary.looking.album; end
|
|
35
|
+
def year; MusicLibrary.looking.year; end
|
|
36
|
+
def time; MusicLibrary.looking.time; end
|
|
37
|
+
def track; MusicLibrary.looking.track; end
|
|
38
|
+
|
|
39
|
+
# Search buttons
|
|
40
|
+
|
|
41
|
+
def same_album; MusicLibrary.find_album(MusicLibrary.looking.album); end
|
|
42
|
+
def same_artist; MusicLibrary.find_artist(MusicLibrary.looking.artist); end
|
|
43
|
+
def same_genre; MusicLibrary.find_genre(MusicLibrary.looking.genre); end
|
|
44
|
+
def same_year; MusicLibrary.find_year(MusicLibrary.looking.year); end
|
|
45
|
+
|
|
46
|
+
def selected_songs; MusicLibrary.display_count; end
|
|
47
|
+
|
|
48
|
+
def show_all; MusicLibrary.find_all; end
|
|
49
|
+
|
|
50
|
+
# Play buttons
|
|
51
|
+
|
|
52
|
+
def play; MusicPlayer.play(MusicLibrary.looking); end
|
|
53
|
+
def pause; MusicPlayer.pause; end
|
|
54
|
+
def status; Music.status; end
|
|
55
|
+
def remaining; MusicPlayer.minutes_remaining; end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Copyright (c) 2002 Cunningham & Cunningham, Inc.
|
|
2
|
+
# Released under the terms of the GNU General Public License version 2 or later.
|
|
3
|
+
|
|
4
|
+
require 'fit/row_fixture'
|
|
5
|
+
|
|
6
|
+
require 'parsedate'
|
|
7
|
+
|
|
8
|
+
module Eg
|
|
9
|
+
module Music
|
|
10
|
+
|
|
11
|
+
class Display < Fit::RowFixture
|
|
12
|
+
def get_target_class; Music; end
|
|
13
|
+
def query; MusicLibrary.display_contents; end
|
|
14
|
+
def parse string, klass
|
|
15
|
+
if klass == Time
|
|
16
|
+
Time.gm(*ParseDate.parsedate(string).compact)
|
|
17
|
+
else
|
|
18
|
+
super
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Copyright (c) 2002 Cunningham & Cunningham, Inc.
|
|
2
|
+
# Released under the terms of the GNU General Public License version 2 or later.
|
|
3
|
+
|
|
4
|
+
require 'parsedate'
|
|
5
|
+
|
|
6
|
+
module Eg
|
|
7
|
+
module Music
|
|
8
|
+
|
|
9
|
+
class Music
|
|
10
|
+
@@status = 'ready'
|
|
11
|
+
attr_accessor :title, :artist, :album, :genre
|
|
12
|
+
attr_accessor :size, :seconds, :track_number, :track_count, :year
|
|
13
|
+
attr_accessor :date, :selected
|
|
14
|
+
def initialize
|
|
15
|
+
@selected = false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Accessors
|
|
19
|
+
|
|
20
|
+
def track
|
|
21
|
+
"#{@track_number} of #{@track_count}"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def time
|
|
25
|
+
(@seconds / 0.6).round / 100.0
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def selected?
|
|
29
|
+
@selected
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def Music.status= value
|
|
33
|
+
@@status = value
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def Music.status; @@status; end
|
|
37
|
+
|
|
38
|
+
# Factory
|
|
39
|
+
def Music.parse s
|
|
40
|
+
m = new
|
|
41
|
+
data = s.split(/\t/)
|
|
42
|
+
m.title = data[0]
|
|
43
|
+
m.artist = data[1]
|
|
44
|
+
m.album = data[2]
|
|
45
|
+
m.genre = data[3]
|
|
46
|
+
m.size = data[4].to_i
|
|
47
|
+
m.seconds = data[5].to_i
|
|
48
|
+
m.track_number = data[6].to_i
|
|
49
|
+
m.track_count = data[7].to_i
|
|
50
|
+
m.year = data[8].to_i
|
|
51
|
+
m.date = Time.gm(*ParseDate.parsedate(data[9]).compact)
|
|
52
|
+
m
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
alias to_string to_s
|
|
56
|
+
@@metadata = { 'title' => String, 'artist' => String, 'album' => String,
|
|
57
|
+
'genre' => String, 'size' => Fixnum, 'seconds' => Fixnum,
|
|
58
|
+
'track_number' => Fixnum, 'track_count' => Fixnum,
|
|
59
|
+
'year' => Fixnum, 'date' => Time, 'track()' => String,
|
|
60
|
+
'time()' => Float, 'to_string()' => String
|
|
61
|
+
}
|
|
62
|
+
def Music.metadata; @@metadata; end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Copyright (c) 2002 Cunningham & Cunningham, Inc.
|
|
2
|
+
# Released under the terms of the GNU General Public License version 2 or later.
|
|
3
|
+
|
|
4
|
+
require 'eg/music/music'
|
|
5
|
+
|
|
6
|
+
module Eg
|
|
7
|
+
module Music
|
|
8
|
+
|
|
9
|
+
class MusicLibrary
|
|
10
|
+
@@library = []
|
|
11
|
+
@@looking = nil
|
|
12
|
+
def MusicLibrary.library
|
|
13
|
+
@@library
|
|
14
|
+
end
|
|
15
|
+
def MusicLibrary.looking
|
|
16
|
+
@@looking
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def MusicLibrary.load name
|
|
20
|
+
music = []
|
|
21
|
+
f = File.new(name)
|
|
22
|
+
f.each_line { |line| music << Music.parse(line) if f.lineno > 1 } # skip column headings
|
|
23
|
+
f.close
|
|
24
|
+
@@library = music
|
|
25
|
+
end
|
|
26
|
+
def MusicLibrary.select music
|
|
27
|
+
@@looking = music
|
|
28
|
+
end
|
|
29
|
+
def MusicLibrary.display_count
|
|
30
|
+
count = 0
|
|
31
|
+
@@library.each {|music| count += music.selected ? 1 : 0}
|
|
32
|
+
count
|
|
33
|
+
end
|
|
34
|
+
def MusicLibrary.display_contents
|
|
35
|
+
displayed = []
|
|
36
|
+
@@library.each {|music| displayed << music if music.selected?}
|
|
37
|
+
displayed
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def MusicLibrary.search seconds
|
|
41
|
+
Music.status = 'searching'
|
|
42
|
+
Simulator.next_search_complete = Simulator.schedule seconds
|
|
43
|
+
end
|
|
44
|
+
def MusicLibrary.search_complete
|
|
45
|
+
Music.status = (MusicPlayer.playing.nil?) ? 'ready': 'playing'
|
|
46
|
+
end
|
|
47
|
+
def MusicLibrary.find_all
|
|
48
|
+
MusicLibrary.search 3.2
|
|
49
|
+
@@library.each {|music| music.selected = true}
|
|
50
|
+
end
|
|
51
|
+
def MusicLibrary.find_artist author
|
|
52
|
+
MusicLibrary.search 2.3
|
|
53
|
+
@@library.each {|music| music.selected = (music.artist == author)}
|
|
54
|
+
end
|
|
55
|
+
def MusicLibrary.find_album album
|
|
56
|
+
MusicLibrary.search 1.1
|
|
57
|
+
@@library.each {|music| music.selected = (music.album == album)}
|
|
58
|
+
end
|
|
59
|
+
def MusicLibrary.find_genre genre
|
|
60
|
+
search 0.2
|
|
61
|
+
@@library.each {|music| music.selected = (music.genre == genre)}
|
|
62
|
+
end
|
|
63
|
+
def MusicLibrary.find_year year
|
|
64
|
+
search 0.8
|
|
65
|
+
@@library.each {|music| music.selected = (music.year == year)}
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Copyright (c) 2002 Cunningham & Cunningham, Inc.
|
|
2
|
+
# Released under the terms of the GNU General Public License version 2 or later.
|
|
3
|
+
|
|
4
|
+
require 'eg/music/simulator'
|
|
5
|
+
require 'eg/music/music_library'
|
|
6
|
+
|
|
7
|
+
module Eg
|
|
8
|
+
module Music
|
|
9
|
+
|
|
10
|
+
class MusicPlayer
|
|
11
|
+
|
|
12
|
+
@@playing = nil
|
|
13
|
+
@@paused = 0
|
|
14
|
+
|
|
15
|
+
def MusicPlayer.playing; @@playing; end
|
|
16
|
+
|
|
17
|
+
# Controls
|
|
18
|
+
|
|
19
|
+
def MusicPlayer.play music
|
|
20
|
+
if @@paused.zero?
|
|
21
|
+
Music.status = 'loading'
|
|
22
|
+
seconds = (music == @@playing) ? 0.3 : 2.5
|
|
23
|
+
Simulator.next_play_started = Simulator.schedule seconds
|
|
24
|
+
else
|
|
25
|
+
Music.status = 'playing'
|
|
26
|
+
Simulator.next_play_complete = Simulator.schedule @@paused
|
|
27
|
+
@@paused = 0
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def MusicPlayer.pause
|
|
32
|
+
Music.status = 'pause'
|
|
33
|
+
if (not @@playing.nil?) and @@paused.zero?
|
|
34
|
+
@@paused = (Simulator.next_play_complete - Simulator.time)
|
|
35
|
+
Simulator.next_play_complete = 0
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def MusicPlayer.stop
|
|
40
|
+
Simulator.next_play_started = 0
|
|
41
|
+
Simulator.next_play_complete = 0
|
|
42
|
+
play_complete
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Status
|
|
46
|
+
|
|
47
|
+
def MusicPlayer.seconds_remaining
|
|
48
|
+
if not @@paused.zero?
|
|
49
|
+
return @@paused
|
|
50
|
+
elsif not @@playing.nil?
|
|
51
|
+
return (Simulator.next_play_complete - Simulator.time)
|
|
52
|
+
else
|
|
53
|
+
return 0
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def MusicPlayer.minutes_remaining
|
|
58
|
+
(MusicPlayer.seconds_remaining / 0.6).ceil / 100.0
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Events
|
|
62
|
+
|
|
63
|
+
def MusicPlayer.play_started
|
|
64
|
+
Music.status = 'playing'
|
|
65
|
+
@@playing = MusicLibrary.looking
|
|
66
|
+
Simulator.next_play_complete = Simulator.schedule @@playing.seconds
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def MusicPlayer.play_complete
|
|
70
|
+
Music.status = 'ready'
|
|
71
|
+
@@playing = nil
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Copyright (c) 2002 Cunningham & Cunningham, Inc.
|
|
2
|
+
# Released under the terms of the GNU General Public License version 2 or later.
|
|
3
|
+
|
|
4
|
+
require 'fit/timed_action_fixture'
|
|
5
|
+
require 'eg/music/simulator'
|
|
6
|
+
|
|
7
|
+
module Eg
|
|
8
|
+
module Music
|
|
9
|
+
|
|
10
|
+
class Realtime < Fit::TimedActionFixture
|
|
11
|
+
def initialize
|
|
12
|
+
super
|
|
13
|
+
@system = Simulator.system
|
|
14
|
+
@system.reset
|
|
15
|
+
end
|
|
16
|
+
def time; Time.at(Simulator.time); end
|
|
17
|
+
def pause; @system.delay(cells.more.text.to_f); end
|
|
18
|
+
def await; system('wait', cells.more); end
|
|
19
|
+
def fail; system('fail', cells.more); end
|
|
20
|
+
def enter
|
|
21
|
+
@system.delay 0.8
|
|
22
|
+
super
|
|
23
|
+
end
|
|
24
|
+
def press
|
|
25
|
+
@system.delay 1.2
|
|
26
|
+
super
|
|
27
|
+
end
|
|
28
|
+
def system prefix, cell
|
|
29
|
+
method_name = Fit::Fixture.camel "#{prefix} #{cell.text}"
|
|
30
|
+
begin
|
|
31
|
+
@system.send(method_name)
|
|
32
|
+
rescue Exception => e
|
|
33
|
+
exception cell, e
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Copyright (c) 2002 Cunningham & Cunningham, Inc.
|
|
2
|
+
# Released under the terms of the GNU General Public License version 2 or later.
|
|
3
|
+
|
|
4
|
+
require 'fit/fixture'
|
|
5
|
+
require 'fit/action_fixture'
|
|
6
|
+
|
|
7
|
+
module Eg
|
|
8
|
+
module Music
|
|
9
|
+
|
|
10
|
+
class Simulator
|
|
11
|
+
@@system = Simulator.new
|
|
12
|
+
@@time = Time.now.to_i
|
|
13
|
+
@@next_search_complete = @@next_play_started = @@next_play_complete = 0
|
|
14
|
+
def Simulator.system
|
|
15
|
+
@@system
|
|
16
|
+
end
|
|
17
|
+
def Simulator.next_search_complete= value
|
|
18
|
+
@@next_search_complete = value
|
|
19
|
+
end
|
|
20
|
+
def Simulator.next_play_started= value
|
|
21
|
+
@@next_play_started = value
|
|
22
|
+
end
|
|
23
|
+
def Simulator.next_play_complete= value
|
|
24
|
+
@@next_play_complete = value
|
|
25
|
+
end
|
|
26
|
+
def Simulator.next_play_complete; @@next_play_complete; end
|
|
27
|
+
def Simulator.time; @@time; end
|
|
28
|
+
def reset
|
|
29
|
+
@@next_search_complete = @@next_play_started = @@next_play_complete = 0
|
|
30
|
+
MusicPlayer.stop
|
|
31
|
+
end
|
|
32
|
+
def next_event bound
|
|
33
|
+
result = bound
|
|
34
|
+
result = sooner result, @@next_search_complete
|
|
35
|
+
result = sooner result, @@next_play_started
|
|
36
|
+
result = sooner result, @@next_play_complete
|
|
37
|
+
result
|
|
38
|
+
end
|
|
39
|
+
def sooner soon, event
|
|
40
|
+
(event > @@time and event < soon) ? event : soon
|
|
41
|
+
end
|
|
42
|
+
def perform
|
|
43
|
+
MusicLibrary.search_complete if @@time == @@next_search_complete
|
|
44
|
+
MusicPlayer.play_started if @@time == @@next_play_started
|
|
45
|
+
MusicPlayer.play_complete if @@time == @@next_play_complete
|
|
46
|
+
end
|
|
47
|
+
def advance future
|
|
48
|
+
while @@time < future
|
|
49
|
+
@@time = next_event future
|
|
50
|
+
perform
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
def Simulator.schedule seconds
|
|
54
|
+
@@time + seconds
|
|
55
|
+
end
|
|
56
|
+
def delay seconds
|
|
57
|
+
advance(Simulator.schedule(seconds))
|
|
58
|
+
end
|
|
59
|
+
def wait_search_complete; advance(@@next_search_complete); end
|
|
60
|
+
def wait_play_started; advance(@@next_play_started); end
|
|
61
|
+
def wait_play_complete; advance(@@next_play_complete); end
|
|
62
|
+
def fail_load_jam
|
|
63
|
+
Fit::ActionFixture.actor = Dialog.new('load jamed', Fit::ActionFixture.actor)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class Dialog < Fit::Fixture
|
|
68
|
+
attr_reader :message
|
|
69
|
+
def initialize message, caller
|
|
70
|
+
super()
|
|
71
|
+
@message = message
|
|
72
|
+
@caller = caller
|
|
73
|
+
end
|
|
74
|
+
def ok
|
|
75
|
+
MusicPlayer.stop if message == 'load jamed'
|
|
76
|
+
Fit::ActionFixture.actor = @caller
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Copyright (c) 2002 Cunningham & Cunningham, Inc.
|
|
2
|
+
# Released under the terms of the GNU General Public License version 2 or later.
|
|
3
|
+
|
|
4
|
+
require 'fit/fixture'
|
|
5
|
+
|
|
6
|
+
module Eg
|
|
7
|
+
module Net
|
|
8
|
+
|
|
9
|
+
class GeoCoordinate
|
|
10
|
+
attr_accessor :lat, :lon
|
|
11
|
+
@@precision = 0.00001
|
|
12
|
+
def initialize lat, lon
|
|
13
|
+
@lat = lat
|
|
14
|
+
@lon = lon
|
|
15
|
+
end
|
|
16
|
+
def GeoCoordinate.parse string
|
|
17
|
+
coordinates = string.downcase.split(/\s*([wWnNsSeE])\s*|\s/).delete_if {|it| it.size.zero?}
|
|
18
|
+
n = [0, 0, 0, 0, 0, 0]
|
|
19
|
+
i = 0
|
|
20
|
+
north = true; east = true
|
|
21
|
+
coordinates.each do |data|
|
|
22
|
+
c = data[0, 1] # pick the first character
|
|
23
|
+
if c.between?('0', '9') or c == '-'
|
|
24
|
+
n[i] = data.to_f
|
|
25
|
+
i += 1
|
|
26
|
+
end
|
|
27
|
+
north = false if c == 's'
|
|
28
|
+
east = false if c == 'w'
|
|
29
|
+
i = 3 if i > 0 and 'nsew'.index(c)
|
|
30
|
+
end
|
|
31
|
+
lat = n[0] + n[1]/60 + n[2]/3600
|
|
32
|
+
lon = n[3] + n[4]/60 + n[5]/3600
|
|
33
|
+
GeoCoordinate.new(north ? lat : -lat, east ? lon : -lon)
|
|
34
|
+
end
|
|
35
|
+
def == object
|
|
36
|
+
return false unless object.kind_of? GeoCoordinate
|
|
37
|
+
return (@lat / @@precision).to_i == (object.lat / @@precision).to_i &&
|
|
38
|
+
(@lon / @@precision).to_i == (object.lon / @@precision).to_i
|
|
39
|
+
end
|
|
40
|
+
def to_s
|
|
41
|
+
"#{@lat > 0 ? 'N' : 'S'}#{@lat.abs} #{@lon > 0 ? 'E' : 'W'}#{@lon.abs}"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class Simulator < Fit::Fixture
|
|
46
|
+
@@metadata = {'coord' => GeoCoordinate}
|
|
47
|
+
def Simulator.metadata; @@metadata; end
|
|
48
|
+
attr_accessor :zip, :nodes
|
|
49
|
+
def initialize
|
|
50
|
+
super
|
|
51
|
+
@nodes = 0
|
|
52
|
+
end
|
|
53
|
+
def coord= value
|
|
54
|
+
@coord = value
|
|
55
|
+
end
|
|
56
|
+
def coord; @coord; end
|
|
57
|
+
def new_city; end;
|
|
58
|
+
def ok; @nodes += 1; end
|
|
59
|
+
def cancel; end;
|
|
60
|
+
def name s; end;
|
|
61
|
+
def population p; end
|
|
62
|
+
def parse string, klass
|
|
63
|
+
return GeoCoordinate.parse(string) if klass == GeoCoordinate
|
|
64
|
+
super
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
end
|