scout_scout 0.0.5 → 0.0.6

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.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source :rubygems
2
+
3
+ gem "hashie", "~> 0.1.8"
4
+ gem "httparty", "~> 0.5.0"
5
+ gem "nokogiri"
6
+
7
+ group :development do
8
+ gem "rspec", "~> 1.3.0"
9
+ gem "fakeweb"
10
+ gem "jeweler", "~> 1.5.0"
11
+ end
@@ -0,0 +1,27 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ crack (0.1.6)
5
+ fakeweb (1.3.0)
6
+ git (1.2.5)
7
+ hashie (0.1.8)
8
+ httparty (0.5.2)
9
+ crack (= 0.1.6)
10
+ jeweler (1.5.2)
11
+ bundler (~> 1.0.0)
12
+ git (>= 1.2.5)
13
+ rake
14
+ nokogiri (1.4.4)
15
+ rake (0.8.7)
16
+ rspec (1.3.1)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ fakeweb
23
+ hashie (~> 0.1.8)
24
+ httparty (~> 0.5.0)
25
+ jeweler (~> 1.5.0)
26
+ nokogiri
27
+ rspec (~> 1.3.0)
@@ -1,6 +1,6 @@
1
1
  = scout_scout
2
2
 
3
- A library for extracting data out of Scout[http//:scoutapp.com], a hosted monitoring service. This is experimental and likely to change.
3
+ A library for interacting with Scout[http//:scoutapp.com], a hosted monitoring service.
4
4
 
5
5
  require 'scout_scout'
6
6
  scout = ScoutScout.new('youraccountname', 'your@awesome.com', 'sekret')
@@ -35,6 +35,12 @@ A library for extracting data out of Scout[http//:scoutapp.com], a hosted monito
35
35
 
36
36
  #cluster metrics
37
37
  ScoutScout::Cluster.average('mem_used')
38
+
39
+ #create a server using the server with id=6 as the template.
40
+ ScoutScout::Server.create('heavy metal',:id => 6) => <#ScoutScout::Server>
41
+
42
+ #delete the server with id=10
43
+ ScoutScout::Server.delete(10) => true
38
44
 
39
45
  == Metrics
40
46
 
data/Rakefile CHANGED
@@ -1,29 +1,22 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require 'bundler'
2
+ Bundler.setup(:default, :development)
3
+
3
4
  $LOAD_PATH.unshift 'lib'
4
5
  require 'scout_scout/version'
5
6
 
6
- begin
7
- require 'jeweler'
8
- Jeweler::Tasks.new do |gem|
9
- gem.version = ScoutScout::VERSION
10
- gem.name = "scout_scout"
11
- gem.summary = %Q{API wrapper for scout.com}
12
- gem.description = %Q{API wrapper for scout.com}
13
- gem.email = "jnewland@gmail.com"
14
- gem.homepage = "http://github.com/jnewland/scout_scout"
15
- gem.authors = ["Jesse Newland"]
16
- gem.add_development_dependency "rspec", "= 1.3.0"
17
- gem.add_development_dependency "fakeweb"
18
- gem.add_dependency "hashie", "~> 0.1.8"
19
- gem.add_dependency "httparty", "~> 0.5.0"
20
- gem.add_dependency "nokogiri"
21
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
22
- end
23
- Jeweler::GemcutterTasks.new
24
- rescue LoadError
25
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
7
+ require 'jeweler'
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.version = ScoutScout::VERSION
10
+ gem.name = "scout_scout"
11
+ gem.summary = %Q{API wrapper for scout.com}
12
+ gem.description = %Q{API wrapper for scout.com}
13
+ gem.email = "jnewland@gmail.com"
14
+ gem.homepage = "http://github.com/jnewland/scout_scout"
15
+ gem.authors = ["Jesse Newland"]
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ # dependencies are handled in Gemfile
26
18
  end
19
+ Jeweler::GemcutterTasks.new
27
20
 
28
21
  require 'spec/rake/spectask'
29
22
  Spec::Rake::SpecTask.new(:spec) do |spec|
@@ -37,8 +30,6 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
37
30
  spec.rcov = true
38
31
  end
39
32
 
40
- task :spec => :check_dependencies
41
-
42
33
  task :default => :spec
43
34
 
44
35
  require 'rake/rdoctask'
@@ -20,6 +20,37 @@ class ScoutScout::Server < Hashie::Mash
20
20
  ScoutScout::Server.new(response['clients'].first)
21
21
  end
22
22
  end
23
+
24
+ # Creates a new server. If an error occurs, a +ScoutScout::Error+ is raised.
25
+ #
26
+ # An optional existing server id can be used as a template:
27
+ # ScoutScout::Server.create('web server 12',:id => 99999)
28
+ #
29
+ # @return [ScoutScout::Server]
30
+ def self.create(name,options = {})
31
+ id = options[:id]
32
+ response = ScoutScout.post("/#{ScoutScout.account}/clients.xml",
33
+ :query => {:client => {:name => name, :copy_plugins_from_client_id => id}})
34
+
35
+ raise ScoutScout::Error, response['errors']['error'] if response['errors']
36
+
37
+ first(response.headers['id'].first.to_i)
38
+ end
39
+
40
+ # Delete a server by id. If an error occurs, a +ScoutScout::Error+ is raised.
41
+ #
42
+ # @return [true]
43
+ def self.delete(id)
44
+ response = ScoutScout.delete("/#{ScoutScout.account}/clients/#{id}.xml")
45
+
46
+ if response.headers['status'].first.match('404')
47
+ raise ScoutScout::Error, "Server Not Found"
48
+ elsif !response.headers['status'].first.match('200')
49
+ raise ScoutScout::Error, "An error occured"
50
+ else
51
+ return true
52
+ end
53
+ end
23
54
 
24
55
  # Search for servers by matching hostname via :host.
25
56
  #
@@ -1,3 +1,3 @@
1
1
  class ScoutScout
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -1,84 +1,86 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{scout_scout}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jesse Newland"]
12
- s.date = %q{2010-07-15}
12
+ s.date = %q{2011-04-10}
13
13
  s.description = %q{API wrapper for scout.com}
14
14
  s.email = %q{jnewland@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "lib/scout_scout.rb",
26
- "lib/scout_scout/alert.rb",
27
- "lib/scout_scout/cluster.rb",
28
- "lib/scout_scout/descriptor.rb",
29
- "lib/scout_scout/metric.rb",
30
- "lib/scout_scout/person.rb",
31
- "lib/scout_scout/plugin.rb",
32
- "lib/scout_scout/server.rb",
33
- "lib/scout_scout/trigger.rb",
34
- "lib/scout_scout/version.rb",
35
- "scout_scout.gemspec",
36
- "spec/fixtures/activities.xml",
37
- "spec/fixtures/client.xml",
38
- "spec/fixtures/client_by_hostname.xml",
39
- "spec/fixtures/clients.xml",
40
- "spec/fixtures/data.xml",
41
- "spec/fixtures/descriptors.xml",
42
- "spec/fixtures/plugin_data.xml",
43
- "spec/fixtures/plugins.xml",
44
- "spec/fixtures/triggers.xml",
45
- "spec/scout_scout_spec.rb",
46
- "spec/spec.opts",
47
- "spec/spec_helper.rb"
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "lib/scout_scout.rb",
27
+ "lib/scout_scout/alert.rb",
28
+ "lib/scout_scout/cluster.rb",
29
+ "lib/scout_scout/descriptor.rb",
30
+ "lib/scout_scout/metric.rb",
31
+ "lib/scout_scout/person.rb",
32
+ "lib/scout_scout/plugin.rb",
33
+ "lib/scout_scout/server.rb",
34
+ "lib/scout_scout/trigger.rb",
35
+ "lib/scout_scout/version.rb",
36
+ "scout_scout.gemspec",
37
+ "spec/fixtures/activities.xml",
38
+ "spec/fixtures/client.xml",
39
+ "spec/fixtures/client_by_hostname.xml",
40
+ "spec/fixtures/clients.xml",
41
+ "spec/fixtures/data.xml",
42
+ "spec/fixtures/descriptors.xml",
43
+ "spec/fixtures/plugin_data.xml",
44
+ "spec/fixtures/plugins.xml",
45
+ "spec/fixtures/triggers.xml",
46
+ "spec/scout_scout_spec.rb",
47
+ "spec/spec.opts",
48
+ "spec/spec_helper.rb"
48
49
  ]
49
50
  s.homepage = %q{http://github.com/jnewland/scout_scout}
50
- s.rdoc_options = ["--charset=UTF-8"]
51
51
  s.require_paths = ["lib"]
52
- s.rubygems_version = %q{1.3.6}
52
+ s.rubygems_version = %q{1.4.2}
53
53
  s.summary = %q{API wrapper for scout.com}
54
54
  s.test_files = [
55
55
  "spec/scout_scout_spec.rb",
56
- "spec/spec_helper.rb"
56
+ "spec/spec_helper.rb"
57
57
  ]
58
58
 
59
59
  if s.respond_to? :specification_version then
60
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
60
  s.specification_version = 3
62
61
 
63
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
64
- s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
65
- s.add_development_dependency(%q<fakeweb>, [">= 0"])
62
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
63
  s.add_runtime_dependency(%q<hashie>, ["~> 0.1.8"])
67
64
  s.add_runtime_dependency(%q<httparty>, ["~> 0.5.0"])
68
65
  s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
66
+ s.add_development_dependency(%q<rspec>, ["~> 1.3.0"])
67
+ s.add_development_dependency(%q<fakeweb>, [">= 0"])
68
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.0"])
69
69
  else
70
- s.add_dependency(%q<rspec>, ["= 1.3.0"])
71
- s.add_dependency(%q<fakeweb>, [">= 0"])
72
70
  s.add_dependency(%q<hashie>, ["~> 0.1.8"])
73
71
  s.add_dependency(%q<httparty>, ["~> 0.5.0"])
74
72
  s.add_dependency(%q<nokogiri>, [">= 0"])
73
+ s.add_dependency(%q<rspec>, ["~> 1.3.0"])
74
+ s.add_dependency(%q<fakeweb>, [">= 0"])
75
+ s.add_dependency(%q<jeweler>, ["~> 1.5.0"])
75
76
  end
76
77
  else
77
- s.add_dependency(%q<rspec>, ["= 1.3.0"])
78
- s.add_dependency(%q<fakeweb>, [">= 0"])
79
78
  s.add_dependency(%q<hashie>, ["~> 0.1.8"])
80
79
  s.add_dependency(%q<httparty>, ["~> 0.5.0"])
81
80
  s.add_dependency(%q<nokogiri>, [">= 0"])
81
+ s.add_dependency(%q<rspec>, ["~> 1.3.0"])
82
+ s.add_dependency(%q<fakeweb>, [">= 0"])
83
+ s.add_dependency(%q<jeweler>, ["~> 1.5.0"])
82
84
  end
83
85
  end
84
86
 
@@ -97,6 +97,25 @@ describe "ScoutScout" do
97
97
  end
98
98
  end
99
99
  end
100
+ describe '' do
101
+ before(:each) do
102
+ @scout_scout.stub_post('clients.xml?client[copy_plugins_from_client_id]=&client[name]=sweet%20new%20server',
103
+ 'client.xml', {:id => '1234'})
104
+ @scout_scout.stub_get('clients/1234.xml', 'client.xml')
105
+ end
106
+ it 'can be created' do
107
+ @server = ScoutScout::Server.create('sweet new server')
108
+ @server.id.should == 13431
109
+ end
110
+ end
111
+ describe '' do
112
+ before(:each) do
113
+ @scout_scout.stub_delete('clients/1234.xml','client.xml', {'status' => '200 OK'})
114
+ end
115
+ it 'can be deleted' do
116
+ ScoutScout::Server.delete(1234).should == true
117
+ end
118
+ end
100
119
  describe 'alert log' do
101
120
  before(:each) do
102
121
  @scout_scout.stub_get('clients/13431.xml', 'client.xml')
@@ -24,16 +24,16 @@ class ScoutScout
24
24
  FakeWeb.register_uri(:get, scout_url(path), options)
25
25
  end
26
26
 
27
- def stub_post(path, filename)
28
- FakeWeb.register_uri(:post, scout_url(path), :body => file_fixture(filename))
27
+ def stub_post(path, filename, headers = {})
28
+ FakeWeb.register_uri(:post, scout_url(path), {:body => file_fixture(filename)}.merge(headers))
29
29
  end
30
30
 
31
31
  def stub_put(path, filename)
32
32
  FakeWeb.register_uri(:put, scout_url(path), :body => file_fixture(filename))
33
33
  end
34
34
 
35
- def stub_delete(path, filename)
36
- FakeWeb.register_uri(:delete, scout_url(path), :body => file_fixture(filename))
35
+ def stub_delete(path, filename, headers = {})
36
+ FakeWeb.register_uri(:delete, scout_url(path), {:body => file_fixture(filename)}.merge(headers))
37
37
  end
38
38
 
39
39
  def stub_http_response_with(filename)
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_scout
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 19
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 5
9
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jesse Newland
@@ -14,75 +15,101 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-07-15 00:00:00 -04:00
18
+ date: 2011-04-10 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 3
30
- - 0
31
- version: 1.3.0
32
- type: :development
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: fakeweb
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- version: "0"
44
- type: :development
45
- version_requirements: *id002
46
- - !ruby/object:Gem::Dependency
22
+ type: :runtime
47
23
  name: hashie
48
- prerelease: false
49
- requirement: &id003 !ruby/object:Gem::Requirement
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ none: false
50
26
  requirements:
51
27
  - - ~>
52
28
  - !ruby/object:Gem::Version
29
+ hash: 11
53
30
  segments:
54
31
  - 0
55
32
  - 1
56
33
  - 8
57
34
  version: 0.1.8
58
- type: :runtime
59
- version_requirements: *id003
35
+ prerelease: false
36
+ requirement: *id001
60
37
  - !ruby/object:Gem::Dependency
38
+ type: :runtime
61
39
  name: httparty
62
- prerelease: false
63
- requirement: &id004 !ruby/object:Gem::Requirement
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
+ none: false
64
42
  requirements:
65
43
  - - ~>
66
44
  - !ruby/object:Gem::Version
45
+ hash: 11
67
46
  segments:
68
47
  - 0
69
48
  - 5
70
49
  - 0
71
50
  version: 0.5.0
72
- type: :runtime
73
- version_requirements: *id004
51
+ prerelease: false
52
+ requirement: *id002
74
53
  - !ruby/object:Gem::Dependency
54
+ type: :runtime
75
55
  name: nokogiri
56
+ version_requirements: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ prerelease: false
66
+ requirement: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ type: :development
69
+ name: rspec
70
+ version_requirements: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ hash: 27
76
+ segments:
77
+ - 1
78
+ - 3
79
+ - 0
80
+ version: 1.3.0
76
81
  prerelease: false
77
- requirement: &id005 !ruby/object:Gem::Requirement
82
+ requirement: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ type: :development
85
+ name: fakeweb
86
+ version_requirements: &id005 !ruby/object:Gem::Requirement
87
+ none: false
78
88
  requirements:
79
89
  - - ">="
80
90
  - !ruby/object:Gem::Version
91
+ hash: 3
81
92
  segments:
82
93
  - 0
83
94
  version: "0"
84
- type: :runtime
85
- version_requirements: *id005
95
+ prerelease: false
96
+ requirement: *id005
97
+ - !ruby/object:Gem::Dependency
98
+ type: :development
99
+ name: jeweler
100
+ version_requirements: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 1
108
+ - 5
109
+ - 0
110
+ version: 1.5.0
111
+ prerelease: false
112
+ requirement: *id006
86
113
  description: API wrapper for scout.com
87
114
  email: jnewland@gmail.com
88
115
  executables: []
@@ -94,7 +121,8 @@ extra_rdoc_files:
94
121
  - README.rdoc
95
122
  files:
96
123
  - .document
97
- - .gitignore
124
+ - Gemfile
125
+ - Gemfile.lock
98
126
  - LICENSE
99
127
  - README.rdoc
100
128
  - Rakefile
@@ -126,28 +154,32 @@ homepage: http://github.com/jnewland/scout_scout
126
154
  licenses: []
127
155
 
128
156
  post_install_message:
129
- rdoc_options:
130
- - --charset=UTF-8
157
+ rdoc_options: []
158
+
131
159
  require_paths:
132
160
  - lib
133
161
  required_ruby_version: !ruby/object:Gem::Requirement
162
+ none: false
134
163
  requirements:
135
164
  - - ">="
136
165
  - !ruby/object:Gem::Version
166
+ hash: 3
137
167
  segments:
138
168
  - 0
139
169
  version: "0"
140
170
  required_rubygems_version: !ruby/object:Gem::Requirement
171
+ none: false
141
172
  requirements:
142
173
  - - ">="
143
174
  - !ruby/object:Gem::Version
175
+ hash: 3
144
176
  segments:
145
177
  - 0
146
178
  version: "0"
147
179
  requirements: []
148
180
 
149
181
  rubyforge_project:
150
- rubygems_version: 1.3.6
182
+ rubygems_version: 1.4.2
151
183
  signing_key:
152
184
  specification_version: 3
153
185
  summary: API wrapper for scout.com
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC