rubyonacid 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/LICENSE +20 -0
- data/README.textile +21 -0
- data/Rakefile +63 -0
- data/VERSION +1 -0
- data/examples/midi.rb +57 -0
- data/examples/permutations.rb +40 -0
- data/examples/raw_audio.rb +54 -0
- data/examples/rinda_agent.rb +81 -0
- data/examples/rmagick.rb +59 -0
- data/examples/test.rb +95 -0
- data/examples/test2.rb +85 -0
- data/examples/test3.rb +108 -0
- data/features/rubyonacid.feature +9 -0
- data/features/step_definitions/rubyonacid_steps.rb +0 -0
- data/features/support/env.rb +4 -0
- data/lib/rubyonacid/factories/constant.rb +25 -0
- data/lib/rubyonacid/factories/flash.rb +32 -0
- data/lib/rubyonacid/factories/increment.rb +32 -0
- data/lib/rubyonacid/factories/loop.rb +30 -0
- data/lib/rubyonacid/factories/meta.rb +31 -0
- data/lib/rubyonacid/factories/modulo.rb +25 -0
- data/lib/rubyonacid/factories/random.rb +15 -0
- data/lib/rubyonacid/factories/repeat.rb +35 -0
- data/lib/rubyonacid/factories/rinda.rb +40 -0
- data/lib/rubyonacid/factories/sine.rb +24 -0
- data/lib/rubyonacid/factories/skip.rb +23 -0
- data/lib/rubyonacid/factory.rb +29 -0
- data/lib/rubyonacid.rb +0 -0
- data/spec/generators/constant_spec.rb +24 -0
- data/spec/generators/flash_spec.rb +49 -0
- data/spec/generators/increment_spec.rb +43 -0
- data/spec/generators/loop_spec.rb +43 -0
- data/spec/generators/meta_spec.rb +20 -0
- data/spec/generators/modulo_spec.rb +33 -0
- data/spec/generators/random_spec.rb +20 -0
- data/spec/generators/repeat_spec.rb +37 -0
- data/spec/generators/rinda_spec.rb +32 -0
- data/spec/generators/sine_spec.rb +43 -0
- data/spec/generators/skip_spec.rb +25 -0
- data/spec/shared_factory_specs.rb +79 -0
- data/spec/spec_helper.rb +9 -0
- metadata +122 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
require 'rubyonacid/factories/modulo'
|
3
|
+
|
4
|
+
include RubyOnAcid
|
5
|
+
|
6
|
+
describe ModuloFactory do
|
7
|
+
|
8
|
+
MARGIN = 0.01
|
9
|
+
|
10
|
+
before :each do
|
11
|
+
@it = ModuloFactory.new
|
12
|
+
end
|
13
|
+
|
14
|
+
it "accumulates values and returns remainder of dividing by 1" do
|
15
|
+
source_factory = mock('Factory')
|
16
|
+
source_factory.should_receive(:get_unit).exactly(3).times.and_return(0.1, 0.35, 0.75)
|
17
|
+
@it.source_factory = source_factory
|
18
|
+
@it.get_unit(:x).should be_close(0.1, MARGIN)
|
19
|
+
@it.get_unit(:x).should be_close(0.45, MARGIN)
|
20
|
+
@it.get_unit(:x).should be_close(0.2, MARGIN) #0.45 + 0.75 == 1.2, 1.2 modulo 1 == 0.2
|
21
|
+
end
|
22
|
+
|
23
|
+
it "Tracks modulos on a per-key basis" do
|
24
|
+
source_factory = mock('Factory')
|
25
|
+
source_factory.should_receive(:get_unit).exactly(4).times.and_return(0.25, 0.9, 0.33, 0.8)
|
26
|
+
@it.source_factory = source_factory
|
27
|
+
@it.get_unit(:x).should be_close(0.25, MARGIN)#== 0.25
|
28
|
+
@it.get_unit(:x).should be_close(0.15, MARGIN)#== 0.15
|
29
|
+
@it.get_unit(:y).should be_close(0.33, MARGIN)#== 0.33
|
30
|
+
@it.get_unit(:x).should be_close(0.95, MARGIN)#== 0.95
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
require "shared_factory_specs"
|
3
|
+
require "rubyonacid/factories/random"
|
4
|
+
|
5
|
+
include RubyOnAcid
|
6
|
+
|
7
|
+
describe RandomFactory do
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@it = RandomFactory.new
|
11
|
+
end
|
12
|
+
|
13
|
+
it_should_behave_like "a factory"
|
14
|
+
|
15
|
+
it "generates random numbers between 0 and 1" do
|
16
|
+
@it.get_unit(:x).should_not == @it.get_unit(:x)
|
17
|
+
@it.get_unit(:x).should_not == @it.get_unit(:x)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
require 'rubyonacid/factories/repeat'
|
3
|
+
|
4
|
+
include RubyOnAcid
|
5
|
+
|
6
|
+
describe RepeatFactory do
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@it = RepeatFactory.new
|
10
|
+
end
|
11
|
+
|
12
|
+
it "Requests a value from the source factory and repeats it a given number of times" do
|
13
|
+
source_factory = mock('Factory')
|
14
|
+
source_factory.should_receive(:get_unit).exactly(3).times.and_return(0.0, 1.0, 0.5)
|
15
|
+
@it.source_factory = source_factory
|
16
|
+
@it.repeat_count = 2
|
17
|
+
@it.get_unit(:x).should == 0.0
|
18
|
+
@it.get_unit(:x).should == 0.0
|
19
|
+
@it.get_unit(:x).should == 1.0
|
20
|
+
@it.get_unit(:x).should == 1.0
|
21
|
+
@it.get_unit(:x).should == 0.5
|
22
|
+
end
|
23
|
+
|
24
|
+
it "Tracks repeats on a per-key basis" do
|
25
|
+
source_factory = mock('Factory')
|
26
|
+
source_factory.should_receive(:get_unit).exactly(4).times.and_return(0.0, 1.0, 0.5, 0.75)
|
27
|
+
@it.source_factory = source_factory
|
28
|
+
@it.repeat_count = 2
|
29
|
+
@it.get_unit(:x).should == 0.0
|
30
|
+
@it.get_unit(:y).should == 1.0
|
31
|
+
@it.get_unit(:x).should == 0.0
|
32
|
+
@it.get_unit(:y).should == 1.0
|
33
|
+
@it.get_unit(:x).should == 0.5
|
34
|
+
@it.get_unit(:y).should == 0.75
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
require "shared_factory_specs"
|
3
|
+
require 'rubyonacid/factories/rinda'
|
4
|
+
|
5
|
+
include RubyOnAcid
|
6
|
+
|
7
|
+
describe RindaFactory do
|
8
|
+
|
9
|
+
MARGIN = 0.01
|
10
|
+
|
11
|
+
before :each do
|
12
|
+
@it = RindaFactory.new
|
13
|
+
uri = "druby://127.0.0.1:9999"
|
14
|
+
@it.uri = uri
|
15
|
+
require 'rinda/rinda'
|
16
|
+
require 'rinda/tuplespace'
|
17
|
+
DRb.start_service
|
18
|
+
DRb.start_service(uri, Rinda::TupleSpace.new)
|
19
|
+
@space = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, @it.uri))
|
20
|
+
end
|
21
|
+
|
22
|
+
it_should_behave_like "a factory"
|
23
|
+
|
24
|
+
it "gets keys from Rinda server" do
|
25
|
+
@it.start_service
|
26
|
+
@space.write([:x, 0.5])
|
27
|
+
@it.get_unit(:x).should == 0.5
|
28
|
+
@space.write([:y, 0.6])
|
29
|
+
@it.get_unit(:x).should == 0.6
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
require "shared_factory_specs"
|
3
|
+
require 'rubyonacid/factories/sine'
|
4
|
+
|
5
|
+
include RubyOnAcid
|
6
|
+
|
7
|
+
describe SineFactory do
|
8
|
+
|
9
|
+
MARGIN = 0.01
|
10
|
+
|
11
|
+
before :each do
|
12
|
+
@it = SineFactory.new
|
13
|
+
end
|
14
|
+
|
15
|
+
it_should_behave_like "a factory"
|
16
|
+
|
17
|
+
it "loops between 0 and 1" do
|
18
|
+
@it.interval = 1.0
|
19
|
+
# @it.get_unit(:x).should be_close(0.500, MARGIN)
|
20
|
+
@it.get_unit(:x).should be_close(0.920, MARGIN)
|
21
|
+
@it.get_unit(:x).should be_close(0.954, MARGIN)
|
22
|
+
@it.get_unit(:x).should be_close(0.570, MARGIN)
|
23
|
+
@it.get_unit(:x).should be_close(0.122, MARGIN)
|
24
|
+
@it.get_unit(:x).should be_close(0.020, MARGIN)
|
25
|
+
@it.get_unit(:x).should be_close(0.360, MARGIN)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "can take a different interval" do
|
29
|
+
@it.interval = 0.5
|
30
|
+
# @it.get_unit(:x).should be_close(0.500, MARGIN)
|
31
|
+
@it.get_unit(:x).should be_close(0.740, MARGIN)
|
32
|
+
@it.get_unit(:x).should be_close(0.920, MARGIN)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "handles multiple keys" do
|
36
|
+
@it.interval = 1.0
|
37
|
+
@it.get_unit(:x).should be_close(0.920, MARGIN)
|
38
|
+
@it.get_unit(:y).should be_close(0.920, MARGIN)
|
39
|
+
@it.get_unit(:x).should be_close(0.954, MARGIN)
|
40
|
+
@it.get_unit(:y).should be_close(0.954, MARGIN)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
require "shared_factory_specs"
|
3
|
+
require 'rubyonacid/factories/skip'
|
4
|
+
|
5
|
+
include RubyOnAcid
|
6
|
+
|
7
|
+
describe SkipFactory do
|
8
|
+
|
9
|
+
MARGIN = 0.01
|
10
|
+
|
11
|
+
before :each do
|
12
|
+
@it = SkipFactory.new
|
13
|
+
end
|
14
|
+
|
15
|
+
it_should_behave_like "a factory"
|
16
|
+
|
17
|
+
it "generates only 0 or 1" do
|
18
|
+
@it.odds = 0.1
|
19
|
+
300.times do
|
20
|
+
[0, 1].should include(@it.get_unit(:x))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'rubyonacid/factory'
|
2
|
+
|
3
|
+
include RubyOnAcid
|
4
|
+
|
5
|
+
shared_examples_for "a factory" do
|
6
|
+
|
7
|
+
describe "#get_unit" do
|
8
|
+
it "returns a value between 0.0 and 1.0 (inclusive) for a key" do
|
9
|
+
value = @it.get_unit(:any_key)
|
10
|
+
value.should_not be_nil
|
11
|
+
value.should >= 0.0
|
12
|
+
value.should <= 1.0
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#within" do
|
17
|
+
it "allows setting a maximum" do
|
18
|
+
@it.within(:any_key, 0.0, 1.0).should <= 1.0
|
19
|
+
@it.within(:any_key, 0.0, 1.5).should <= 1.5
|
20
|
+
@it.within(:any_key, 0.0, 2.0).should <= 2.0
|
21
|
+
@it.within(:any_key, 0.0, 3.0).should <= 3.0
|
22
|
+
@it.within(:any_key, 0.0, 10.0).should <= 10.0
|
23
|
+
@it.within(:any_key, 0.0, 100.0).should <= 100.0
|
24
|
+
@it.within(:any_key, 0.0, 1000.0).should <= 1000.0
|
25
|
+
@it.within(:any_key, 0.0, 10000.0).should <= 10000.0
|
26
|
+
@it.within(:any_key, -2.0, -1.0).should <= -1.0
|
27
|
+
@it.within(:any_key, -10.0, -2.0).should <= -2.0
|
28
|
+
@it.within(:any_key, -100.0, -10.0).should <= -10.0
|
29
|
+
end
|
30
|
+
it "allows setting a minimum" do
|
31
|
+
@it.within(:any_key, 0.0, 1.0).should >= 0.0
|
32
|
+
@it.within(:any_key, 1.5, 2.5).should >= 1.5
|
33
|
+
@it.within(:any_key, 2.0, 10.0).should >= 2.0
|
34
|
+
@it.within(:any_key, 3.0, 20.0).should >= 3.0
|
35
|
+
@it.within(:any_key, 10.0, 30.0).should >= 10.0
|
36
|
+
@it.within(:any_key, 100.0, 100000.0).should >= 100.0
|
37
|
+
@it.within(:any_key, 1000.0, 100000.0).should >= 1000.0
|
38
|
+
@it.within(:any_key, 10000.0, 100000.0).should >= 10000.0
|
39
|
+
@it.within(:any_key, -1.0, 1.0).should >= -1.0
|
40
|
+
@it.within(:any_key, -2.0, 1.0).should >= -2.0
|
41
|
+
@it.within(:any_key, -10.0, 1.0).should >= -10.0
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#get" do
|
46
|
+
it "allows setting a maximum" do
|
47
|
+
@it.get(:a, :max => 2.0).should <= 2.0
|
48
|
+
@it.get(:b, :max => 10.0).should <= 10.0
|
49
|
+
@it.get(:c, :max => 100.0).should <= 100.0
|
50
|
+
@it.get(:d, :max => 1000.0).should <= 1000.0
|
51
|
+
end
|
52
|
+
it "allows setting a minimum" do
|
53
|
+
@it.get(:a, :min => 2.0).should >= 2.0
|
54
|
+
@it.get(:b, :min => -1.0).should >= -1.0
|
55
|
+
@it.get(:c, :min => -100.0).should >= -100.0
|
56
|
+
@it.get(:d, :min => 1000.0).should >= 1000.0
|
57
|
+
end
|
58
|
+
it "uses a default minimum of 0.0" do
|
59
|
+
@it.get(:a).should >= 0.0
|
60
|
+
@it.get(:a, :max => 10.0).should >= 0.0
|
61
|
+
end
|
62
|
+
it "uses a default maximum of 1.0" do
|
63
|
+
@it.get(:a).should <= 1.0
|
64
|
+
@it.get(:a, :min => -1.0).should <= 0.0
|
65
|
+
end
|
66
|
+
it "keeps the minimum and maximum between calls for a given key" do
|
67
|
+
@it.get(:a, :max => 2.0).should <= 2.0
|
68
|
+
10.times do
|
69
|
+
@it.get(:a).should <= 2.0
|
70
|
+
end
|
71
|
+
@it.get(:b, :min => 2.0).should >= 2.0
|
72
|
+
10.times do
|
73
|
+
@it.get(:b).should >= 2.0
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyonacid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jay McGavren
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-19 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: A framework for creating trippy visuals
|
26
|
+
email: jay@mcgavren.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.textile
|
34
|
+
files:
|
35
|
+
- .gitignore
|
36
|
+
- LICENSE
|
37
|
+
- README.textile
|
38
|
+
- Rakefile
|
39
|
+
- VERSION
|
40
|
+
- examples/midi.rb
|
41
|
+
- examples/raw_audio.rb
|
42
|
+
- examples/rmagick.rb
|
43
|
+
- examples/test.rb
|
44
|
+
- features/rubyonacid.feature
|
45
|
+
- features/step_definitions/rubyonacid_steps.rb
|
46
|
+
- features/support/env.rb
|
47
|
+
- lib/rubyonacid.rb
|
48
|
+
- lib/rubyonacid/factories/constant.rb
|
49
|
+
- lib/rubyonacid/factories/flash.rb
|
50
|
+
- lib/rubyonacid/factories/increment.rb
|
51
|
+
- lib/rubyonacid/factories/loop.rb
|
52
|
+
- lib/rubyonacid/factories/meta.rb
|
53
|
+
- lib/rubyonacid/factories/modulo.rb
|
54
|
+
- lib/rubyonacid/factories/random.rb
|
55
|
+
- lib/rubyonacid/factories/repeat.rb
|
56
|
+
- lib/rubyonacid/factories/rinda.rb
|
57
|
+
- lib/rubyonacid/factories/sine.rb
|
58
|
+
- lib/rubyonacid/factories/skip.rb
|
59
|
+
- lib/rubyonacid/factory.rb
|
60
|
+
- spec/generators/constant_spec.rb
|
61
|
+
- spec/generators/flash_spec.rb
|
62
|
+
- spec/generators/increment_spec.rb
|
63
|
+
- spec/generators/loop_spec.rb
|
64
|
+
- spec/generators/meta_spec.rb
|
65
|
+
- spec/generators/modulo_spec.rb
|
66
|
+
- spec/generators/random_spec.rb
|
67
|
+
- spec/generators/repeat_spec.rb
|
68
|
+
- spec/generators/rinda_spec.rb
|
69
|
+
- spec/generators/sine_spec.rb
|
70
|
+
- spec/generators/skip_spec.rb
|
71
|
+
- spec/shared_factory_specs.rb
|
72
|
+
- spec/spec_helper.rb
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: http://github.com/jaymcgavren/rubyonacid
|
75
|
+
licenses: []
|
76
|
+
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options:
|
79
|
+
- --charset=UTF-8
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: "0"
|
87
|
+
version:
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: "0"
|
93
|
+
version:
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project: rubyonacid
|
97
|
+
rubygems_version: 1.3.5
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: A framework for creating trippy visuals
|
101
|
+
test_files:
|
102
|
+
- spec/generators/constant_spec.rb
|
103
|
+
- spec/generators/flash_spec.rb
|
104
|
+
- spec/generators/increment_spec.rb
|
105
|
+
- spec/generators/loop_spec.rb
|
106
|
+
- spec/generators/meta_spec.rb
|
107
|
+
- spec/generators/modulo_spec.rb
|
108
|
+
- spec/generators/random_spec.rb
|
109
|
+
- spec/generators/repeat_spec.rb
|
110
|
+
- spec/generators/rinda_spec.rb
|
111
|
+
- spec/generators/sine_spec.rb
|
112
|
+
- spec/generators/skip_spec.rb
|
113
|
+
- spec/shared_factory_specs.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
- examples/midi.rb
|
116
|
+
- examples/permutations.rb
|
117
|
+
- examples/raw_audio.rb
|
118
|
+
- examples/rinda_agent.rb
|
119
|
+
- examples/rmagick.rb
|
120
|
+
- examples/test.rb
|
121
|
+
- examples/test2.rb
|
122
|
+
- examples/test3.rb
|