rsc 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/lib/rsc.rb +43 -91
- metadata +21 -32
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 92e70abbd33d33717aa932ceb741f06b0ffd5eda
|
4
|
+
data.tar.gz: fe2397317f3f6a7374cd67ed7a5b6569eef50e5d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 249065339c9f84386163471d65a84b36ee5d7039e562beac841b051bfcd301eec0b4a070f73cb73e10e22f70158d942e667dcf31e017a9181258eebfc5266a8f
|
7
|
+
data.tar.gz: c84342971d81b6991e9a766592e762ef51f2f39c7f7f7d7d79a9c5d3718a4e3c2644bca7de15b3ebabc8403c2f8315f595d4b6567b0b83efb8f6ce64c87ecff9
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rsc.rb
CHANGED
@@ -1,105 +1,57 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: rsc.rb
|
4
|
+
|
3
5
|
require 'rexml/document'
|
6
|
+
require 'open-uri'
|
7
|
+
require 'drb'
|
4
8
|
|
5
|
-
class Rsc
|
6
|
-
include REXML
|
7
9
|
|
8
|
-
|
9
|
-
attr_accessor :package
|
10
|
+
class RSC
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
o = {:hostname => 'rscript.heroku.com', :package => ''}.merge(opts)
|
14
|
-
@hostname = o[:hostname]
|
15
|
-
@package = o[:package]
|
16
|
-
|
17
|
-
if @package.length > 0 then
|
18
|
-
jobs_to_methods(@package)
|
19
|
-
init_content_types
|
20
|
-
end
|
12
|
+
class Package
|
13
|
+
include REXML
|
21
14
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
if s then
|
26
|
-
@package = s
|
27
|
-
jobs_to_methods(@package)
|
28
|
-
init_content_types
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def jobs_to_methods(package)
|
35
|
-
#url = "http://rorbuilder.info/r/heroku/%s.rsf" % package
|
36
|
-
url = "http://%s/source/%s" % [@hostname, package]
|
37
|
-
puts 'url : ' + url
|
38
|
-
doc = Document.new(open(url, 'UserAgent' => 'ClientRscript').read)
|
39
|
-
a = XPath.match(doc.root, 'job/attribute::id')
|
40
|
-
a.each do |attr|
|
41
|
-
method_name = attr.value.to_s.gsub('-','_')
|
42
|
-
method = "def %s(param={}); query_method('%s', param); end" % [method_name, method_name]
|
43
|
-
self.instance_eval(method)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def init_content_types
|
48
|
-
|
49
|
-
@return_type = {}
|
50
|
-
|
51
|
-
xmlproc = Proc.new {
|
52
|
-
@doc = Document.new(@result.sub(/xmlns=["']http:\/\/www.w3.org\/1999\/xhtml["']/,''))
|
53
|
-
summary_node = XPath.match(@doc.root, 'summary/*')
|
54
|
-
if summary_node then
|
55
|
-
summary_node.each do |node|
|
56
|
-
|
57
|
-
if node.cdatas.length > 0 then
|
58
|
-
if node.cdatas.length == 1 then
|
59
|
-
content = node.cdatas.join.strip
|
60
|
-
else
|
61
|
-
if node.elements["@value='methods'"] then
|
62
|
-
|
63
|
-
else
|
64
|
-
content = node.cdatas.map {|x| x.to_s[/^\{.*\}$/] ? eval(x.to_s) : x.to_s}
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
else
|
69
|
-
content = node.text.to_s.gsub(/"/,'\"').gsub(/#/,'\#')
|
70
|
-
end
|
15
|
+
def initialize(drb_obj, parent_url, package)
|
16
|
+
|
17
|
+
@obj = drb_obj
|
71
18
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
records = XPath.match(@doc.root, 'records/*/text()')
|
81
|
-
method = "def %s(); %s; end" % [@doc.root.name, records.inspect] if records
|
19
|
+
@url = File.join(parent_url, package + '.rsf')
|
20
|
+
doc = Document.new(open(@url, 'UserAgent' => 'ClientRscript'){|x| x.read})
|
21
|
+
a = XPath.match(doc.root, 'job/attribute::id')
|
22
|
+
|
23
|
+
a.each do |attr|
|
24
|
+
method_name = attr.value.to_s.gsub('-','_')
|
25
|
+
method = "def %s(*args); run_job('%s', args) ; end" % \
|
26
|
+
([method_name] * 2)
|
82
27
|
self.instance_eval(method)
|
83
28
|
end
|
84
|
-
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
85
33
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
34
|
+
def run_job(method_name, *args)
|
35
|
+
|
36
|
+
args.flatten!(1)
|
37
|
+
params = args.pop if args.find {|x| x.is_a? Hash}
|
38
|
+
a = ['//job:' + method_name, @url, args].flatten(1)
|
39
|
+
params ? @obj.run(a, params) : @obj.run(a)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def initialize(drb_hostname='rse', parent_url)
|
92
45
|
|
46
|
+
@parent_url = parent_url
|
47
|
+
DRb.start_service
|
48
|
+
@obj = DRbObject.new(nil, "druby://#{drb_hostname}:61000")
|
93
49
|
end
|
50
|
+
|
51
|
+
private
|
94
52
|
|
95
|
-
def
|
96
|
-
|
97
|
-
param_list = params.to_a.map{|param, value| "%s=%s" % [param, CGI.escape(value)]}.join('&')
|
98
|
-
url = "%s%s?%s" % [base_url, method.gsub('_','-'), param_list]
|
99
|
-
response = open(url, 'UserAgent' => 'RScriptClient')
|
100
|
-
@result = response.read
|
101
|
-
@return_type[response.content_type].call
|
102
|
-
return self
|
53
|
+
def method_missing(method_name, *args)
|
54
|
+
Package.new @obj, @parent_url, method_name.to_s
|
103
55
|
end
|
104
56
|
|
105
|
-
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsc
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.1.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- James Robertson
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
|
-
cert_chain:
|
10
|
+
cert_chain:
|
12
11
|
- |
|
13
12
|
-----BEGIN CERTIFICATE-----
|
14
13
|
MIIDRDCCAiygAwIBAgIBADANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
@@ -30,46 +29,36 @@ cert_chain:
|
|
30
29
|
rFGEyvD2FamY5ONO7fEc+cszTqV8A3/SlFAd5O6/LFmt2pj7mwKtVYRe0UEEuFCX
|
31
30
|
g7cSQPGgok2TL2SAXni9sq+LMXO6PYwU
|
32
31
|
-----END CERTIFICATE-----
|
33
|
-
|
34
|
-
date: 2013-02-06 00:00:00 Z
|
32
|
+
date: 2013-07-20 00:00:00.000000000 Z
|
35
33
|
dependencies: []
|
36
|
-
|
37
34
|
description: formerly known as rcscript-client
|
38
35
|
email:
|
39
36
|
executables: []
|
40
|
-
|
41
37
|
extensions: []
|
42
|
-
|
43
38
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
files:
|
39
|
+
files:
|
46
40
|
- lib/rsc.rb
|
47
41
|
homepage:
|
48
42
|
licenses: []
|
49
|
-
|
43
|
+
metadata: {}
|
50
44
|
post_install_message:
|
51
45
|
rdoc_options: []
|
52
|
-
|
53
|
-
require_paths:
|
46
|
+
require_paths:
|
54
47
|
- lib
|
55
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: "0"
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
67
58
|
requirements: []
|
68
|
-
|
69
59
|
rubyforge_project:
|
70
|
-
rubygems_version:
|
60
|
+
rubygems_version: 2.0.0.rc.2
|
71
61
|
signing_key:
|
72
|
-
specification_version:
|
62
|
+
specification_version: 4
|
73
63
|
summary: rsc
|
74
64
|
test_files: []
|
75
|
-
|
metadata.gz.sig
CHANGED
Binary file
|