frappuccino 0.0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ describe "Source" do
4
+ describe "#emit" do
5
+ it "notifies observers" do
6
+ pushed = nil
7
+ source = Object.new.extend(Frappuccino::Source)
8
+ source.add_observer(Observer.new { |value| pushed = value })
9
+ source.emit("EVENT!")
10
+
11
+ assert_equal "EVENT!", pushed, "#emit did not notify observers"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,44 @@
1
+ require 'test_helper'
2
+
3
+ describe Frappuccino::Stream do
4
+ describe "#count" do
5
+ it "returns a Stepper that's value is the current length of the Stream" do
6
+ button = Button.new
7
+ stream = Frappuccino::Stream.new(button)
8
+ count = stream.count
9
+
10
+ assert_equal 0, count.now
11
+
12
+ button.push
13
+ assert_equal 1, count.now
14
+ end
15
+
16
+ it "it only counts matching items if an argument is passed" do
17
+ button = Button.new
18
+ stream = Frappuccino::Stream.new(button)
19
+ count = stream.count(1)
20
+
21
+ assert_equal 0, count.now
22
+
23
+ button.emit(0)
24
+ assert_equal 0, count.now
25
+
26
+ button.emit(1)
27
+ assert_equal 1, count.now
28
+ end
29
+
30
+ it "it only counts the matching item if a block is given" do
31
+ button = Button.new
32
+ stream = Frappuccino::Stream.new(button)
33
+ count = stream.count { |i| i > 1 }
34
+
35
+ assert_equal 0, count.now
36
+
37
+ button.emit(1)
38
+ assert_equal 0, count.now
39
+
40
+ button.emit(5)
41
+ assert_equal 1, count.now
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ describe "take" do
4
+ it "returns a Stream that only contains n elements" do
5
+ button = CounterButton.new
6
+ stream = Frappuccino::Stream.new(button)
7
+ taken_stream = to_array(stream.take(2))
8
+
9
+ 3.times { button.push }
10
+ assert_equal 2, taken_stream.length
11
+ assert_equal [0, 1], taken_stream
12
+ end
13
+ end
@@ -0,0 +1,66 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter do |source_file|
4
+ source_file.filename =~ /test/
5
+ end
6
+ end
7
+
8
+ require 'coveralls'
9
+ Coveralls.wear!
10
+
11
+ require 'minitest/autorun'
12
+
13
+ def to_array(stream)
14
+ pushed = []
15
+ stream.on_value do |value|
16
+ pushed << value
17
+ end
18
+
19
+ pushed
20
+ end
21
+
22
+ class Button
23
+ def push
24
+ emit(:pushed)
25
+ end
26
+ end
27
+
28
+ class PlusOneButton
29
+ def push
30
+ emit(:+)
31
+ end
32
+ end
33
+
34
+ class MinusOneButton
35
+ def push
36
+ emit(:-)
37
+ end
38
+ end
39
+
40
+ class Points
41
+ def POINTS!
42
+ emit(:POINTS!)
43
+ end
44
+ end
45
+
46
+ class CounterButton
47
+ def initialize(ini = 0)
48
+ @count = ini
49
+ end
50
+
51
+ def push
52
+ emit(@count)
53
+ @count += 1
54
+ end
55
+ end
56
+
57
+ class Observer
58
+ def initialize(&blk)
59
+ @block = blk
60
+ end
61
+
62
+ def update(value)
63
+ @block.call(value)
64
+ end
65
+ end
66
+
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ describe "zip" do
4
+ it "returns a stream where the events are tuples of corresponding events" do
5
+ button1 = CounterButton.new(0)
6
+ stream1 = Frappuccino::Stream.new(button1)
7
+ button2 = CounterButton.new(10)
8
+ stream2 = Frappuccino::Stream.new(button2)
9
+
10
+
11
+ zipped_stream = to_array(stream1.zip(stream2))
12
+
13
+ button1.push
14
+ button2.push
15
+ assert_equal [[0, 10]], zipped_stream, "zipped stream did not propagate events correctly"
16
+
17
+ button2.push
18
+ button1.push
19
+ assert_equal [[0, 10], [1, 11]], zipped_stream, "zipped stream did not propagate events correctly"
20
+ end
21
+
22
+ it "returns a stream that buffers the left input stream" do
23
+ button1 = CounterButton.new(0)
24
+ stream1 = Frappuccino::Stream.new(button1)
25
+ button2 = CounterButton.new(10)
26
+ stream2 = Frappuccino::Stream.new(button2)
27
+
28
+ zipped_stream = to_array(stream1.zip(stream2))
29
+
30
+ 2.times do |i|
31
+ button1.push
32
+ assert_equal [], zipped_stream, "zipped stream occurred too early"
33
+ end
34
+
35
+ 2.times do |i|
36
+ button2.push
37
+ assert_equal zipped_stream.length, i + 1, "zipped stream did not occur"
38
+ assert_equal [i, 10 + i], zipped_stream.last, "zipped stream did not occur with correct value"
39
+ end
40
+
41
+ zipped_stream.clear
42
+ end
43
+
44
+ it "returns a stream that buffers the right input stream" do
45
+ button1 = CounterButton.new(0)
46
+ stream1 = Frappuccino::Stream.new(button1)
47
+ button2 = CounterButton.new(10)
48
+ stream2 = Frappuccino::Stream.new(button2)
49
+
50
+ zipped_stream = to_array(stream1.zip(stream2))
51
+
52
+ 2.times do |i|
53
+ button2.push
54
+ assert_equal [], zipped_stream, "zipped stream occurred too early"
55
+ end
56
+
57
+ 2.times do |i|
58
+ button1.push
59
+ assert_equal zipped_stream.length, i + 1, "zipped stream did not occur"
60
+ assert_equal [i, 10 + i], zipped_stream.last, "zipped stream did not occur with correct value"
61
+ end
62
+
63
+ end
64
+ end
metadata CHANGED
@@ -1,59 +1,119 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: frappuccino
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
6
5
  platform: ruby
7
- authors:
8
- - Jesse Ikonen
6
+ authors:
7
+ - Steve Klabnik
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-10-31 00:00:00 +02:00
14
- default_executable:
15
- dependencies: []
16
-
17
- description: Superdumb coffeescript documentation generator
18
- email: jesse.ikonen@gmail.com
19
- executables:
20
- - frappuccino
11
+ date: 2013-06-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A library to do Functional Reactive Programming in Ruby.
42
+ email:
43
+ - steve@steveklabnik.com
44
+ executables: []
21
45
  extensions: []
22
-
23
46
  extra_rdoc_files: []
24
-
25
- files:
47
+ files:
48
+ - .gitignore
49
+ - .travis.yml
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - frappuccino.gemspec
26
55
  - lib/frappuccino.rb
27
- - template/bg.png
28
- - template/index.erb
29
- - bin/frappuccino
30
- has_rdoc: true
31
- homepage: ""
32
- licenses: []
33
-
56
+ - lib/frappuccino/property.rb
57
+ - lib/frappuccino/source.rb
58
+ - lib/frappuccino/stream.rb
59
+ - lib/frappuccino/stream/drop.rb
60
+ - lib/frappuccino/stream/map.rb
61
+ - lib/frappuccino/stream/scan.rb
62
+ - lib/frappuccino/stream/select.rb
63
+ - lib/frappuccino/stream/take.rb
64
+ - lib/frappuccino/stream/zip.rb
65
+ - lib/frappuccino/version.rb
66
+ - test/drop_test.rb
67
+ - test/map_test.rb
68
+ - test/merge_test.rb
69
+ - test/mvp_test.rb
70
+ - test/not_implemented_test.rb
71
+ - test/on_value_test.rb
72
+ - test/property_test.rb
73
+ - test/scan_test.rb
74
+ - test/select_test.rb
75
+ - test/source_test.rb
76
+ - test/stream_test.rb
77
+ - test/take_test.rb
78
+ - test/test_helper.rb
79
+ - test/zip_test.rb
80
+ homepage: https://github.com/steveklabnik/frappuccino
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
34
84
  post_install_message:
35
85
  rdoc_options: []
36
-
37
- require_paths:
86
+ require_paths:
38
87
  - lib
39
- required_ruby_version: !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: "0"
45
- required_rubygems_version: !ruby/object:Gem::Requirement
46
- none: false
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: "0"
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
51
98
  requirements: []
52
-
53
- rubyforge_project: frappuccino
54
- rubygems_version: 1.6.2
99
+ rubyforge_project:
100
+ rubygems_version: 2.0.0
55
101
  signing_key:
56
- specification_version: 3
57
- summary: Superdumb coffeescript documentation generator
58
- test_files: []
59
-
102
+ specification_version: 4
103
+ summary: Functional Reactive Programming in Ruby.
104
+ test_files:
105
+ - test/drop_test.rb
106
+ - test/map_test.rb
107
+ - test/merge_test.rb
108
+ - test/mvp_test.rb
109
+ - test/not_implemented_test.rb
110
+ - test/on_value_test.rb
111
+ - test/property_test.rb
112
+ - test/scan_test.rb
113
+ - test/select_test.rb
114
+ - test/source_test.rb
115
+ - test/stream_test.rb
116
+ - test/take_test.rb
117
+ - test/test_helper.rb
118
+ - test/zip_test.rb
119
+ has_rdoc:
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'frappuccino'
4
-
5
- lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
6
- $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
7
-
8
- Frappuccino.new(ARGV[0], ARGV[1])
Binary file
@@ -1,191 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset=utf-8>
5
- <title>
6
- <%= @title %>
7
- </title>
8
- <style>
9
- html, body {
10
- height: 100%;
11
- width: 100%;
12
- background-image: ('bg.png');
13
- margin: 0px;
14
- padding: 0px;
15
- font-family: Tahoma, Geneva, sans-serif;
16
- color: #181818;
17
- background-image: url(bg.png);
18
- background-repeat: repeat-x;
19
- background-color: #eee;
20
- }
21
-
22
- a {
23
- text-decoration: none;
24
- color: #181818;
25
- }
26
-
27
- aside {
28
- position: fixed;
29
- text-align: left;
30
- width: 10%;
31
- height: 100%;
32
- float: left;
33
- }
34
-
35
- aside div {
36
- text-align: left;
37
- font-size: 30px;
38
- font-weight: bold;
39
- color: #00adee;
40
- border-bottom: 1px solid #7db9e8;
41
- margin-bottom: 20px;
42
- }
43
-
44
- aside ul {
45
- list-style: none;
46
- padding: 0px;
47
- margin: 0px;
48
- width: 100%;
49
- }
50
-
51
- aside ul li {
52
- width: 100%;
53
- margin-left: 6px;
54
- font-size: 14px;
55
- }
56
-
57
- aside ul li a {
58
- color: black;
59
- }
60
-
61
- aside ul li a:hover {
62
- color: black;
63
- }
64
-
65
- section {
66
- float: right;
67
- width: 90%;
68
- }
69
-
70
- .master_box {
71
- -webkit-border-radius: 15px;
72
- padding: 25px;
73
- margin: 50px;
74
- background: white;
75
- /* drop shadow follows (moar info: http://www.css3.info/preview/box-shadow/) */
76
- -moz-border-radius: 15px;
77
- border-radius: 15px;
78
- -moz-box-shadow: 3px 3px 3px rgba(0,0,0,0.2);
79
- -webkit-box-shadow: 3px 3px 3px rgba(0,0,0,0.2);
80
- box-shadow: 3px 3px 3px rgba(0,0,0,0.2);
81
- }
82
-
83
- .box {
84
- -webkit-border-radius: 15px;
85
- padding: 25px;
86
- margin: 50px;
87
- margin-left: 100px;
88
- background: white;
89
- /* drop shadow follows (moar info: http://www.css3.info/preview/box-shadow/) */
90
- -moz-border-radius: 15px;
91
- border-radius: 15px;
92
- -moz-box-shadow: 3px 3px 3px rgba(0,0,0,0.2);
93
- -webkit-box-shadow: 3px 3px 3px rgba(0,0,0,0.2);
94
- box-shadow: 3px 3px 3px rgba(0,0,0,0.2);
95
-
96
- }
97
-
98
- .title {
99
- padding-left: 10px;
100
- font-size: 18px;
101
- font-weight: bold;
102
- border-bottom: 1px solid #7db9e8;
103
- color: #00adee;
104
- }
105
-
106
- .description {
107
- font-size: 14px;
108
- padding: 10px;
109
- }
110
-
111
- .master_title {
112
- padding-left: 10px;
113
- font-size: 22px;
114
- font-weight: bold;
115
- border-bottom: 1px solid #7db9e8;
116
- color: #00adee;
117
- }
118
-
119
- .master_description {
120
- font-size: 15px;
121
- padding: 10px;
122
- }
123
-
124
- footer {
125
- width: 100%;
126
- font-size: 10px;
127
- text-align: center;
128
- }
129
- </style>
130
- <!--[if IE]>
131
- <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
132
- <![endif]-->
133
- </head>
134
- <body>
135
- <!-- descriptions -->
136
- <section>
137
- <% @doctree[:namespaces].each do |key, ns| %>
138
- <a name="<%= ns[:full_namespace] %>"></a>
139
- <div class="master_box">
140
- <div class="master_title">
141
- <%= ns[:full_namespace] %>
142
- <div style="float:right;color:silver;font-size: 14px;font-weight:normal;font-style:italic;">namespace</div>
143
- </div>
144
- <div class="master_description">
145
- <%= ns[:description].gsub!(" ", "&nbsp").gsub!("\n", "<br />") %>
146
- </div>
147
- </div>
148
- <% if ns[:objects] %>
149
- <% ns[:objects].each do |obj| %>
150
- <div class="box">
151
- <div class="title">
152
- <%= "#{ns[:full_namespace]}.#{obj[:object_name]}" %>
153
- <div style="float:right;color:silver;font-size: 12px;font-weight:normal;font-style:italic;">object</div>
154
- </div>
155
- <div class="description">
156
- <%= obj[:description].gsub!(" ", "&nbsp").gsub!("\n", "<br />") %>
157
- </div>
158
- </div>
159
- <% end %>
160
- <% end %>
161
- <% if ns[:functions] %>
162
- <% ns[:functions].sort_by{|fn| fn[:function_name]}.each do |fn| %>
163
- <div class="box">
164
- <div class="title">
165
- <%= "#{ns[:full_namespace]}.#{fn[:function_name]}" %>
166
- <div style="float:right;color:silver;font-size: 12px;font-weight:normal;font-style:italic;">function</div>
167
- </div>
168
- <div class="description">
169
- <%= fn[:description].gsub!(" ", "&nbsp").gsub!("\n", "<br />") %>
170
- </div>
171
- </div>
172
- <% end %>
173
- <% end %>
174
- <div style="margin-bottom: 250px;"></div>
175
- <% end %>
176
- </section>
177
- <!-- complete namespace tree w/ links -->
178
- <aside>
179
- <div><%= @title %></div>
180
- <ul>
181
- <% @doctree[:namespaces].each do |key, value| %>
182
- <li><a href="#<%= key %>">-<%= key %></a></li>
183
- <% end %>
184
- </ul>
185
- </aside>
186
- <div style="clear:both;"></div>
187
- <footer>
188
- documentation was generated by frappuccino
189
- </footer>
190
- </body>
191
- </html>