uptrends 0.2.2 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 230b460fe57835d0f5e24d44f9f05376aad9490e
4
- data.tar.gz: 9fb5efd271b67f20899b642f31f52e82d918efe8
3
+ metadata.gz: 69a8350abcaf27e3eb580f7d57966bbdb33383c0
4
+ data.tar.gz: 657d3938ead33d2be4b33edcb7380e8361d3f938
5
5
  SHA512:
6
- metadata.gz: e4e36b3e967428080f4664ea8a2b11faf9d52bdee3a74c767c147b0d4461d95b7e8cae34f9b56a44e810a4ed0ec4b6473bed31c56be6a705f131ed2f78277748
7
- data.tar.gz: 748c9ef2dbe28a4ab46a46b54c324a908c6835342562161c14e6e8562a85bf1c335e4faa2766598cc6629f3392ce252c7ffd670964822929cf74403cefe47ef6
6
+ metadata.gz: 7d4e7c9662118f8a2028e72f8798ddecb0ec6fbbb728e48fb369af38cee7f08126e6919b9eaf68943a6be086fc1b4a875e8642b824f48d3a19979e818793c52e
7
+ data.tar.gz: b8518d4d9d8765cd5fdcb1f5b69ed71e58316b34e478fb8f681b72316013bd597a021fe937850c83898fbb2427525d5991bc9b970dd3d8c3229b0daeaac6d8ee
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+
5
+ env: UPTRENDS_USERNAME=my@username.com UPTRENDS_PASSWORD=password
6
+
7
+ branches:
8
+ only:
9
+ - master
data/Gemfile CHANGED
@@ -3,10 +3,12 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in uptrends.gemspec
4
4
  gemspec
5
5
 
6
- gem 'httparty'
6
+ gem "httparty", "~> 0.13"
7
+ gem "activesupport", "~> 4.1.4"
7
8
 
8
9
  group :test do
9
10
  gem 'webmock'
10
11
  gem 'vcr'
11
12
  gem 'rake'
13
+ gem "codeclimate-test-reporter", require: nil
12
14
  end
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Uptrends
2
2
 
3
- This is a ruby wrapper around the [Uptrends API][2].
3
+ [![Code Climate](https://codeclimate.com/github/jasonwbarnett/uptrends-gem/badges/gpa.svg)](https://codeclimate.com/github/jasonwbarnett/uptrends-gem) [![Test Coverage](https://codeclimate.com/github/jasonwbarnett/uptrends-gem/badges/coverage.svg)](https://codeclimate.com/github/jasonwbarnett/uptrends-gem) [![Build Status](https://travis-ci.org/jasonwbarnett/uptrends-gem.svg?branch=master)](https://travis-ci.org/jasonwbarnett/uptrends-gem)
4
+
5
+ This is a ruby wrapper around the [Uptrends API][2]. Uptrends is a monitoring service that let's you monitor Web pages, Web services, Mail servers, Database servers, DNS, SSL certificates, FTP and more.
4
6
 
5
7
  ## Installation
6
8
 
@@ -40,7 +42,7 @@ Let's select the first probe and look at it's attributes
40
42
  # => #<Uptrends::Probe:0x0000010336cac8 ...>
41
43
 
42
44
  p.attributes
43
- # => [:guid, :name, :url, :port, :checkfrequency, :probetype, :isactive, :generatealert, :notes, :performancelimit1, :performancelimit2, :erroronlimit1, :erroronlimit2, :minbytes, :erroronminbytes, :timeout, :tcpconnecttimeout, :matchpattern, :dnslookupmode, :useragent, :username, :password, :iscompetitor, :checkpoints, :httpmethod, :postdata]
45
+ # => [:guid, :name, :url, :port, :check_frequency, :probe_type, :is_active, :generate_alert, :notes, :performance_limit1, :performance_limit2, :error_on_limit1, :error_on_limit2, :min_bytes, :error_on_min_bytes, :timeout, :tcp_connect_timeout, :match_pattern, :dns_lookup_mode, :user_agent, :user_name, :password, :is_competitor, :checkpoints, :http_method, :post_data]
44
46
 
45
47
  p.guid
46
48
  # => "7ef43a1b255949f5a052444348971690"
@@ -54,7 +56,7 @@ Let's select the first probe __group__ and look at it's attributes
54
56
  # => #<Uptrends::ProbeGroup:0x000001021594f8 ...>
55
57
 
56
58
  pg.attributes
57
- # => [:guid, :name, :isall, :isclientprobegroup]
59
+ # => [:guid, :name, :is_all, :is_client_probe_group]
58
60
 
59
61
  pg.guid
60
62
  # => "c8d6a0f704494c37823850f3d4fd4273"
@@ -68,8 +70,10 @@ If you wanted to update the probe, all you need to do is change as many attribut
68
70
 
69
71
  p.name = "My Probe's NEW name"
70
72
  # => "My Probe's NEW name"
73
+
71
74
  response = u.update_probe(p)
72
75
  # => #<HTTParty::Response:0x10 parsed_response=nil, @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"cache-control"=>["private"], "server"=>["Microsoft-IIS/7.5"], "x-servername"=>["OBI"], "x-aspnet-version"=>["4.0.30319"], "x-powered-by"=>["ASP.NET"], "x-server"=>["OBI"], "date"=>["Sat, 26 Jul 2014 20:21:00 GMT"], "connection"=>["close"], "content-length"=>["0"]}>
76
+
73
77
  response.response
74
78
  # => #<Net::HTTPOK 200 OK readbody=true>
75
79
 
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'uptrends/api_client'
3
3
 
4
- (puts "You must set both the \"uptrends_username\" and \"uptrends_password\" environment variables, exiting..."; exit 1;) unless ENV['uptrends_username'] && ENV['uptrends_password']
4
+ (puts "You must set both the \"UPTRENDS_USERNAME\" and \"UPTRENDS_PASSWORD\" environment variables, exiting..."; exit 1;) unless ENV['UPTRENDS_USERNAME'] && ENV['UPTRENDS_PASSWORD']
5
5
 
6
- u = Uptrends::ApiClient.new(username: ENV['uptrends_username'], password: ENV['uptrends_password'])
6
+ u = Uptrends::ApiClient.new(username: ENV['UPTRENDS_USERNAME'], password: ENV['UPTRENDS_PASSWORD'])
7
7
 
8
8
  # select our probe group by name
9
9
  linux_probe_group = u.probe_groups.select { |x| x.name =~ /Linux/}.first
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'uptrends/api_client'
3
3
 
4
- (puts "You must set both the \"uptrends_username\" and \"uptrends_password\" environment variables, exiting..."; exit 1;) unless ENV['uptrends_username'] && ENV['uptrends_password']
4
+ (puts "You must set both the \"UPTRENDS_USERNAME\" and \"UPTRENDS_PASSWORD\" environment variables, exiting..."; exit 1;) unless ENV['UPTRENDS_USERNAME'] && ENV['UPTRENDS_PASSWORD']
5
5
 
6
- u = Uptrends::ApiClient.new(username: ENV['uptrends_username'], password: ENV['uptrends_password'])
6
+ u = Uptrends::ApiClient.new(username: ENV['UPTRENDS_USERNAME'], password: ENV['UPTRENDS_PASSWORD'])
7
7
 
8
8
  u.probes.each do |x|
9
- next if x.dnslookupmode == 'Local' && x.timeout == 20000 && x.tcpconnecttimeout == 5000
9
+ next if x.dns_lookup_mode == 'Local' && x.timeout == 20000 && x.tcp_connect_timeout == 5000
10
10
 
11
- x.dnslookupmode = 'Local'
11
+ x.dns_lookup_mode = 'Local'
12
12
  x.timeout = 20000
13
- x.tcpconnecttimeout = 5000
13
+ x.tcp_connect_timeout = 5000
14
14
 
15
15
  puts "Updating the \"#{x.name}\" probe now... "
16
16
  u.update_probe(x)
@@ -1,6 +1,7 @@
1
1
  require "httparty"
2
2
  require "uptrends/probe"
3
3
  require "uptrends/probe_group"
4
+ require "uptrends/utils"
4
5
 
5
6
  module Uptrends
6
7
  class ApiClient
@@ -32,17 +33,27 @@ module Uptrends
32
33
 
33
34
  private
34
35
  def get_probes
35
- parsed_response = self.class.get('/probes').parsed_response
36
- probes = parsed_response.inject([]) do |memo, x|
37
- memo << Uptrends::Probe.new(x)
38
- memo
39
- end
36
+ get_all(Uptrends::Probe)
40
37
  end
41
38
 
42
39
  def get_probe_groups
43
- parsed_response = self.class.get('/probegroups').parsed_response
44
- probe_groups = parsed_response.inject([]) do |memo, x|
45
- memo << Uptrends::ProbeGroup.new(x)
40
+ get_all(Uptrends::ProbeGroup)
41
+ end
42
+
43
+ def get_all(type)
44
+ case type.new
45
+ when Uptrends::ProbeGroup
46
+ uri = '/probegroups'
47
+ when Uptrends::Probe
48
+ uri = '/probes'
49
+ else
50
+ fail("You passed an unknown type. Try Uptrends::Probe or Uptrends::ProbeGroup")
51
+ end
52
+
53
+ parsed_response = self.class.get(uri).parsed_response
54
+
55
+ all = parsed_response.inject([]) do |memo, x|
56
+ memo << type.new(x)
46
57
  memo
47
58
  end
48
59
  end
@@ -75,7 +86,7 @@ module Uptrends
75
86
  end
76
87
 
77
88
  def update_probe(probe)
78
- self.class.put("/probes/#{probe.guid}", body: probe.gen_request_body)
89
+ self.class.put("/probes/#{probe.guid}", body: Uptrends::Utils.gen_request_body(probe))
79
90
  end
80
91
 
81
92
  def delete_probe(probe)
@@ -85,12 +96,22 @@ module Uptrends
85
96
  @probes.delete_if { |x| x.guid == probe.guid }
86
97
  end
87
98
 
88
- def create_http_probe(options = {}) #url, match_pattern = nil)
89
- base_hash = {"Name"=>"", "URL"=>"", "CheckFrequency"=>5, "IsActive"=>true, "GenerateAlert"=>true, "Notes"=>"", "PerformanceLimit1"=>60000, "PerformanceLimit2"=>60000, "ErrorOnLimit1"=>false, "ErrorOnLimit2"=>false, "MinBytes"=>0, "ErrorOnMinBytes"=>false, "Timeout"=>30000, "TcpConnectTimeout"=>10000, "MatchPattern"=>"", "DnsLookupMode"=>"Local", "UserAgent"=>"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;)", "UserName"=>"", "Password"=>"", "IsCompetitor"=>false, "Checkpoints"=>"", "HttpMethod"=>"Get", "PostData"=>""}
99
+ def create_http_probe(options = {})
100
+ name = options[:name] ? options[:name] : fail("You must provide a name!")
101
+ url = options[:url] ? options[:url] : fail("You must provide a URL!")
102
+ match_pattern = options[:match_pattern]
90
103
 
91
- name = options[:name] ? options[:name] : fail("You must provide a name!")
92
- url = options[:url] ? options[:url] : fail("You must provide a URL!")
93
- match_pattern = options[:match_pattern] ? options[:match_pattern] : nil
104
+ probe = Uptrends::Probe.new(gen_new_probe_hash(name, url, match_pattern))
105
+ response = self.class.post("/probes", body: Uptrends::Utils.gen_request_body(probe))
106
+ new_probe = Uptrends::Probe.new(response.parsed_response)
107
+
108
+ @probes ||= get_probes
109
+ @probes << new_probe
110
+ end
111
+
112
+ private
113
+ def gen_new_probe_hash(name, url, match_pattern = nil)
114
+ base_hash = {"Name"=>"", "URL"=>"", "CheckFrequency"=>5, "IsActive"=>true, "GenerateAlert"=>true, "Notes"=>"", "PerformanceLimit1"=>60000, "PerformanceLimit2"=>60000, "ErrorOnLimit1"=>false, "ErrorOnLimit2"=>false, "MinBytes"=>0, "ErrorOnMinBytes"=>false, "Timeout"=>30000, "TcpConnectTimeout"=>10000, "MatchPattern"=>"", "DnsLookupMode"=>"Local", "UserAgent"=>"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;)", "UserName"=>"", "Password"=>"", "IsCompetitor"=>false, "Checkpoints"=>"", "HttpMethod"=>"Get", "PostData"=>""}
94
115
 
95
116
  if url =~ %r{^https:}i
96
117
  base_hash.merge!({"Name"=>name, "URL"=>url, "ProbeType"=>"Https", "Port"=>443})
@@ -102,14 +123,8 @@ module Uptrends
102
123
 
103
124
  base_hash.merge!({"MatchPattern"=>match_pattern}) unless match_pattern.nil?
104
125
 
105
- p = Uptrends::Probe.new(base_hash)
106
- response = self.class.post("/probes", body: p.gen_request_body)
107
- new_probe = Uptrends::Probe.new(response.parsed_response)
108
-
109
- @probes ||= get_probes
110
- @probes << new_probe
126
+ base_hash
111
127
  end
112
128
 
113
-
114
129
  end
115
130
  end
@@ -1,69 +1,19 @@
1
1
  require 'json'
2
+ require 'uptrends/utils'
2
3
 
3
4
  module Uptrends
4
5
  class Probe
5
- attr_reader :guid, :original_hash, :original_keys, :attributes
6
- attr_accessor :name, :url, :port, :checkfrequency, :probetype, :isactive, :generatealert, :notes, :performancelimit1, :performancelimit2, :erroronlimit1, :erroronlimit2, :minbytes, :erroronminbytes, :timeout, :tcpconnecttimeout, :matchpattern, :dnslookupmode, :useragent, :username, :password, :iscompetitor, :checkpoints, :httpmethod, :postdata
7
6
 
8
- def initialize(probe_hash = {})
9
- @original_hash = probe_hash
10
- @original_keys = probe_hash.keys
11
- @attributes = probe_hash.keys.map{|x| x.downcase.to_sym }
12
-
13
- @guid = probe_hash["Guid"] ? probe_hash["Guid"] : nil
14
- @name = probe_hash["Name"] ? probe_hash["Name"] : nil
15
- @url = probe_hash["URL"] ? probe_hash["URL"] : nil
16
- @port = probe_hash["Port"] ? probe_hash["Port"] : nil
17
- @checkfrequency = probe_hash["CheckFrequency"] ? probe_hash["CheckFrequency"] : nil
18
- @probetype = probe_hash["ProbeType"] ? probe_hash["ProbeType"] : nil
19
- @isactive = probe_hash["IsActive"] ? probe_hash["IsActive"] : nil
20
- @generatealert = probe_hash["GenerateAlert"] ? probe_hash["GenerateAlert"] : nil
21
- @notes = probe_hash["Notes"] ? probe_hash["Notes"] : nil
22
- @performancelimit1 = probe_hash["PerformanceLimit1"] ? probe_hash["PerformanceLimit1"] : nil
23
- @performancelimit2 = probe_hash["PerformanceLimit2"] ? probe_hash["PerformanceLimit2"] : nil
24
- @erroronlimit1 = probe_hash["ErrorOnLimit1"] ? probe_hash["ErrorOnLimit1"] : nil
25
- @erroronlimit2 = probe_hash["ErrorOnLimit2"] ? probe_hash["ErrorOnLimit2"] : nil
26
- @minbytes = probe_hash["MinBytes"] ? probe_hash["MinBytes"] : nil
27
- @erroronminbytes = probe_hash["ErrorOnMinBytes"] ? probe_hash["ErrorOnMinBytes"] : nil
28
- @timeout = probe_hash["Timeout"] ? probe_hash["Timeout"] : nil
29
- @tcpconnecttimeout = probe_hash["TcpConnectTimeout"] ? probe_hash["TcpConnectTimeout"] : nil
30
- @matchpattern = probe_hash["MatchPattern"] ? probe_hash["MatchPattern"] : nil
31
- @dnslookupmode = probe_hash["DnsLookupMode"] ? probe_hash["DnsLookupMode"] : nil
32
- @useragent = probe_hash["UserAgent"] ? probe_hash["UserAgent"] : nil
33
- @username = probe_hash["UserName"] ? probe_hash["UserName"] : nil
34
- @password = probe_hash["Password"] ? probe_hash["Password"] : nil
35
- @iscompetitor = probe_hash["IsCompetitor"] ? probe_hash["IsCompetitor"] : nil
36
- @checkpoints = probe_hash["Checkpoints"] ? probe_hash["Checkpoints"] : nil
37
-
38
- if probetype == "Http"
39
- @httpmethod = probe_hash["HttpMethod"]
40
- @postdata = probe_hash["PostData"]
41
- end
42
- end
7
+ attr_reader :original_hash, :attributes
43
8
 
44
- alias :probetype= :probetype=
45
- alias :type :probetype
46
-
47
- def gen_request_body
48
- new_hash = original_keys.inject({}) do |memo,key|
49
- if key == 'Guid'
50
- memo
51
- else
52
- memo[key] = self.send(key.downcase.to_sym)
53
- memo
54
- end
55
- end
9
+ def initialize(probe_hash = {})
10
+ @original_hash = probe_hash
56
11
 
57
- request_body = JSON.dump(new_hash)
12
+ Uptrends::Utils.gen_and_set_accessors(self)
58
13
  end
59
14
 
60
15
  def to_s
61
- string = []
62
- original_keys.each do |key|
63
- string << "#{key}: #{self.send(key.downcase.to_sym)}"
64
- end
65
-
66
- "#{string.join("\n")}"
16
+ Uptrends::Utils.to_s(self)
67
17
  end
68
18
 
69
19
  end
@@ -1,43 +1,19 @@
1
1
  require 'json'
2
+ require 'uptrends/utils'
2
3
 
3
4
  module Uptrends
4
5
  class ProbeGroup
5
- attr_reader :original_hash, :original_keys, :attributes
6
6
 
7
- attr_reader :guid, :isall, :isclientprobegroup
8
- attr_accessor :name
7
+ attr_reader :original_hash, :attributes
9
8
 
10
9
  def initialize(probe_group_hash = {})
11
10
  @original_hash = probe_group_hash
12
- @original_keys = probe_group_hash.keys
13
- @attributes = probe_group_hash.keys.map{|x| x.downcase.to_sym }
14
11
 
15
- @guid = probe_group_hash["Guid"] ? probe_group_hash["Guid"] : nil
16
- @name = probe_group_hash["Name"]
17
- @isall = probe_group_hash["IsAll"]
18
- @isclientprobegroup = probe_group_hash["IsClientProbeGroup"]
19
- end
20
-
21
- def gen_request_body
22
- new_hash = original_keys.inject({}) do |memo,key|
23
- if key == 'Guid'
24
- memo
25
- else
26
- memo[key] = self.send(key.downcase.to_sym)
27
- memo
28
- end
29
- end
30
-
31
- request_body = JSON.dump(new_hash)
12
+ Uptrends::Utils.gen_and_set_accessors(self)
32
13
  end
33
14
 
34
15
  def to_s
35
- string = []
36
- original_keys.each do |key|
37
- string << "#{key}: #{self.send(key.downcase.to_sym)}"
38
- end
39
-
40
- "#{string.join("\n")}"
16
+ Uptrends::Utils.to_s(self)
41
17
  end
42
18
 
43
19
  end
@@ -0,0 +1,49 @@
1
+ require 'json'
2
+ require 'active_support/inflector'
3
+
4
+ module Uptrends
5
+ class Utils
6
+ def self.gen_request_body(object)
7
+ new_hash = object.original_hash.inject({}) do |memo,(k,v)|
8
+ if k == 'Guid'
9
+ memo
10
+ else
11
+ memo[k] = object.send(k.underscore)
12
+ memo
13
+ end
14
+ end
15
+
16
+ request_body = JSON.dump(new_hash)
17
+ end
18
+
19
+ def self.to_s(object)
20
+ string = []
21
+ object.attributes.each do |attr|
22
+ string << "#{attr}: #{object.send(attr)}"
23
+ end
24
+
25
+ "#{string.join("\n")}"
26
+ end
27
+
28
+ # This method sets up all of our attr_accessor so we can easily edit probe attributes
29
+ def self.gen_and_set_accessors(object)
30
+ attributes = []
31
+ object.original_hash.each_pair do |k,v|
32
+
33
+ k = k.underscore
34
+ case k
35
+ when "guid"
36
+ object.class.send(:attr_reader, k)
37
+ object.instance_variable_set("@#{k}", v)
38
+ else
39
+ object.class.send(:attr_accessor, k)
40
+ object.send("#{k}=", v)
41
+ end
42
+ attributes << k.to_sym
43
+
44
+ end
45
+ object.instance_variable_set(:@attributes, attributes)
46
+ end
47
+
48
+ end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module Uptrends
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,6 +1,10 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
1
3
  require_relative '../lib/uptrends'
2
4
  require_relative '../lib/uptrends/api_client'
3
5
  require_relative '../lib/uptrends/probe'
6
+ require_relative '../lib/uptrends/probe_group'
7
+ require_relative '../lib/uptrends/utils'
4
8
  require 'minitest/autorun'
5
9
  require 'webmock/minitest'
6
10
  require 'vcr'
@@ -9,4 +13,13 @@ require 'vcr'
9
13
  VCR.configure do |c|
10
14
  c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
11
15
  c.hook_into :webmock
16
+ c.ignore_hosts 'codeclimate.com'
17
+ end
18
+
19
+ @username = ENV['UPTRENDS_USERNAME']
20
+ @password = ENV['UPTRENDS_PASSWORD']
21
+
22
+ if @username.nil? || @password.nil?
23
+ $stderr.puts "You must define UPTRENDS_USERNAME and UPTRENDS_PASSWORD as environment variables, exiting..."
24
+ exit 1
12
25
  end
@@ -1,15 +1,15 @@
1
1
  require_relative '../spec_helper'
2
2
 
3
3
  describe Uptrends::ApiClient do
4
- let(:username) { ENV['uptrends_username'] }
5
- let(:password) { ENV['uptrends_password'] }
4
+ let(:username) { ENV['UPTRENDS_USERNAME'] }
5
+ let(:password) { ENV['UPTRENDS_PASSWORD'] }
6
6
 
7
7
  describe "Setting up testing" do
8
- it "should have a username defined in an env varible: uptrends_username" do
8
+ it "should have a username defined in an env varible: UPTRENDS_USERNAME" do
9
9
  username.wont_be_nil
10
10
  end
11
11
 
12
- it "should have a password defined in an env varible: uptrends_password" do
12
+ it "should have a password defined in an env varible: UPTRENDS_PASSWORD" do
13
13
  password.wont_be_nil
14
14
  end
15
15
  end
@@ -76,7 +76,7 @@ describe Uptrends::ApiClient do
76
76
  end
77
77
 
78
78
  it "must has a #get_probes method" do
79
- uac.must_respond_to :get_probes
79
+ uac.wont_respond_to :get_probes
80
80
  end
81
81
 
82
82
  it "must have a #probes method" do
@@ -0,0 +1,40 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Uptrends::ProbeGroup do
4
+ let(:up) { Uptrends::ProbeGroup.new({"Guid" => "myguid", "Name" => "myvalue", "other" => "thing"}) }
5
+
6
+ it "#guid" do
7
+ up.must_respond_to :guid
8
+ up.guid.must_equal "myguid"
9
+ end
10
+
11
+ it "#guid= must NOT exist" do
12
+ up.wont_respond_to :guid=
13
+ end
14
+
15
+ it "#name" do
16
+ up.must_respond_to :name
17
+ up.name.must_equal "myvalue"
18
+ end
19
+
20
+ it "#name=" do
21
+ up.must_respond_to :name=
22
+ up.name = "updates to hello_you="
23
+ up.name.must_equal "updates to hello_you="
24
+ end
25
+
26
+ it "#other" do
27
+ up.must_respond_to :other
28
+ up.other.must_equal "thing"
29
+ end
30
+
31
+ it "#other=" do
32
+ up.must_respond_to :other=
33
+ up.other = "updates to other"
34
+ up.other.must_equal "updates to other"
35
+ end
36
+
37
+ it "#to_s" do
38
+ up.to_s.must_equal "guid: myguid\nname: myvalue\nother: thing"
39
+ end
40
+ end
@@ -1,16 +1,40 @@
1
1
  require_relative '../spec_helper'
2
2
 
3
3
  describe Uptrends::Probe do
4
- let(:up) { Uptrends::Probe.new }
5
- %w[guid name url port checkfrequency probetype isactive generatealert notes performancelimit1 performancelimit2 erroronlimit1 erroronlimit2 minbytes erroronminbytes timeout tcpconnecttimeout matchpattern dnslookupmode useragent username password iscompetitor checkpoints httpmethod postdata].each do |attr|
6
- it "should have a ##{attr} reader" do
7
- up.send(attr.to_sym)
8
- end
4
+ let(:up) { Uptrends::Probe.new({"Guid" => "myguid", "HelloYou" => "myvalue", "other" => "thing"}) }
5
+
6
+ it "#guid" do
7
+ up.must_respond_to :guid
8
+ up.guid.must_equal "myguid"
9
+ end
10
+
11
+ it "#guid= must NOT exist" do
12
+ up.wont_respond_to :guid=
13
+ end
14
+
15
+ it "#hello_you" do
16
+ up.must_respond_to :hello_you
17
+ up.hello_you.must_equal "myvalue"
18
+ end
19
+
20
+ it "#hello_you=" do
21
+ up.must_respond_to :hello_you=
22
+ up.hello_you = "updates to hello_you="
23
+ up.hello_you.must_equal "updates to hello_you="
24
+ end
25
+
26
+ it "#other" do
27
+ up.must_respond_to :other
28
+ up.other.must_equal "thing"
29
+ end
30
+
31
+ it "#other=" do
32
+ up.must_respond_to :other=
33
+ up.other = "updates to other"
34
+ up.other.must_equal "updates to other"
9
35
  end
10
36
 
11
- %w[name url port checkfrequency probetype isactive generatealert notes performancelimit1 performancelimit2 erroronlimit1 erroronlimit2 minbytes erroronminbytes timeout tcpconnecttimeout matchpattern dnslookupmode useragent username password iscompetitor checkpoints httpmethod postdata].each do |attr|
12
- it "should have a ##{attr} writer" do
13
- up.send("#{attr}=", "some_value")
14
- end
37
+ it "#to_s" do
38
+ up.to_s.must_equal "guid: myguid\nhello_you: myvalue\nother: thing"
15
39
  end
16
40
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Jason Barnett"]
10
10
  spec.email = ["J@sonBarnett.com"]
11
11
  spec.summary = %q{Ruby wrapper around the Uptrends API, http://www.uptrends.com/}
12
- spec.description = %q{This is a ruby wrapper around the Uptrends API. Uptrends is a monitoring service that let's you monitor Web pages, Web services, Mail servers, Database servers, DNS, SSL certificates, FTP anod more.}
12
+ spec.description = %q{This is a ruby wrapper around the Uptrends API. Uptrends is a monitoring service that let's you monitor Web pages, Web services, Mail servers, Database servers, DNS, SSL certificates, FTP and more.}
13
13
  spec.homepage = "https://github.com/jasonwbarnett/uptrends-gem"
14
14
  spec.license = "MIT"
15
15
 
@@ -18,5 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'httparty', "~> 0.13"
21
+ spec.add_dependency "httparty", "~> 0.13"
22
+ spec.add_dependency "activesupport", "~> 4.1.4"
22
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uptrends
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Barnett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-02 00:00:00.000000000 Z
11
+ date: 2014-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -24,9 +24,23 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 4.1.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 4.1.4
27
41
  description: This is a ruby wrapper around the Uptrends API. Uptrends is a monitoring
28
- service that let's you monitor Web pages, Web services, Mail servers, Database
29
- servers, DNS, SSL certificates, FTP anod more.
42
+ service that let's you monitor Web pages, Web services, Mail servers, Database servers,
43
+ DNS, SSL certificates, FTP and more.
30
44
  email:
31
45
  - J@sonBarnett.com
32
46
  executables: []
@@ -34,6 +48,7 @@ extensions: []
34
48
  extra_rdoc_files: []
35
49
  files:
36
50
  - ".gitignore"
51
+ - ".travis.yml"
37
52
  - Gemfile
38
53
  - LICENSE.txt
39
54
  - README.md
@@ -44,10 +59,12 @@ files:
44
59
  - lib/uptrends/api_client.rb
45
60
  - lib/uptrends/probe.rb
46
61
  - lib/uptrends/probe_group.rb
62
+ - lib/uptrends/utils.rb
47
63
  - lib/uptrends/version.rb
48
64
  - spec/fixtures/vcr_cassettes/GET_Probes.yml
49
65
  - spec/spec_helper.rb
50
66
  - spec/uptrends/api_client_spec.rb
67
+ - spec/uptrends/probe_group_spec.rb
51
68
  - spec/uptrends/probe_spec.rb
52
69
  - uptrends.gemspec
53
70
  homepage: https://github.com/jasonwbarnett/uptrends-gem
@@ -78,4 +95,5 @@ test_files:
78
95
  - spec/fixtures/vcr_cassettes/GET_Probes.yml
79
96
  - spec/spec_helper.rb
80
97
  - spec/uptrends/api_client_spec.rb
98
+ - spec/uptrends/probe_group_spec.rb
81
99
  - spec/uptrends/probe_spec.rb