pingdom-cli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 05c6ccfa4fce781ee7ff2f29c52e9bce2016c69d
4
+ data.tar.gz: f410898d6418681582e5acc46829e5f7bd491f93
5
+ SHA512:
6
+ metadata.gz: 2367cdad02781b39ac8fa9b1b1c7cb6dd73c3566ca9c15e6e31842e5a4b082627a11a276aee7fe55df5ecc0f72b1586c2cb7e3d7a49cfdf7755a1116b94f05ac
7
+ data.tar.gz: 4195282a2d201c071313a62b20a7b5b380f84afd4375ac2306fe85bcfb3ddff292bdb13dd4b5d2f3a7a7d87df0b14b789aa960ce95cf4c3f2eae2bd9c0ce431a
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ -
2
+ ChangeLog.md
3
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ Gemfile.lock
2
+ doc/
3
+ pkg/
4
+ **/*.gem
5
+ .yardoc/
6
+ .bundle/
7
+ vendor/bundle/
8
+ .tags
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1
7
+ - ruby-head
8
+
9
+ os:
10
+ - linux
11
+ - osx
12
+
13
+ gemfile:
14
+ - Gemfile
15
+
16
+ script: 'bundle exec rake spec'
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title "pingdom-cli Documentation" --protected
data/ChangeLog.md ADDED
@@ -0,0 +1,4 @@
1
+ ### 0.1.0 / 2014-09-26
2
+
3
+ * Initial release:
4
+
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'kramdown'
7
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Hiroshi Toyama
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # pingdom-cli [![Build Status](https://secure.travis-ci.org/toyama0919/pingdom-cli.png?branch=master)](http://travis-ci.org/toyama0919/pingdom-cli)
2
+
3
+ pingdom simple command line interface
4
+
5
+ ## Examples
6
+
7
+ ### list checks
8
+
9
+ $ pingdom-cli checks
10
+
11
+ ### pause checks
12
+
13
+ $ pingdom-cli pause
14
+
15
+ ### unpause checks
16
+
17
+ $ pingdom-cli unpause
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ gem 'pingdom-cli'
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install pingdom-cli
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new [Pull Request](../../pull/new/master)
40
+
41
+ ## Information
42
+
43
+ * [Homepage](https://github.com/toyama0919/pingdom-cli)
44
+ * [Issues](https://github.com/toyama0919/pingdom-cli/issues)
45
+ * [Documentation](http://rubydoc.info/gems/pingdom-cli/frames)
46
+ * [Email](mailto:toyama0919@gmail.com)
47
+
48
+ ## Copyright
49
+
50
+ Copyright (c) 2014 Hiroshi Toyama
51
+
52
+ See [LICENSE.txt](../LICENSE.txt) for details.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+
6
+ begin
7
+ gem 'rubygems-tasks', '~> 0.2'
8
+ require 'rubygems/tasks'
9
+
10
+ Gem::Tasks.new
11
+ rescue LoadError => e
12
+ warn e.message
13
+ warn "Run `gem install rubygems-tasks` to install Gem::Tasks."
14
+ end
15
+
16
+ begin
17
+ gem 'rspec', '~> 2.4'
18
+ require 'rspec/core/rake_task'
19
+
20
+ RSpec::Core::RakeTask.new
21
+ rescue LoadError => e
22
+ task :spec do
23
+ abort "Please run `gem install rspec` to install RSpec."
24
+ end
25
+ end
26
+
27
+ task :test => :spec
28
+ task :default => :spec
29
+
30
+ begin
31
+ gem 'yard', '~> 0.8'
32
+ require 'yard'
33
+
34
+ YARD::Rake::YardocTask.new
35
+ rescue LoadError => e
36
+ task :yard do
37
+ abort "Please run `gem install yard` to install YARD."
38
+ end
39
+ end
40
+ task :doc => :yard
data/bin/pingdom-cli ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'pingdom/cli'
5
+
6
+ Pingdom::Cli::CLI.start
@@ -0,0 +1,48 @@
1
+ #! /usr/bin/env ruby
2
+ # -*- encoding: UTF-8 -*-
3
+ require 'thor'
4
+ require 'json'
5
+ require 'yaml'
6
+
7
+ module Pingdom
8
+ module Cli
9
+ class CLI < Thor
10
+ include Thor::Actions
11
+ map '-l' => :checks
12
+ class_option :config, aliases: '--config', type: :string, default: "#{ENV['HOME']}/.pingdomrc", desc: 'config file'
13
+ def initialize(args = [], options = {}, config = {})
14
+ super(args, options, config)
15
+ @global_options = config[:shell].base.options
16
+ @config = YAML.load_file(@global_options['config'])
17
+ @core = Core.new(@config)
18
+ end
19
+
20
+ desc "config", "config"
21
+ def config
22
+ puts @config.to_json
23
+ end
24
+
25
+ desc "checks", "checks"
26
+ def checks
27
+ puts @core.checks.to_json
28
+ end
29
+
30
+ desc "pause", "pause"
31
+ def pause
32
+ puts @core.update({ paused: true })
33
+ end
34
+
35
+ desc "unpause", "unpause"
36
+ def unpause
37
+ puts @core.update({ paused: false })
38
+ end
39
+
40
+ desc "update", "update"
41
+ option :params, type: :hash, default: {}, desc: 'params'
42
+ def update
43
+ puts @core.update(options['params'])
44
+ end
45
+ end
46
+ end
47
+ end
48
+
@@ -0,0 +1,26 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+
4
+ module Pingdom
5
+ module Cli
6
+ class Core
7
+
8
+ def initialize(config)
9
+ @config = config
10
+ @url = "https://#{CGI::escape @config['user']}:#{CGI::escape @config['password']}@api.pingdom.com/api/2.0/checks"
11
+ @header = {"App-Key" => @config['app_key']}
12
+ end
13
+
14
+ def checks
15
+ response = RestClient.get(@url, @header)
16
+ JSON.parse(response.body, :symbolize_names => true)
17
+ end
18
+
19
+ def update(params)
20
+ response = RestClient.put(@url, params, @header)
21
+ response.body
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ module Pingdom
2
+ module Cli
3
+ # pingdom-cli version
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ require 'pingdom/cli/version'
2
+ require 'pingdom/cli/core'
3
+ require 'pingdom/cli/cli'
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/pingdom/cli/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "pingdom-cli"
7
+ gem.version = Pingdom::Cli::VERSION
8
+ gem.summary = %q{pingdom simple command line interface}
9
+ gem.description = %q{pingdom simple command line interface}
10
+ gem.license = "MIT"
11
+ gem.authors = ["Hiroshi Toyama"]
12
+ gem.email = "toyama0919@gmail.com"
13
+ gem.homepage = "https://github.com/toyama0919/pingdom-cli"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ['lib']
19
+
20
+ gem.add_dependency 'thor', '~> 0.19.1'
21
+ gem.add_dependency 'rest-client'
22
+
23
+ gem.add_development_dependency 'bundler', '~> 1.7.2'
24
+ gem.add_development_dependency 'pry', '~> 0.10.1'
25
+ gem.add_development_dependency 'rake', '~> 10.3.2'
26
+ gem.add_development_dependency 'rspec', '~> 2.4'
27
+ gem.add_development_dependency 'rubocop', '~> 0.24.1'
28
+ gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
29
+ gem.add_development_dependency 'yard', '~> 0.8'
30
+ end
data/spec/cli_spec.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'pingdom/cli'
3
+
4
+ describe Pingdom::Cli::CLI do
5
+ before do
6
+ end
7
+
8
+ it "should stdout sample" do
9
+ output = capture_stdout do
10
+ Pingdom::Cli::CLI.start(['sample'])
11
+ end
12
+ output.should == "This is your new task\n"
13
+ end
14
+
15
+ after do
16
+ end
17
+ end
data/spec/core_spec.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+ require 'pingdom/cli'
3
+
4
+ describe Pingdom::Cli::Core do
5
+ before do
6
+ @core = Core.new
7
+ end
8
+
9
+ it "core not nil" do
10
+ @core.should_not nil
11
+ end
12
+
13
+ after do
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ gem 'rspec', '~> 2.4'
2
+ require 'rspec'
3
+ require 'pingdom/cli/version'
4
+
5
+ include Pingdom::Cli
6
+
7
+ def capture_stdout
8
+ out = StringIO.new
9
+ $stdout = out
10
+ yield
11
+ return out.string
12
+ ensure
13
+ $stdout = STDOUT
14
+ end
15
+
16
+ def capture_stderr
17
+ out = StringIO.new
18
+ $stderr = out
19
+ yield
20
+ return out.string
21
+ ensure
22
+ $stderr = STDERR
23
+ end
24
+
metadata ADDED
@@ -0,0 +1,192 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pingdom-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hiroshi Toyama
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.19.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.19.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.7.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.7.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.10.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.10.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 10.3.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 10.3.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.24.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.24.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubygems-tasks
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: yard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.8'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.8'
139
+ description: pingdom simple command line interface
140
+ email: toyama0919@gmail.com
141
+ executables:
142
+ - pingdom-cli
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".document"
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".travis.yml"
150
+ - ".yardopts"
151
+ - ChangeLog.md
152
+ - Gemfile
153
+ - LICENSE.txt
154
+ - README.md
155
+ - Rakefile
156
+ - bin/pingdom-cli
157
+ - lib/pingdom/cli.rb
158
+ - lib/pingdom/cli/cli.rb
159
+ - lib/pingdom/cli/core.rb
160
+ - lib/pingdom/cli/version.rb
161
+ - pingdom-cli.gemspec
162
+ - spec/cli_spec.rb
163
+ - spec/core_spec.rb
164
+ - spec/spec_helper.rb
165
+ homepage: https://github.com/toyama0919/pingdom-cli
166
+ licenses:
167
+ - MIT
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.2.2
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: pingdom simple command line interface
189
+ test_files:
190
+ - spec/cli_spec.rb
191
+ - spec/core_spec.rb
192
+ - spec/spec_helper.rb