runabove 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/runabove.rb +87 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8bbd5d9396fc1ec9b3ba82d0ddba716d0e18df24
|
|
4
|
+
data.tar.gz: b12e48016f7d874d675aafa0284034dbff233c1c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f18ea93fa6a5d36fa31d8c62b128636cdd9b2a44f5dca80990006a030ce207270cd20f38b88f366af17599aca9ae3fa74267eb5d9967e87a0d3f6a1e424e840d
|
|
7
|
+
data.tar.gz: 51cc95816057890d4d1705ae7e8d310570ca225a477ce24626ce91f27e0ea5f560fdbe940cc2d81ea6800d82052bcff68a8ccfd2a59b9185bf1a5c70a4ce23f7
|
data/lib/runabove.rb
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
|
|
2
|
+
# Application Name : demo
|
|
3
|
+
|
|
4
|
+
class Runabove
|
|
5
|
+
require "net/https"
|
|
6
|
+
require "open-uri"
|
|
7
|
+
require 'json'
|
|
8
|
+
require 'digest/sha1'
|
|
9
|
+
|
|
10
|
+
def initialize(appkey, secret, consumerkey = "")
|
|
11
|
+
@appkey = appkey
|
|
12
|
+
@secret = secret
|
|
13
|
+
@consumerkey = consumerkey
|
|
14
|
+
@baseurl = "https://api.runabove.com/1.0"
|
|
15
|
+
@server_time = self.time.to_i
|
|
16
|
+
@delta_time = @server_time - Time.now.to_i
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def createConsumerKey
|
|
20
|
+
uri = URI.parse("https://api.runabove.com/1.0/auth/credential")
|
|
21
|
+
|
|
22
|
+
https = Net::HTTP.new(uri.host,uri.port)
|
|
23
|
+
https.use_ssl = true
|
|
24
|
+
req = Net::HTTP::Post.new(uri.path, initheader = {
|
|
25
|
+
'Content-Type' =>'application/json',
|
|
26
|
+
'X-Ra-Application' => @appkey
|
|
27
|
+
})
|
|
28
|
+
toSend = {
|
|
29
|
+
"accessRules" => [
|
|
30
|
+
{'method'=> 'GET', 'path'=> '/*'},
|
|
31
|
+
{'method'=> 'POST', 'path'=> '/*'},
|
|
32
|
+
{'method'=> 'PUT', 'path'=> '/*'},
|
|
33
|
+
{'method'=> 'DELETE', 'path'=> '/*'}
|
|
34
|
+
]
|
|
35
|
+
}.to_json
|
|
36
|
+
req.body = "#{toSend}"
|
|
37
|
+
req = https.request(req)
|
|
38
|
+
@consumerkey = JSON.parse(req.body)["consumerKey"]
|
|
39
|
+
JSON.parse(req.body)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def time
|
|
43
|
+
uri = URI.parse("https://api.runabove.com/1.0/auth/time")
|
|
44
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
45
|
+
http.use_ssl = true
|
|
46
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
47
|
+
http.get(uri.request_uri).body
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def raw_call(method, path, data = nil)
|
|
51
|
+
time = Time.now.to_i + @delta_time
|
|
52
|
+
body = data.nil? ? "" : data.to_json
|
|
53
|
+
|
|
54
|
+
puts data.inspect
|
|
55
|
+
puts [
|
|
56
|
+
@secret, @consumerkey, method.upcase, @baseurl + path, body, time
|
|
57
|
+
].join("+")
|
|
58
|
+
|
|
59
|
+
sign = "$1$" + Digest::SHA1.hexdigest([
|
|
60
|
+
@secret, @consumerkey, method.upcase, @baseurl + path, body, time
|
|
61
|
+
].join("+"))
|
|
62
|
+
|
|
63
|
+
uri = URI.parse("#{@baseurl}#{path}")
|
|
64
|
+
https = Net::HTTP.new(uri.host,uri.port)
|
|
65
|
+
https.use_ssl = true
|
|
66
|
+
headers = {
|
|
67
|
+
'X-Ra-Timestamp' => (Time.now.to_i + @delta_time).to_s,
|
|
68
|
+
'X-Ra-Application' => @appkey,
|
|
69
|
+
'X-Ra-Signature' => sign,
|
|
70
|
+
'X-Ra-Consumer' => @consumerkey
|
|
71
|
+
}
|
|
72
|
+
if(method.upcase == "GET")
|
|
73
|
+
req = Net::HTTP::Get.new(uri.path, initheader = headers)
|
|
74
|
+
end
|
|
75
|
+
if(method.upcase == "POST")
|
|
76
|
+
req = Net::HTTP::Post.new(uri.path, initheader = headers)
|
|
77
|
+
end
|
|
78
|
+
if(method.upcase == "PUT")
|
|
79
|
+
req = Net::HTTP::Put.new(uri.path, initheader = headers)
|
|
80
|
+
end
|
|
81
|
+
if(method.upcase == "DELETE")
|
|
82
|
+
req = Net::HTTP::Delete.new(uri.path, initheader = headers)
|
|
83
|
+
end
|
|
84
|
+
req.body = body
|
|
85
|
+
JSON.parse(https.request(req).body) rescue ""
|
|
86
|
+
end
|
|
87
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: runabove
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Olivier BONNAURE
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A simple runabove wrapper
|
|
14
|
+
email: olivier@solisoft.net
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/runabove.rb
|
|
20
|
+
homepage: http://rubygems.org/gems/runabove
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubyforge_project:
|
|
40
|
+
rubygems_version: 2.2.2
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: runabove wrapper
|
|
44
|
+
test_files: []
|