afmotion-rocket 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +53 -0
- data/LICENSE +26 -0
- data/README.md +38 -0
- data/Rakefile +18 -0
- data/afmotion-rocket.gemspec +20 -0
- data/app/app_delegate.rb +5 -0
- data/lib/afmotion-rocket.rb +15 -0
- data/lib/afmotion-rocket/AFJSONPatchOperation.rb +19 -0
- data/lib/afmotion-rocket/client_patch.rb +55 -0
- data/lib/afmotion-rocket/version.rb +5 -0
- data/resources/Default-568h@2x.png +0 -0
- data/spec/main_spec.rb +9 -0
- data/vendor/Podfile.lock +37 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 22925e0ec658bb8e50a6ea65d011262140a38c65
|
4
|
+
data.tar.gz: a76fc070527205e42c8fa1f11e5301ccbbbf1714
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a25bed9dcceef38e527a6f0ad81fe4b4cb8631708dd17dc79e12c1a00f6f18f78d876e320215cef70eecdf1cb18ed98d83e95a27647d3925f4083b30c97fccd5
|
7
|
+
data.tar.gz: 8e37b48be9946574693e61970521d3c3065b599b101d7fe4137a49a09b794cfa1692e3910179a5e1e44c2f7afc85278b4a2e983862e8440f220ca70b4aab9d3f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
afmotion-rocket (0.0.1)
|
5
|
+
afmotion (~> 2.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (3.2.15)
|
11
|
+
i18n (~> 0.6, >= 0.6.4)
|
12
|
+
multi_json (~> 1.0)
|
13
|
+
afmotion (2.0.0)
|
14
|
+
motion-cocoapods (~> 1.4.0)
|
15
|
+
motion-require (~> 0.0.7)
|
16
|
+
claide (0.3.2)
|
17
|
+
cocoapods (0.27.1)
|
18
|
+
activesupport (>= 3.2.15, < 4)
|
19
|
+
claide (~> 0.3.2)
|
20
|
+
cocoapods-core (= 0.27.1)
|
21
|
+
cocoapods-downloader (~> 0.2.0)
|
22
|
+
colored (~> 1.2)
|
23
|
+
escape (~> 0.0.4)
|
24
|
+
json_pure (~> 1.8)
|
25
|
+
open4 (~> 1.3)
|
26
|
+
xcodeproj (~> 0.14.0)
|
27
|
+
cocoapods-core (0.27.1)
|
28
|
+
activesupport (>= 3.2.15, < 4)
|
29
|
+
json_pure (~> 1.8)
|
30
|
+
nap (~> 0.5)
|
31
|
+
cocoapods-downloader (0.2.0)
|
32
|
+
colored (1.2)
|
33
|
+
escape (0.0.4)
|
34
|
+
i18n (0.6.5)
|
35
|
+
json_pure (1.8.1)
|
36
|
+
motion-cocoapods (1.4.0)
|
37
|
+
cocoapods (>= 0.26.2)
|
38
|
+
motion-require (0.0.7)
|
39
|
+
multi_json (1.8.2)
|
40
|
+
nap (0.5.1)
|
41
|
+
open4 (1.3.0)
|
42
|
+
rake (10.1.0)
|
43
|
+
xcodeproj (0.14.1)
|
44
|
+
activesupport (~> 3.0)
|
45
|
+
colored (~> 1.2)
|
46
|
+
rake
|
47
|
+
|
48
|
+
PLATFORMS
|
49
|
+
ruby
|
50
|
+
|
51
|
+
DEPENDENCIES
|
52
|
+
afmotion-rocket!
|
53
|
+
rake
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
LICENCE
|
2
|
+
|
3
|
+
MIT: http://clayallsopp.mit-license.org
|
4
|
+
|
5
|
+
------------------------------------------------
|
6
|
+
|
7
|
+
The MIT License (MIT)
|
8
|
+
Copyright © 2013 Clay Allsopp <clay@usepropeller.com>
|
9
|
+
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
11
|
+
of this software and associated documentation files (the “Software”), to deal
|
12
|
+
in the Software without restriction, including without limitation the rights
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
15
|
+
furnished to do so, subject to the following conditions:
|
16
|
+
|
17
|
+
The above copyright notice and this permission notice shall be included in
|
18
|
+
all copies or substantial portions of the Software.
|
19
|
+
|
20
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
26
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# AFMotion+Rocket
|
2
|
+
|
3
|
+
Use [Rocket](http://rocket.github.io) in RubyMotion
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
@client = AFMotion::... # create your client
|
9
|
+
|
10
|
+
@client.subscribe("http://myendpoint.com/updates") do |json_patch_operations|
|
11
|
+
|
12
|
+
json_patch_operations.each do |json_patch|
|
13
|
+
if json_patch['add']
|
14
|
+
@resources << json_patch['value']
|
15
|
+
else
|
16
|
+
# handle other cases
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
## Install
|
24
|
+
|
25
|
+
1. `gem install afmotion-rocket`
|
26
|
+
|
27
|
+
2. `require 'afmotion-rocket'` or add to your `Gemfile`
|
28
|
+
|
29
|
+
## Contact
|
30
|
+
|
31
|
+
Clay Allsopp ([http://clayallsopp.com](http://clayallsopp.com))
|
32
|
+
|
33
|
+
- [http://twitter.com/clayallsopp](http://twitter.com/clayallsopp)
|
34
|
+
- [clay@usepropeller.com](clay@usepropeller.com)
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
AFMotion+Rocket is available under the MIT license. See the LICENSE file for more info.
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
$:.unshift("/Library/RubyMotion/lib")
|
3
|
+
require 'motion/project/template/ios'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require "bundler/gem_tasks"
|
7
|
+
require "bundler/setup"
|
8
|
+
Bundler.require :default
|
9
|
+
rescue LoadError
|
10
|
+
end
|
11
|
+
|
12
|
+
$:.unshift("./lib/")
|
13
|
+
require './lib/afmotion-rocket'
|
14
|
+
|
15
|
+
Motion::Project::App.setup do |app|
|
16
|
+
# Use `rake config' to see complete project settings.
|
17
|
+
app.name = 'afmotion-rocket'
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/afmotion-rocket/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "afmotion-rocket"
|
6
|
+
s.version = AFMotion::Rocket::VERSION
|
7
|
+
s.authors = ["Clay Allsopp", "Ben Kudria"]
|
8
|
+
s.email = ["clay@usepropeller.com", "ben@usepropeller.com"]
|
9
|
+
s.homepage = "https://github.com/usepropeller/afmotion-rocket"
|
10
|
+
s.summary = "AFMotion extensions for Rocket"
|
11
|
+
s.description = "AFMotion extensions for Rocket"
|
12
|
+
s.license = 'MIT'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split($\).delete_if {|x| x.include? "example"}
|
15
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_dependency "afmotion", "~> 2.0"
|
19
|
+
s.add_development_dependency 'rake'
|
20
|
+
end
|
data/app/app_delegate.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
require 'afmotion'
|
6
|
+
|
7
|
+
Motion::Project::App.setup do |app|
|
8
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'afmotion-rocket/**/*.rb')).each { |file|
|
9
|
+
app.files << file
|
10
|
+
}
|
11
|
+
|
12
|
+
app.pods do
|
13
|
+
pod 'AFRocketClient', podspec: 'https://raw.github.com/usepropeller/AFRocketClient/master/AFRocketClient.podspec'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class AFJSONPatchOperation
|
2
|
+
OPERATION_NAMES = {
|
3
|
+
AFJSONAddOperationType => 'add',
|
4
|
+
AFJSONRemoveOperationType => 'remove',
|
5
|
+
AFJSONReplaceOperationType => 'replace',
|
6
|
+
AFJSONMoveOperationType => 'move',
|
7
|
+
AFJSONCopyOperationType => 'copy',
|
8
|
+
AFJSONTestOperationType => 'test'
|
9
|
+
}
|
10
|
+
|
11
|
+
def to_h
|
12
|
+
{
|
13
|
+
'op' => OPERATION_NAMES[self.type],
|
14
|
+
'path' => self.path,
|
15
|
+
'from' => self.from,
|
16
|
+
'value' => self.value
|
17
|
+
}.reject {|key, value| value.nil? || value.empty?}
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module AFMotion
|
2
|
+
module Rocket
|
3
|
+
def rocket_client
|
4
|
+
@rocket_client ||= begin
|
5
|
+
client = AFRocketClient.alloc.init
|
6
|
+
self.all_headers.each do |header, value|
|
7
|
+
client.requestSerializer.headers[header] = value
|
8
|
+
end
|
9
|
+
client
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def subscribe(url, &callback)
|
14
|
+
url_string = NSURL.URLWithString(url, relativeToURL: self.baseURL).absoluteString
|
15
|
+
error_ptr = Pointer.new(:object)
|
16
|
+
event_source = rocket_client.SUBSCRIBE(url_string, usingBlock: ->(operations, error) {
|
17
|
+
callback.call operations.map(&:to_h)
|
18
|
+
}, error: error_ptr)
|
19
|
+
|
20
|
+
# .retain because event_source will otherwise be autoreleased.
|
21
|
+
# see also: https://github.com/AFNetworking/AFRocketClient/issues/3 .
|
22
|
+
[error_ptr[0], event_source.retain]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Synchronize headers between clients
|
26
|
+
class HeaderWrapper
|
27
|
+
def initialize(source)
|
28
|
+
@source = WeakRef.new(source)
|
29
|
+
end
|
30
|
+
|
31
|
+
def [](key)
|
32
|
+
@source.headers_without_wrapper[key]
|
33
|
+
end
|
34
|
+
|
35
|
+
def []=(key, value)
|
36
|
+
@source.headers_without_wrapper[key] = value
|
37
|
+
@source.rocket_client.requestSerializer.headers[key] = value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
alias_method "headers_without_wrapper", "headers"
|
42
|
+
|
43
|
+
def headers
|
44
|
+
@headers_wrapper ||= HeaderWrapper.new(self)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class AFHTTPRequestOperationManager
|
50
|
+
include AFMotion::Rocket
|
51
|
+
end
|
52
|
+
|
53
|
+
class AFHTTPSessionManager
|
54
|
+
include AFMotion::Rocket
|
55
|
+
end
|
Binary file
|
data/spec/main_spec.rb
ADDED
data/vendor/Podfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PODS:
|
2
|
+
- AFNetworking (2.0.2):
|
3
|
+
- AFNetworking/NSURLConnection
|
4
|
+
- AFNetworking/NSURLSession
|
5
|
+
- AFNetworking/Reachability
|
6
|
+
- AFNetworking/Security
|
7
|
+
- AFNetworking/Serialization
|
8
|
+
- AFNetworking/UIKit
|
9
|
+
- AFNetworking/NSURLConnection (2.0.2):
|
10
|
+
- AFNetworking/Reachability
|
11
|
+
- AFNetworking/Security
|
12
|
+
- AFNetworking/Serialization
|
13
|
+
- AFNetworking/NSURLSession (2.0.2):
|
14
|
+
- AFNetworking/Reachability
|
15
|
+
- AFNetworking/Security
|
16
|
+
- AFNetworking/Serialization
|
17
|
+
- AFNetworking/Reachability (2.0.2)
|
18
|
+
- AFNetworking/Security (2.0.2)
|
19
|
+
- AFNetworking/Serialization (2.0.2)
|
20
|
+
- AFNetworking/UIKit (2.0.2):
|
21
|
+
- AFNetworking/NSURLConnection
|
22
|
+
- AFRocketClient (0.0.1):
|
23
|
+
- AFNetworking (~> 2.0.0)
|
24
|
+
|
25
|
+
DEPENDENCIES:
|
26
|
+
- AFNetworking (~> 2.0.1)
|
27
|
+
- AFRocketClient (from `https://raw.github.com/usepropeller/AFRocketClient/master/AFRocketClient.podspec`)
|
28
|
+
|
29
|
+
EXTERNAL SOURCES:
|
30
|
+
AFRocketClient:
|
31
|
+
:podspec: https://raw.github.com/usepropeller/AFRocketClient/master/AFRocketClient.podspec
|
32
|
+
|
33
|
+
SPEC CHECKSUMS:
|
34
|
+
AFNetworking: 22de50ae71ab1c4859773f61068d6fcd1d8f9a4d
|
35
|
+
AFRocketClient: 5c42fd281a17995b8caef7faa2b84c01183a0fea
|
36
|
+
|
37
|
+
COCOAPODS: 0.27.1
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: afmotion-rocket
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Clay Allsopp
|
8
|
+
- Ben Kudria
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-11-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: afmotion
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '2.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '2.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
description: AFMotion extensions for Rocket
|
43
|
+
email:
|
44
|
+
- clay@usepropeller.com
|
45
|
+
- ben@usepropeller.com
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- .gitignore
|
51
|
+
- Gemfile
|
52
|
+
- Gemfile.lock
|
53
|
+
- LICENSE
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- afmotion-rocket.gemspec
|
57
|
+
- app/app_delegate.rb
|
58
|
+
- lib/afmotion-rocket.rb
|
59
|
+
- lib/afmotion-rocket/AFJSONPatchOperation.rb
|
60
|
+
- lib/afmotion-rocket/client_patch.rb
|
61
|
+
- lib/afmotion-rocket/version.rb
|
62
|
+
- resources/Default-568h@2x.png
|
63
|
+
- spec/main_spec.rb
|
64
|
+
- vendor/Podfile.lock
|
65
|
+
homepage: https://github.com/usepropeller/afmotion-rocket
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.0.3
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: AFMotion extensions for Rocket
|
89
|
+
test_files:
|
90
|
+
- spec/main_spec.rb
|