elevate 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,56 +1,19 @@
1
1
  describe Elevate::ElevateOperation do
2
2
  before do
3
- @target = lambda { @result }
4
- @operation = Elevate::ElevateOperation.alloc.initWithTarget(@target, args: {})
3
+ @target = lambda { 42 }
4
+ @operation = Elevate::ElevateOperation.alloc.initWithTarget(@target, args: {}, channel: [])
5
5
  @queue = NSOperationQueue.alloc.init
6
6
  end
7
7
 
8
8
  after do
9
- @queue.waitUntilAllOperationsAreFinished()
10
- end
11
-
12
- it "subclasses NSOperation" do
13
- @operation.class.ancestors.should.include NSOperation
14
- end
15
-
16
- describe "#on_finish=" do
17
- it "invokes it after #on_started" do
18
- @lock = NSLock.alloc.init
19
- @value = []
20
-
21
- @operation.on_start = lambda do
22
- @lock.lock()
23
- if @value == []
24
- @value << 1
25
- end
26
- @lock.unlock()
27
- end
28
-
29
- @operation.on_finish = lambda do |result, exception|
30
- @lock.lock()
31
- if @value == [1]
32
- @value << 2
33
- end
34
- @lock.unlock()
35
-
36
- Dispatch::Queue.main.sync { resume }
37
- end
38
-
39
- @queue.addOperation(@operation)
40
-
41
- wait_max 1.0 do
42
- @lock.lock()
43
- @value.should == [1,2]
44
- @lock.unlock()
45
- end
46
- end
9
+ @queue.waitUntilAllOperationsAreFinished
47
10
  end
48
11
 
49
12
  describe "#exception" do
50
13
  describe "when no exception is raised" do
51
14
  it "returns nil" do
52
15
  @queue.addOperation(@operation)
53
- @operation.waitUntilFinished()
16
+ @operation.waitUntilFinished
54
17
 
55
18
  @operation.exception.should.be.nil
56
19
  end
@@ -59,10 +22,10 @@ describe Elevate::ElevateOperation do
59
22
  describe "when an exception is raised" do
60
23
  it "returns the exception" do
61
24
  @target = lambda { raise IndexError }
62
- @operation = Elevate::ElevateOperation.alloc.initWithTarget(@target, args: {})
25
+ @operation = Elevate::ElevateOperation.alloc.initWithTarget(@target, args: {}, channel: nil)
63
26
 
64
27
  @queue.addOperation(@operation)
65
- @operation.waitUntilFinished()
28
+ @operation.waitUntilFinished
66
29
 
67
30
  @operation.exception.should.not.be.nil
68
31
  end
@@ -72,7 +35,7 @@ describe Elevate::ElevateOperation do
72
35
  describe "#result" do
73
36
  before do
74
37
  @target = lambda { 42 }
75
- @operation = Elevate::ElevateOperation.alloc.initWithTarget(@target, args: {})
38
+ @operation = Elevate::ElevateOperation.alloc.initWithTarget(@target, args: {}, channel: nil)
76
39
  end
77
40
 
78
41
  describe "before starting the operation" do
@@ -83,10 +46,10 @@ describe Elevate::ElevateOperation do
83
46
 
84
47
  describe "when the operation has been cancelled" do
85
48
  it "returns nil" do
86
- @operation.cancel()
49
+ @operation.cancel
87
50
 
88
51
  @queue.addOperation(@operation)
89
- @operation.waitUntilFinished()
52
+ @operation.waitUntilFinished
90
53
 
91
54
  @operation.result.should.be.nil
92
55
  end
@@ -95,7 +58,7 @@ describe Elevate::ElevateOperation do
95
58
  describe "when the operation has finished" do
96
59
  it "returns the result of the lambda" do
97
60
  @queue.addOperation(@operation)
98
- @operation.waitUntilFinished()
61
+ @operation.waitUntilFinished
99
62
 
100
63
  @operation.result.should == 42
101
64
  end
@@ -0,0 +1,12 @@
1
+ describe Elevate::TaskContext do
2
+ describe "#execute" do
3
+ it "runs the specified block" do
4
+ result = {}
5
+
6
+ context = Elevate::TaskContext.new(->{ result[:ret] = true }, [], {})
7
+ context.execute
8
+
9
+ result[:ret].should.be.true
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elevate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Green
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-12 00:00:00.000000000 Z
11
+ date: 2014-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.0
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: webstub
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.6.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.6.0
41
41
  description: Distill the essence of your RubyMotion app
@@ -45,8 +45,8 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
49
- - .travis.yml
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
50
  - Gemfile
51
51
  - Guardfile
52
52
  - LICENSE
@@ -55,9 +55,9 @@ files:
55
55
  - app/app_delegate.rb
56
56
  - elevate.gemspec
57
57
  - lib/elevate.rb
58
- - lib/elevate/callback.rb
59
- - lib/elevate/dsl.rb
58
+ - lib/elevate/channel.rb
60
59
  - lib/elevate/elevate.rb
60
+ - lib/elevate/future.rb
61
61
  - lib/elevate/http.rb
62
62
  - lib/elevate/http/activity_indicator.rb
63
63
  - lib/elevate/http/base64.rb
@@ -69,10 +69,10 @@ files:
69
69
  - lib/elevate/http/uri.rb
70
70
  - lib/elevate/io_coordinator.rb
71
71
  - lib/elevate/operation.rb
72
- - lib/elevate/promise.rb
72
+ - lib/elevate/task.rb
73
73
  - lib/elevate/task_context.rb
74
+ - lib/elevate/task_definition.rb
74
75
  - lib/elevate/version.rb
75
- - spec/callback_spec.rb
76
76
  - spec/elevate_spec.rb
77
77
  - spec/http/activity_indicator_spec.rb
78
78
  - spec/http/http_client_spec.rb
@@ -80,8 +80,10 @@ files:
80
80
  - spec/http_spec.rb
81
81
  - spec/io_coordinator_spec.rb
82
82
  - spec/operation_spec.rb
83
+ - spec/task_context_spec.rb
83
84
  homepage: http://github.com/mattgreen/elevate
84
- licenses: []
85
+ licenses:
86
+ - MIT
85
87
  metadata: {}
86
88
  post_install_message:
87
89
  rdoc_options: []
@@ -89,22 +91,21 @@ require_paths:
89
91
  - lib
90
92
  required_ruby_version: !ruby/object:Gem::Requirement
91
93
  requirements:
92
- - - '>='
94
+ - - ">="
93
95
  - !ruby/object:Gem::Version
94
96
  version: '0'
95
97
  required_rubygems_version: !ruby/object:Gem::Requirement
96
98
  requirements:
97
- - - '>='
99
+ - - ">="
98
100
  - !ruby/object:Gem::Version
99
101
  version: '0'
100
102
  requirements: []
101
103
  rubyforge_project:
102
- rubygems_version: 2.0.3
104
+ rubygems_version: 2.2.0
103
105
  signing_key:
104
106
  specification_version: 4
105
107
  summary: Distill the essence of your RubyMotion app
106
108
  test_files:
107
- - spec/callback_spec.rb
108
109
  - spec/elevate_spec.rb
109
110
  - spec/http/activity_indicator_spec.rb
110
111
  - spec/http/http_client_spec.rb
@@ -112,3 +113,4 @@ test_files:
112
113
  - spec/http_spec.rb
113
114
  - spec/io_coordinator_spec.rb
114
115
  - spec/operation_spec.rb
116
+ - spec/task_context_spec.rb
@@ -1,22 +0,0 @@
1
- module Elevate
2
- class Callback
3
- def initialize(controller, block)
4
- @controller = controller
5
- @block = block
6
- end
7
-
8
- def call(*args)
9
- if NSThread.isMainThread
10
- invoke(*args)
11
- else
12
- Dispatch::Queue.main.sync { invoke(*args) }
13
- end
14
- end
15
-
16
- private
17
-
18
- def invoke(*args)
19
- @controller.instance_exec(*args, &@block)
20
- end
21
- end
22
- end
@@ -1,49 +0,0 @@
1
- module Elevate
2
- class DSL
3
- def initialize(&block)
4
- instance_eval(&block)
5
- end
6
-
7
- attr_reader :finish_callback
8
- attr_reader :start_callback
9
- attr_reader :task_callback
10
- attr_reader :update_callback
11
-
12
- attr_reader :timeout_callback
13
- attr_reader :timeout_interval
14
-
15
- def on_finish(&block)
16
- raise "on_finish blocks must accept two parameters" unless block.arity == 2
17
-
18
- @finish_callback = block
19
- end
20
-
21
- def on_start(&block)
22
- raise "on_start blocks must accept zero parameters" unless block.arity == 0
23
-
24
- @start_callback = block
25
- end
26
-
27
- def on_timeout(&block)
28
- raise "on_timeout blocks must accept zero parameters" unless block.arity == 0
29
-
30
- @timeout_callback = block
31
- end
32
-
33
- def on_update(&block)
34
- @update_callback = block
35
- end
36
-
37
- def task(&block)
38
- raise "task blocks must accept zero parameters" unless block.arity == 0
39
-
40
- @task_callback = block
41
- end
42
-
43
- def timeout(seconds)
44
- raise "timeout argument must be a number" unless seconds.is_a?(Numeric)
45
-
46
- @timeout_interval = seconds
47
- end
48
- end
49
- end
@@ -1,22 +0,0 @@
1
- describe Elevate::Callback do
2
- describe "#call" do
3
- describe "on the main thread" do
4
- it "invokes the block within the provided context" do
5
- callback = Elevate::Callback.new(self, lambda { |v| @value = v })
6
- callback.call(42)
7
-
8
- @value.should == 42
9
- end
10
- end
11
-
12
- describe "on a background thread" do
13
- it "invokes the block within the provided context on the main thread" do
14
- callback = Elevate::Callback.new(self, lambda { @thread = NSThread.currentThread })
15
- callback.call
16
-
17
- @thread.should == NSThread.mainThread
18
- end
19
- end
20
- end
21
- end
22
-