neuron-client 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -6
- data/lib/neuron-client/api.rb +1 -1
- data/lib/neuron-client/connection.rb +24 -9
- data/lib/neuron-client/report.rb +16 -0
- data/lib/neuron-client/version.rb +1 -1
- data/lib/neuron-client.rb +13 -1
- metadata +22 -22
data/Rakefile
CHANGED
@@ -22,9 +22,3 @@ task :console do
|
|
22
22
|
puts "Loading development console..."
|
23
23
|
system "irb -I #{File.join('.', 'lib')} -r #{File.join('.', 'lib', 'neuron-client')}"
|
24
24
|
end
|
25
|
-
|
26
|
-
task :force_release do
|
27
|
-
gem_helper = Bundler::GemHelper.new(Dir.pwd)
|
28
|
-
built_gem_path = gem_helper.build_gem
|
29
|
-
gem_helper.send(:rubygem_push, built_gem_path)
|
30
|
-
end
|
data/lib/neuron-client/api.rb
CHANGED
@@ -18,21 +18,31 @@ module Neuron
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def get(path="", attrs={})
|
21
|
-
|
21
|
+
format = attrs.delete(:format) || :json
|
22
|
+
RestClient.get("#{@url}/#{[path, format].select(&:present?).join(".")}?#{query_string(attrs)}",
|
23
|
+
format.present? ? {:content_type => format, :accept => format} : {}) do |response, request, result, &block|
|
24
|
+
# follow redirection
|
25
|
+
if [301, 302, 307].include? response.code
|
26
|
+
response.follow_redirection(request, result, &block)
|
27
|
+
end
|
28
|
+
|
22
29
|
case response.code
|
23
30
|
when 200
|
24
|
-
return Yajl.load(response.to_str)
|
31
|
+
return (format == :json ? Yajl.load(response.to_str) : response.to_str)
|
25
32
|
else
|
26
|
-
raise "Error : #{response.
|
33
|
+
raise "Error : #{response.inspect}"
|
27
34
|
end
|
28
35
|
end
|
29
36
|
end
|
30
37
|
|
31
38
|
def post(path="", form={}, attrs={})
|
32
|
-
|
39
|
+
format = attrs.delete(:format) || :json
|
40
|
+
RestClient.post("#{@url}/#{[path, format].select(&:present?).join(".")}?#{query_string(attrs)}",
|
41
|
+
(format == :json ? Yajl.dump(form) : form),
|
42
|
+
format.present? ? {:content_type => format, :accept => format} : {}) do |response, request, result, &block|
|
33
43
|
case response.code
|
34
44
|
when 201
|
35
|
-
return Yajl.load(response.to_str)
|
45
|
+
return (format == :json ? Yajl.load(response.to_str) : response.to_str)
|
36
46
|
else
|
37
47
|
raise "Error : #{response.code} - #{response.to_str}"
|
38
48
|
end
|
@@ -40,10 +50,13 @@ module Neuron
|
|
40
50
|
end
|
41
51
|
|
42
52
|
def put(path="", form={}, attrs={})
|
43
|
-
|
53
|
+
format = attrs.delete(:format) || :json
|
54
|
+
RestClient.put("#{@url}/#{[path, format].select(&:present?).join(".")}?#{query_string}",
|
55
|
+
(format == :json ? Yajl.dump(form) : form),
|
56
|
+
format.present? ? {:content_type => format, :accept => format} : {}) do |response, request, result, &block|
|
44
57
|
case response.code
|
45
58
|
when 200
|
46
|
-
return Yajl.load(response.to_str)
|
59
|
+
return (format == :json ? Yajl.load(response.to_str) : response.to_str)
|
47
60
|
else
|
48
61
|
raise "Error : #{response.code} - #{response.to_str}"
|
49
62
|
end
|
@@ -51,10 +64,12 @@ module Neuron
|
|
51
64
|
end
|
52
65
|
|
53
66
|
def delete(path="", attrs={})
|
54
|
-
|
67
|
+
format = attrs.delete(:format) || :json
|
68
|
+
RestClient.delete("#{@url}/#{[path, format].select(&:present?).join(".")}?#{query_string(attrs)}",
|
69
|
+
format.present? ? {:content_type => format, :accept => format} : {}) do |response, request, result, &block|
|
55
70
|
case response.code
|
56
71
|
when 200
|
57
|
-
return Yajl.load(response.to_str)
|
72
|
+
return (format == :json ? Yajl.load(response.to_str) : response.to_str)
|
58
73
|
else
|
59
74
|
raise "Error : #{response.code} - #{response.to_str}"
|
60
75
|
end
|
data/lib/neuron-client/report.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Neuron
|
2
|
+
module Client
|
3
|
+
class Report
|
4
|
+
include Connected
|
5
|
+
resource_name("report")
|
6
|
+
resources_name("reports")
|
7
|
+
|
8
|
+
attr_accessor :errors
|
9
|
+
attr_accessor :template, :parameters, :status
|
10
|
+
|
11
|
+
def result
|
12
|
+
self.class.connection.get("reports/#{id}/result", :format => "")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/neuron-client.rb
CHANGED
@@ -9,4 +9,16 @@ require "neuron-client/blocked_user_agent"
|
|
9
9
|
require "neuron-client/real_time_stats"
|
10
10
|
require "neuron-client/report"
|
11
11
|
require "neuron-client/s3_file"
|
12
|
-
require "neuron-client/zone"
|
12
|
+
require "neuron-client/zone"
|
13
|
+
|
14
|
+
class Object
|
15
|
+
def blank?
|
16
|
+
return true if self.nil?
|
17
|
+
return true if self.respond_to?(:empty) && self.empty?
|
18
|
+
false
|
19
|
+
end
|
20
|
+
|
21
|
+
def present?
|
22
|
+
!self.blank?
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neuron-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,12 +10,12 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-26 00:00:00.000000000 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rest-client
|
18
|
-
requirement: &
|
18
|
+
requirement: &2161396140 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: 1.6.3
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *2161396140
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: yajl-ruby
|
29
|
-
requirement: &
|
29
|
+
requirement: &2161395640 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ! '>='
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: 0.8.2
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *2161395640
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: rspec
|
40
|
-
requirement: &
|
40
|
+
requirement: &2161395180 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: 2.6.0
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *2161395180
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: simplecov
|
51
|
-
requirement: &
|
51
|
+
requirement: &2161394720 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: 0.4.2
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *2161394720
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rb-fsevent
|
62
|
-
requirement: &
|
62
|
+
requirement: &2161394220 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ! '>='
|
@@ -67,10 +67,10 @@ dependencies:
|
|
67
67
|
version: 0.4.1
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *2161394220
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: guard
|
73
|
-
requirement: &
|
73
|
+
requirement: &2161393760 !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|
76
76
|
- - ! '>='
|
@@ -78,10 +78,10 @@ dependencies:
|
|
78
78
|
version: 0.5.1
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
|
-
version_requirements: *
|
81
|
+
version_requirements: *2161393760
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: guard-bundler
|
84
|
-
requirement: &
|
84
|
+
requirement: &2161393300 !ruby/object:Gem::Requirement
|
85
85
|
none: false
|
86
86
|
requirements:
|
87
87
|
- - ! '>='
|
@@ -89,10 +89,10 @@ dependencies:
|
|
89
89
|
version: 0.1.3
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
|
-
version_requirements: *
|
92
|
+
version_requirements: *2161393300
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: guard-rspec
|
95
|
-
requirement: &
|
95
|
+
requirement: &2161392840 !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
97
97
|
requirements:
|
98
98
|
- - ! '>='
|
@@ -100,10 +100,10 @@ dependencies:
|
|
100
100
|
version: 0.4.0
|
101
101
|
type: :development
|
102
102
|
prerelease: false
|
103
|
-
version_requirements: *
|
103
|
+
version_requirements: *2161392840
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: fakeweb
|
106
|
-
requirement: &
|
106
|
+
requirement: &2161392380 !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|
109
109
|
- - ! '>='
|
@@ -111,10 +111,10 @@ dependencies:
|
|
111
111
|
version: 1.3.0
|
112
112
|
type: :development
|
113
113
|
prerelease: false
|
114
|
-
version_requirements: *
|
114
|
+
version_requirements: *2161392380
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
116
|
name: vcr
|
117
|
-
requirement: &
|
117
|
+
requirement: &2161391920 !ruby/object:Gem::Requirement
|
118
118
|
none: false
|
119
119
|
requirements:
|
120
120
|
- - ! '>='
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
version: 1.10.2
|
123
123
|
type: :development
|
124
124
|
prerelease: false
|
125
|
-
version_requirements: *
|
125
|
+
version_requirements: *2161391920
|
126
126
|
description: Neuron Admin Client Gem
|
127
127
|
email:
|
128
128
|
- devteam@rmmonline.com
|