iron-motion 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.repl_history +0 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +45 -0
- data/Rakefile +7 -0
- data/build/iPhoneSimulator-5.1-Development/Untitled.app/Info.plist +0 -0
- data/build/iPhoneSimulator-5.1-Development/Untitled.app/PkgInfo +1 -0
- data/build/iPhoneSimulator-5.1-Development/Untitled.app/Untitled +0 -0
- data/build/iPhoneSimulator-5.1-Development/Untitled.dSYM/Contents/Info.plist +20 -0
- data/build/iPhoneSimulator-5.1-Development/Untitled.dSYM/Contents/Resources/DWARF/Untitled +0 -0
- data/build/iPhoneSimulator-5.1-Development/objs/init.mm +37 -0
- data/build/iPhoneSimulator-5.1-Development/objs/init.o +0 -0
- data/build/iPhoneSimulator-5.1-Development/objs/main.mm +26 -0
- data/build/iPhoneSimulator-5.1-Development/objs/main.o +0 -0
- data/iron-motion.gemspec +20 -0
- data/lib/iron-motion.rb +12 -0
- data/lib/iron-motion/version.rb +3 -0
- data/motion/client.rb +57 -0
- data/motion/code.rb +90 -0
- data/motion/error.rb +4 -0
- data/motion/helper.rb +24 -0
- data/motion/project.rb +43 -0
- data/motion/protocol.rb +28 -0
- data/motion/task.rb +89 -0
- metadata +108 -0
data/.gitignore
ADDED
data/.repl_history
ADDED
File without changes
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Alan deLevie
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# IronMotion
|
2
|
+
|
3
|
+
A RubyMotion wrapper for [Iron.io's](http://iron.io) REST API.
|
4
|
+
|
5
|
+
So far, only [IronWorker](http://www.iron.io/products/worker) is partially supported.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'iron-motion'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install iron-motion
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
|
25
|
+
IronMotion.init(:oauth_token => "12345thisisanoauthtoken6789")
|
26
|
+
projects = IronMotion::Projects.all
|
27
|
+
project = projects.first
|
28
|
+
project.getTasks do |tasks|
|
29
|
+
puts tasks.first.id
|
30
|
+
puts tasks.first.code_name
|
31
|
+
end
|
32
|
+
project.getCodes do |codes|
|
33
|
+
puts codes.first.id
|
34
|
+
puts codes.first.name
|
35
|
+
end
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
AAPL????
|
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
6
|
+
<string>English</string>
|
7
|
+
<key>CFBundleIdentifier</key>
|
8
|
+
<string>com.apple.xcode.dsym.com.yourcompany.Untitled</string>
|
9
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
10
|
+
<string>6.0</string>
|
11
|
+
<key>CFBundlePackageType</key>
|
12
|
+
<string>dSYM</string>
|
13
|
+
<key>CFBundleSignature</key>
|
14
|
+
<string>????</string>
|
15
|
+
<key>CFBundleShortVersionString</key>
|
16
|
+
<string>1</string>
|
17
|
+
<key>CFBundleVersion</key>
|
18
|
+
<string>1.0</string>
|
19
|
+
</dict>
|
20
|
+
</plist>
|
Binary file
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#import <UIKit/UIKit.h>
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
void ruby_sysinit(int *, char ***);
|
5
|
+
void ruby_init(void);
|
6
|
+
void ruby_init_loadpath(void);
|
7
|
+
void ruby_script(const char *);
|
8
|
+
void ruby_set_argv(int, char **);
|
9
|
+
void rb_vm_init_compiler(void);
|
10
|
+
void rb_vm_init_jit(void);
|
11
|
+
void rb_vm_aot_feature_provide(const char *, void *);
|
12
|
+
void *rb_vm_top_self(void);
|
13
|
+
void rb_rb2oc_exc_handler(void);
|
14
|
+
void rb_exit(int);
|
15
|
+
}
|
16
|
+
|
17
|
+
extern "C"
|
18
|
+
void
|
19
|
+
RubyMotionInit(int argc, char **argv)
|
20
|
+
{
|
21
|
+
static bool initialized = false;
|
22
|
+
if (!initialized) {
|
23
|
+
ruby_init();
|
24
|
+
ruby_init_loadpath();
|
25
|
+
if (argc > 0) {
|
26
|
+
const char *progname = argv[0];
|
27
|
+
ruby_script(progname);
|
28
|
+
}
|
29
|
+
try {
|
30
|
+
void *self = rb_vm_top_self();
|
31
|
+
}
|
32
|
+
catch (...) {
|
33
|
+
rb_rb2oc_exc_handler();
|
34
|
+
}
|
35
|
+
initialized = true;
|
36
|
+
}
|
37
|
+
}
|
Binary file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#import <UIKit/UIKit.h>
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
void rb_define_global_const(const char *, void *);
|
5
|
+
void rb_rb2oc_exc_handler(void);
|
6
|
+
void rb_exit(int);
|
7
|
+
void RubyMotionInit(int argc, char **argv);
|
8
|
+
}
|
9
|
+
int
|
10
|
+
main(int argc, char **argv)
|
11
|
+
{
|
12
|
+
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
13
|
+
int retval = 0;
|
14
|
+
try {
|
15
|
+
RubyMotionInit(argc, argv);
|
16
|
+
rb_define_global_const("RUBYMOTION_ENV", @"development");
|
17
|
+
rb_define_global_const("RUBYMOTION_VERSION", @"1.29");
|
18
|
+
retval = UIApplicationMain(argc, argv, nil, @"AppDelegate");
|
19
|
+
rb_exit(retval);
|
20
|
+
}
|
21
|
+
catch (...) {
|
22
|
+
rb_rb2oc_exc_handler();
|
23
|
+
}
|
24
|
+
[pool release];
|
25
|
+
return retval;
|
26
|
+
}
|
Binary file
|
data/iron-motion.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/iron-motion/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Alan deLevie"]
|
6
|
+
gem.email = ["adelevie@gmail.com"]
|
7
|
+
gem.description = %q{A RubyMotion wrapper for Iron.io's REST API}
|
8
|
+
gem.summary = %q{Supports basic read operations for IronWorker.}
|
9
|
+
gem.homepage = "http://github.com/adelevie/IronMotion"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "iron-motion"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = IronMotion::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'bubble-wrap'
|
19
|
+
gem.add_development_dependency 'rake'
|
20
|
+
end
|
data/lib/iron-motion.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "iron-motion/version"
|
2
|
+
require 'bubble-wrap/http'
|
3
|
+
require 'bubble-wrap/core'
|
4
|
+
require 'bubble-wrap/reactor'
|
5
|
+
|
6
|
+
BW.require "motion/code.rb"
|
7
|
+
BW.require "motion/client.rb"
|
8
|
+
BW.require "motion/error.rb"
|
9
|
+
BW.require "motion/helper.rb"
|
10
|
+
BW.require "motion/project.rb"
|
11
|
+
BW.require "motion/protocol.rb"
|
12
|
+
BW.require "motion/task.rb"
|
data/motion/client.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
module IronMotion
|
2
|
+
class Client
|
3
|
+
def initialize(params={})
|
4
|
+
@host = IronMotion::Protocol::HOST
|
5
|
+
@oauth_token = params[:oauth_token]
|
6
|
+
@headers = {}
|
7
|
+
@headers.merge!({"Authorization" => "OAuth #{@oauth_token}"})
|
8
|
+
@headers.merge!({"Accept" => "appplication/json"})
|
9
|
+
@headers.merge!({"Accept-Encoding" => "gzip/deflate"})
|
10
|
+
@headers.merge!({"Content-Type" => "application/json"})
|
11
|
+
end
|
12
|
+
|
13
|
+
def request(uri, method = :get, options = nil, &block)
|
14
|
+
opts = {}
|
15
|
+
opts[:headers] = @headers
|
16
|
+
opts.merge!(options) if options
|
17
|
+
|
18
|
+
case method
|
19
|
+
when :get
|
20
|
+
BW::HTTP.get(uri, opts) do |response|
|
21
|
+
if response.ok?
|
22
|
+
string = response.body.to_str
|
23
|
+
json = BW::JSON.parse(string)
|
24
|
+
block.call(json)
|
25
|
+
# elsif response.status_code == 400
|
26
|
+
# raise IronMotionError, "Invalid authentication: The OAuth token is either not provided or invalid."
|
27
|
+
# elsif response.status_code == 404
|
28
|
+
# raise IronMotionError, "Invalid endpoint: The resource, project, or endpoint being requested doesn’t exist."
|
29
|
+
# elsif response.status_code == 405
|
30
|
+
# raise IronMotionError, "Invalid HTTP method: A GET, POST, DELETE, or PUT was sent to an endpoint that doesn’t support that particular verb."
|
31
|
+
# elsif response.status_code == 406
|
32
|
+
# raise IronMotionError, "Invalid request: Required fields are missing."
|
33
|
+
else
|
34
|
+
raise IronMotionError, "#{response.status_code}: #{response.body.to_str}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def get(uri, options = nil, &block)
|
41
|
+
request(uri, :get, options, &block)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
@@client = nil
|
47
|
+
|
48
|
+
def IronMotion.init(params)
|
49
|
+
@@client = IronMotion::Client.new(params)
|
50
|
+
end
|
51
|
+
|
52
|
+
def IronMotion.client
|
53
|
+
raise IronMotionError, "API Not Initialized" unless @@client
|
54
|
+
@@client
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/motion/code.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
module IronMotion
|
2
|
+
class Code
|
3
|
+
attr_reader :id
|
4
|
+
attr_reader :project_id
|
5
|
+
attr_reader :name
|
6
|
+
attr_reader :runtime
|
7
|
+
attr_reader :latest_checksum
|
8
|
+
attr_reader :rev
|
9
|
+
attr_reader :latest_history_id
|
10
|
+
attr_reader :latest_change
|
11
|
+
attr_reader :created_at
|
12
|
+
attr_reader :updated_at
|
13
|
+
attr_reader :uri
|
14
|
+
|
15
|
+
def initialize(params={})
|
16
|
+
@id = params["id"]
|
17
|
+
@project_id = params["project_id"]
|
18
|
+
@name = params["name"]
|
19
|
+
@runtime = params["runtime"]
|
20
|
+
@latest_checksum = params["latest_checksum"]
|
21
|
+
@rev = params["rev"]
|
22
|
+
@latest_history_id = params["latest_history_id"]
|
23
|
+
@latest_change = params["latest_change"]
|
24
|
+
@created_at = params["created_at"]
|
25
|
+
@updated_at = params["updated_at"]
|
26
|
+
@url = "#{IronMotion::Protocol.codes_uri(@project_id)}/#{id}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.all(project_id, &block)
|
30
|
+
uri = IronMotion::Protocol.codes_uri(project_id)
|
31
|
+
IronMotion.client.get(uri) do |results|
|
32
|
+
block.call parse_results(results)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.get(id, project_id, &block)
|
37
|
+
uri = "#{IronMotion::Protocol.codes_uri(project_id)}/#{id}"
|
38
|
+
IronMotion.client.get(uri) do |results|
|
39
|
+
block.call parse_results(results)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def revisions(&block)
|
44
|
+
uri = "#{@url}/#{IronMotion::Protocol::CODE_REVISIONS_PATH}"
|
45
|
+
IronMotion.client.get(uri) do |results|
|
46
|
+
block.call IronMotion::Code::Revision.parse_results(results)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class Revision
|
51
|
+
attr_reader :id
|
52
|
+
attr_reader :code_id
|
53
|
+
attr_reader :project_id
|
54
|
+
attr_reader :rev
|
55
|
+
attr_reader :runtime
|
56
|
+
attr_reader :name
|
57
|
+
attr_reader :filename
|
58
|
+
|
59
|
+
def initialize(params={})
|
60
|
+
@id = params["id"]
|
61
|
+
@code_id = params["code_id"]
|
62
|
+
@project_id = params["project_id"]
|
63
|
+
@rev = params["rev"]
|
64
|
+
@runtime = params["runtime"]
|
65
|
+
@name = params["name"]
|
66
|
+
@filename = params["filename"]
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def self.parse_results(results)
|
72
|
+
results[IronMotion::Protocol::CODE_REVISIONS_KEY].map {|r| new(r)}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def self.parse_results(results)
|
79
|
+
key = IronMotion::Protocol::CODES_KEY
|
80
|
+
if results.has_key?(key)
|
81
|
+
results[key].map do |r|
|
82
|
+
new(r)
|
83
|
+
end
|
84
|
+
else
|
85
|
+
new(results)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
data/motion/error.rb
ADDED
data/motion/helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module IronMotion
|
2
|
+
module Helper
|
3
|
+
def Helper.hash_to_query_string(hash)
|
4
|
+
query_string = ''
|
5
|
+
if hash.keys == 0
|
6
|
+
return ""
|
7
|
+
elsif hash.keys == 1
|
8
|
+
hash.each_pair do |k,v|
|
9
|
+
query_string << "#{k}=#{v}"
|
10
|
+
end
|
11
|
+
else
|
12
|
+
hash.each_pair do |k,v|
|
13
|
+
query_string << "#{k}=#{v}&"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
query_string.chomp!('&')
|
18
|
+
query_string.chomp!('.0')
|
19
|
+
"?#{query_string}"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/motion/project.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module IronMotion
|
2
|
+
class Project
|
3
|
+
include EM::Eventable
|
4
|
+
|
5
|
+
attr_reader :id
|
6
|
+
attr_reader :name
|
7
|
+
attr_reader :codes
|
8
|
+
attr_reader :tasks
|
9
|
+
|
10
|
+
def initialize(id)
|
11
|
+
@id = id
|
12
|
+
@name = "dokket"
|
13
|
+
end
|
14
|
+
|
15
|
+
def getCodes(&block)
|
16
|
+
IronMotion::Code.all(@id) do |codes|
|
17
|
+
@codes = codes
|
18
|
+
block.call(codes)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def getTasks(options=nil, &block)
|
23
|
+
@tasks = IronMotion::Task.all(@id, options) do |tasks|
|
24
|
+
@tasks = tasks
|
25
|
+
block.call(tasks)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def joinTasksAndCodes
|
30
|
+
raise IronMotionError, "@codes not loaded" if @codes.nil?
|
31
|
+
raise IronMotionError, "@tasks not loaded" if @tasks.nil?
|
32
|
+
@tasks.map do |task|
|
33
|
+
task.setCode @codes.select {|c| c.id == task.code_id}.first
|
34
|
+
end
|
35
|
+
|
36
|
+
@tasks
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.all
|
40
|
+
[IronMotion::Project.new("509c557b7e4b7117f2002bf6")]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/motion/protocol.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module IronMotion
|
2
|
+
module Protocol
|
3
|
+
HOST = "worker-aws-us-east-1.iron.io"
|
4
|
+
VERSION = 2
|
5
|
+
BASE_URI = "https://#{HOST}/#{VERSION}"
|
6
|
+
CODES_PATH = "codes"
|
7
|
+
CODES_KEY = "codes"
|
8
|
+
CODE_REVISIONS_PATH = "revisions"
|
9
|
+
CODE_REVISIONS_KEY = "revisions"
|
10
|
+
PROJECTS_PATH = "projects"
|
11
|
+
TASKS_PATH = "tasks"
|
12
|
+
TASKS_KEY = "tasks"
|
13
|
+
TASK_LOG_PATH = "log"
|
14
|
+
TASK_LOG_KEY = "log"
|
15
|
+
|
16
|
+
def Protocol.project_uri(project_id)
|
17
|
+
"#{BASE_URI}/#{PROJECTS_PATH}/#{project_id}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def Protocol.codes_uri(project_id)
|
21
|
+
"#{Protocol.project_uri(project_id)}/#{CODES_PATH}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def Protocol.tasks_uri(project_id)
|
25
|
+
"#{Protocol.project_uri(project_id)}/#{TASKS_PATH}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/motion/task.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
module IronMotion
|
2
|
+
class Task
|
3
|
+
attr_reader :id
|
4
|
+
attr_reader :project_id
|
5
|
+
attr_reader :code_id
|
6
|
+
attr_reader :code
|
7
|
+
attr_reader :code_history_id
|
8
|
+
attr_reader :status
|
9
|
+
attr_reader :code_name
|
10
|
+
attr_reader :code_rev
|
11
|
+
attr_reader :start_time
|
12
|
+
attr_reader :end_time
|
13
|
+
attr_reader :duration
|
14
|
+
attr_reader :timeout
|
15
|
+
attr_reader :updated_at
|
16
|
+
attr_reader :created_at
|
17
|
+
attr_reader :run_times
|
18
|
+
attr_reader :percent
|
19
|
+
attr_reader :payload
|
20
|
+
|
21
|
+
def initialize(params={})
|
22
|
+
@id = params["id"]
|
23
|
+
@project_id = params["project_id"]
|
24
|
+
@code_id = params["code_id"]
|
25
|
+
@code_history_id = params["code_history_id"]
|
26
|
+
@status = params["status"]
|
27
|
+
@code_name = params["code_name"]
|
28
|
+
@code_rev = params["code_rev"]
|
29
|
+
@start_time = params["start_time"]
|
30
|
+
@end_time = params["end_time"]
|
31
|
+
@duration = params["duration"]
|
32
|
+
@timeout = params["timeout"]
|
33
|
+
@updated_at = params["updated_at"]
|
34
|
+
@created_at = params["created_at"]
|
35
|
+
@run_times = params["run_times"]
|
36
|
+
@percent = params["percent"]
|
37
|
+
@payload = params["payload"]
|
38
|
+
@url = "#{IronMotion::Protocol.tasks_uri(project_id)}/#{@id}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.all(project_id, options, &block)
|
42
|
+
default_options = {
|
43
|
+
:per_page => 100,
|
44
|
+
:from_time => (Time.now - 24.hours).timeIntervalSince1970
|
45
|
+
}
|
46
|
+
default_options.merge!(options) if options
|
47
|
+
opts = default_options
|
48
|
+
query_string = IronMotion::Helper.hash_to_query_string(opts)
|
49
|
+
uri = IronMotion::Protocol.tasks_uri(project_id) + query_string
|
50
|
+
IronMotion.client.get(uri) do |results|
|
51
|
+
block.call parse_results(results)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.get(id, project_id, &block)
|
56
|
+
uri = "#{IronMotion::Protocol.tasks_uri(project_id)}/#{id}"
|
57
|
+
IronMotion.client.get(uri) do |results|
|
58
|
+
block.call parse_results(results)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def setCode(code)
|
63
|
+
@code = code
|
64
|
+
end
|
65
|
+
|
66
|
+
#TODO: make sure this works
|
67
|
+
def log(&block)
|
68
|
+
uri = "#{@url}/#{IronMotion::Protocol::TASK_LOG_PATH}"
|
69
|
+
options = {
|
70
|
+
:headers => {"Content-Type" => "text/plain"}
|
71
|
+
}
|
72
|
+
IronMotion.client.get(uri, options) do |results|
|
73
|
+
block.call(results)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def self.parse_results(results)
|
80
|
+
key = IronMotion::Protocol::TASKS_KEY
|
81
|
+
if results.has_key?(key)
|
82
|
+
results[key].map {|r| new(r)}
|
83
|
+
else
|
84
|
+
new(results)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iron-motion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alan deLevie
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bubble-wrap
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: A RubyMotion wrapper for Iron.io's REST API
|
47
|
+
email:
|
48
|
+
- adelevie@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- .repl_history
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- build/iPhoneSimulator-5.1-Development/Untitled.app/Info.plist
|
60
|
+
- build/iPhoneSimulator-5.1-Development/Untitled.app/PkgInfo
|
61
|
+
- build/iPhoneSimulator-5.1-Development/Untitled.app/Untitled
|
62
|
+
- build/iPhoneSimulator-5.1-Development/Untitled.dSYM/Contents/Info.plist
|
63
|
+
- build/iPhoneSimulator-5.1-Development/Untitled.dSYM/Contents/Resources/DWARF/Untitled
|
64
|
+
- build/iPhoneSimulator-5.1-Development/objs/init.mm
|
65
|
+
- build/iPhoneSimulator-5.1-Development/objs/init.o
|
66
|
+
- build/iPhoneSimulator-5.1-Development/objs/main.mm
|
67
|
+
- build/iPhoneSimulator-5.1-Development/objs/main.o
|
68
|
+
- iron-motion.gemspec
|
69
|
+
- lib/iron-motion.rb
|
70
|
+
- lib/iron-motion/version.rb
|
71
|
+
- motion/client.rb
|
72
|
+
- motion/code.rb
|
73
|
+
- motion/error.rb
|
74
|
+
- motion/helper.rb
|
75
|
+
- motion/project.rb
|
76
|
+
- motion/protocol.rb
|
77
|
+
- motion/task.rb
|
78
|
+
homepage: http://github.com/adelevie/IronMotion
|
79
|
+
licenses: []
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
hash: -162762085295890209
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
hash: -162762085295890209
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 1.8.24
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: Supports basic read operations for IronWorker.
|
108
|
+
test_files: []
|