blade 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e7bb7f80fe929f752ce8fc4123466464fd832ab
4
- data.tar.gz: dd13a3365981759f52cdebec0742f1605662cea1
3
+ metadata.gz: 036f656e11ef4e58b8754e1fa79f3dd2b201ec6d
4
+ data.tar.gz: 861f57df946610dcf07e195476e316b8a665e73c
5
5
  SHA512:
6
- metadata.gz: 4ff02f3a5d8f2b816514ad47ba39d35ad52c3456b5ec65d96bfddd52ebff142539d0d3585dd311ae26b958fac6ba865b7c3db0d6f69c703f1a83410d02e06f89
7
- data.tar.gz: 301fd0c12026cd5a6d599f0734877b700d7fb25659f694910ec1d13004b767c9af61d9c2a01c8dd2b1ef7ea4ec5e83d944571cbcaed2272b5d1803a2f9b45e08
6
+ metadata.gz: 89495488ab78a6b6d95a745573530abcdb18f4e2c23fd42f7e52865a15ae0802e2234bd201e50240475a4150201531bc67432006851da299119ed70761424a99
7
+ data.tar.gz: 31ced33e906e14e7bc223aa72466634e28740edb2c2348f450f9c2c7317768eb75c7355814efd4139f5c8071823b5a5bc538435daa1e7b9420bd0ed2dceebb97
@@ -1,39 +1,35 @@
1
+ @Blade =
2
+ suiteDidBegin: (details) ->
3
+ publish("/tests", event: "begin", total: details.total)
4
+
5
+ testDidEnd: (details) ->
6
+ publish("/tests", event: "result", result: details.pass, name: details.name, message: details.message)
7
+
8
+ suiteDidEnd: (details) ->
9
+ publish("/tests", event: "end", total: details.total)
10
+
11
+ publish = (channel, data = {}) ->
12
+ client.publish(channel, copy(data, {session_id})) if session_id?
13
+
14
+ copy = (object, withAttributes = {}) ->
15
+ result = {}
16
+ result[key] = value for key, value of object
17
+ result[key] = value for key, value of withAttributes
18
+ result
19
+
1
20
  getWebSocketURL = ->
2
21
  element = document.querySelector("script[data-websocket]")
3
22
  element.src.replace(/\/client\.js$/, "")
4
23
 
5
- @client = new Faye.Client getWebSocketURL()
6
- session_id = document.cookie.match(/blade_session=(\w+)/)?[1]
24
+ getSessionId = ->
25
+ document.cookie.match(/blade_session=(\w+)/)?[1]
7
26
 
8
- publish = ({channel, event, data}) ->
9
- if session_id?
10
- data = extend(copy(data), {event, session_id})
11
- client.publish(channel, data)
27
+ client = new Faye.Client(getWebSocketURL())
12
28
 
13
- copy = (object) ->
14
- results = {}
15
- results[key] = value for key, value of object
16
- results
17
-
18
- extend = (object, attributes) ->
19
- object[key] = value for key, value of attributes
20
- object
21
-
22
- if session_id?
29
+ if session_id = getSessionId()
23
30
  client.subscribe "/assets", (data) ->
24
31
  location.reload() if data.changed
25
32
 
26
33
  setInterval ->
27
- publish(channel: "/browsers", event: "ping")
34
+ publish("/browsers", event: "ping")
28
35
  , 1000
29
-
30
- @Blade =
31
- suiteBegin: ({total}) ->
32
- publish("/tests", event: "begin", data: {total})
33
-
34
- testResult: ({name, pass, message}) ->
35
- result = pass
36
- publish(channel: "/tests", event: "result", data: {result, name, message})
37
-
38
- suiteEnd: (details) ->
39
- publish(channel: "/tests", event: "end", data: details)
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.10"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
 
25
- spec.add_dependency "blade-qunit_adapter"
25
+ spec.add_dependency "blade-qunit_adapter", "~> 0.3.0"
26
26
  spec.add_dependency "activesupport", ">= 3.0.0"
27
27
  spec.add_dependency "coffee-script", "~> 2.4.0"
28
28
  spec.add_dependency "coffee-script-source", "~> 1.9.0"
@@ -1,5 +1,5 @@
1
1
  class Blade::TestResults
2
- attr_reader :session_id, :status, :lines, :passes, :failures
2
+ attr_reader :session_id, :status, :lines, :passes, :failures, :total
3
3
 
4
4
  def initialize(session_id)
5
5
  @session_id = session_id
@@ -16,9 +16,8 @@ class Blade::TestResults
16
16
  @lines = []
17
17
  @passes = []
18
18
  @failures = []
19
- @completed = false
20
19
  @status = "pending"
21
- @total = nil
20
+ @total = 0
22
21
  end
23
22
 
24
23
  def process_test_result(details)
@@ -47,21 +46,13 @@ class Blade::TestResults
47
46
  publication.merge!(line: line, pass: pass)
48
47
  when "end"
49
48
  @status = failures.any? ? "failed" : "finished"
50
- @completed = true
49
+ publication[:completed] = true
51
50
  end
52
51
 
53
- publication.merge!(status: status, session_id: session_id, completed: @completed)
52
+ publication.merge!(status: status, session_id: session_id)
54
53
  Blade.publish("/results", publication)
55
54
  end
56
55
 
57
- def total
58
- if @total
59
- @total
60
- elsif @completed
61
- passes.size + failures.size
62
- end
63
- end
64
-
65
56
  def to_s
66
57
  lines.join("\n") + "\n"
67
58
  end
@@ -1,3 +1,3 @@
1
1
  module Blade
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javan Makhmali
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-29 00:00:00.000000000 Z
11
+ date: 2015-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: blade-qunit_adapter
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.3.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.3.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement