blade 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,29 @@
1
+ require "faye/websocket"
2
+ require "useragent"
3
+
4
+ module Blade::Server
5
+ extend self
6
+ include Blade::Component
7
+
8
+ WEBSOCKET_PATH = "/blade/websocket"
9
+
10
+ def start
11
+ Faye::WebSocket.load_adapter("thin")
12
+ Rack::Server.start(app: app, Port: Blade.config.port, server: "thin")
13
+ end
14
+
15
+ def websocket_url(path = "")
16
+ Blade.url(WEBSOCKET_PATH + path)
17
+ end
18
+
19
+ def client
20
+ @client ||= Faye::Client.new(websocket_url)
21
+ end
22
+
23
+ private
24
+ def app
25
+ Rack::Builder.app do
26
+ run Blade::RackAdapter.new
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ class Blade::Session < Blade::Model
2
+ class << self
3
+ def create(attributes)
4
+ model = super
5
+ model.test_results = Blade::TestResults.new(model.id)
6
+ model
7
+ end
8
+
9
+ def combined_test_results
10
+ Blade::CombinedTestResults.new(all)
11
+ end
12
+ end
13
+
14
+ def to_s
15
+ @to_s ||= "#{ua.browser} #{ua.version} #{ua.platform}"
16
+ end
17
+
18
+ private
19
+ def ua
20
+ user_agent
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ require "blade"
2
+ require "minitest/autorun"
3
+
4
+ ActiveSupport.test_order = :random
5
+
6
+ class Blade::TestCase < ActiveSupport::TestCase
7
+ end
@@ -0,0 +1,91 @@
1
+ class Blade::TestResults
2
+ attr_reader :session_id, :status, :lines, :passes, :failures
3
+
4
+ def initialize(session_id)
5
+ @session_id = session_id
6
+ reset
7
+
8
+ Blade.subscribe("/tests") do |details|
9
+ if details["session_id"] == session_id
10
+ process_test_result(details)
11
+ end
12
+ end
13
+ end
14
+
15
+ def reset
16
+ @lines = []
17
+ @passes = []
18
+ @failures = []
19
+ @completed = false
20
+ @status = "pending"
21
+ @total = nil
22
+ end
23
+
24
+ def process_test_result(details)
25
+ publication = {}
26
+
27
+ case details["event"]
28
+ when "begin"
29
+ reset
30
+ @status = "running"
31
+ @total = details["total"]
32
+ @lines << publication[:line] = "1..#{@total}"
33
+ when "result"
34
+ pass = details["result"]
35
+ args = details.values_at("name", "message")
36
+
37
+ if pass
38
+ line = Pass.new(*args).to_s
39
+ @passes << line
40
+ else
41
+ line = Failure.new(*args).to_s
42
+ @failures << line
43
+ @status = "failing"
44
+ end
45
+ @lines << line
46
+
47
+ publication.merge!(line: line, pass: pass)
48
+ when "end"
49
+ @status = failures.any? ? "failed" : "finished"
50
+ @completed = true
51
+ end
52
+
53
+ publication.merge!(status: status, session_id: session_id, completed: @completed)
54
+ Blade.publish("/results", publication)
55
+ end
56
+
57
+ def total
58
+ if @total
59
+ @total
60
+ elsif @completed
61
+ passes.size + failures.size
62
+ end
63
+ end
64
+
65
+ def to_s
66
+ lines.join("\n") + "\n"
67
+ end
68
+
69
+ class Pass
70
+ def initialize(name, message)
71
+ @name = name
72
+ @message = message
73
+ end
74
+
75
+ def to_s(number = nil)
76
+ ["ok", number, @name, message].compact.join(" ")
77
+ end
78
+
79
+ def message
80
+ unless @message.nil?
81
+ "\n" + @message.gsub(/^/, "# ").chomp
82
+ end
83
+ end
84
+ end
85
+
86
+ class Failure < Pass
87
+ def to_s(*args)
88
+ "not #{super}"
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,3 @@
1
+ module Blade
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,253 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blade
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Javan Makhmali
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-29 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: blade-qunit_adapter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: coffee-script
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.4.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.4.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: coffee-script-source
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.9.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.9.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: curses
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.0.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: eventmachine
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 1.0.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 1.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: faye
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 1.1.1
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 1.1.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: sprockets
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 3.2.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 3.2.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: thin
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 1.6.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 1.6.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: useragent
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.13.0
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.13.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: thor
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 0.19.1
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 0.19.1
195
+ description: Sprockets test runner and toolkit
196
+ email:
197
+ - javan@javan.us
198
+ executables:
199
+ - blade
200
+ extensions: []
201
+ extra_rdoc_files: []
202
+ files:
203
+ - ".gitignore"
204
+ - Gemfile
205
+ - LICENSE.txt
206
+ - README.md
207
+ - Rakefile
208
+ - assets/index.coffee
209
+ - assets/index.html.erb
210
+ - bin/console
211
+ - bin/setup
212
+ - blade.gemspec
213
+ - exe/blade
214
+ - lib/blade.rb
215
+ - lib/blade/assets.rb
216
+ - lib/blade/cli.rb
217
+ - lib/blade/combined_test_results.rb
218
+ - lib/blade/component.rb
219
+ - lib/blade/interface/ci.rb
220
+ - lib/blade/interface/console.rb
221
+ - lib/blade/interface/console/tab.rb
222
+ - lib/blade/model.rb
223
+ - lib/blade/rack_adapter.rb
224
+ - lib/blade/server.rb
225
+ - lib/blade/session.rb
226
+ - lib/blade/test_helper.rb
227
+ - lib/blade/test_results.rb
228
+ - lib/blade/version.rb
229
+ homepage: https://github.com/javan/blade
230
+ licenses:
231
+ - MIT
232
+ metadata: {}
233
+ post_install_message:
234
+ rdoc_options: []
235
+ require_paths:
236
+ - lib
237
+ required_ruby_version: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - ">="
240
+ - !ruby/object:Gem::Version
241
+ version: '0'
242
+ required_rubygems_version: !ruby/object:Gem::Requirement
243
+ requirements:
244
+ - - ">="
245
+ - !ruby/object:Gem::Version
246
+ version: '0'
247
+ requirements: []
248
+ rubyforge_project:
249
+ rubygems_version: 2.4.6
250
+ signing_key:
251
+ specification_version: 4
252
+ summary: Blade
253
+ test_files: []