updown 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aba4862ff0038ce2d2371c6bf3bc0366d05f1c23
4
- data.tar.gz: c8b42e77da15cbe65567c89d7a7b2ddde4c7ff1e
3
+ metadata.gz: e2dbae809fc3ca16f30af62279401f4310eda7db
4
+ data.tar.gz: 2f582ea04640723eac849cb8d5647c2d1d27a4e8
5
5
  SHA512:
6
- metadata.gz: 68cce5ca5b657a1a34a1d8376884f56fad59f81aa1e33a649c806ba589279361e004ddb196970240a7b8cb68a9707b7426e10e265a1f3ed2302006e45b58ff40
7
- data.tar.gz: e2bc74df3f6b5ef0eb398c1b0540f320f063a98b324c02d8c7a89af90eb88a27937d99afd3059f226d21b81479d788ce6442f56ec3d35653748ce0cf3d0079c7
6
+ metadata.gz: 9712a39c483a6dd62d10889519b436e3013218e5a57427ac2e80224113dbf3c75aea9083ff2be3b25fdcaf67d8f214daba49fc6e2bd09703b13272b6e5eb7cd0
7
+ data.tar.gz: 7167145967a7e8b56104fd312badd76ed0f72ed91bca1685d05e2b0827817398f7a9262f33e07c57bf42e0cfea5bb10ad6ad4dfda326507cf2c9ba746bc1b812
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- updown (0.0.1)
4
+ updown (0.1.0)
5
5
  gem_config
6
6
  rest-client
7
+ thor
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
@@ -15,6 +16,7 @@ GEM
15
16
  rest-client (1.7.3)
16
17
  mime-types (>= 1.16, < 3.0)
17
18
  netrc (~> 0.7)
19
+ thor (0.19.1)
18
20
 
19
21
  PLATFORMS
20
22
  ruby
data/README.md CHANGED
@@ -74,9 +74,39 @@ Delete a specific check:
74
74
  check.destroy
75
75
  ```
76
76
 
77
+ ## Command Line
78
+
79
+ This gem also comes with a few commands
80
+
81
+ First, configure your API key:
82
+
83
+ ```
84
+ $ updown configure YOUR_API_KEY
85
+ ```
86
+
87
+ See the status of your checks:
88
+
89
+ ```
90
+ $ updown status
91
+ [up] https://google.com
92
+ [up] https://bing.com
93
+ ```
94
+
95
+ Add a new check:
96
+
97
+ ```
98
+ $ updown add https://google.com
99
+ ```
100
+
101
+
102
+ ## Todo
103
+
104
+ - Write tests!
105
+ - Error handling
106
+
77
107
  ## Contributing
78
108
 
79
- 1. Fork it ( https://github.com/[my-github-username]/updown/fork )
109
+ 1. Fork it ( https://github.com/askehansen/updown-ruby/fork )
80
110
  2. Create your feature branch (`git checkout -b my-new-feature`)
81
111
  3. Commit your changes (`git commit -am 'Add some feature'`)
82
112
  4. Push to the branch (`git push origin my-new-feature`)
data/bin/updown ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'yaml'
5
+ require 'updown'
6
+ require 'updown/cli'
7
+
8
+ Updown::CLI.start(ARGV)
data/lib/updown/cli.rb ADDED
@@ -0,0 +1,55 @@
1
+ module Updown
2
+ class CLI < Thor
3
+
4
+ desc 'status', 'see the status of all your checks'
5
+ def status
6
+ configure_api_key
7
+
8
+ Updown::Check.all.each do |check|
9
+ status = check.down ? 'DOWN' : 'up'
10
+ puts "[#{status}] #{check.url}"
11
+ end
12
+ end
13
+
14
+ desc 'add URL [PERIOD]', 'add a new check'
15
+ def add(url, period=60)
16
+ configure_api_key
17
+
18
+ check = Updown::Check.create url, period: period
19
+ system "open https://updown.io/#{check.token}"
20
+ end
21
+
22
+ desc 'configure API_KEY', 'set your updown.io api key'
23
+ def configure(api_key)
24
+ config = read_config
25
+ config['api_key'] = api_key
26
+
27
+ write_config config
28
+ end
29
+
30
+ private
31
+
32
+ CONFIG_FILE = File.expand_path('~/.updown')
33
+
34
+ def read_config
35
+ if File.exist? CONFIG_FILE
36
+ YAML.load File.read(CONFIG_FILE)
37
+ else
38
+ {}
39
+ end
40
+ end
41
+
42
+ def write_config(config)
43
+ File.write CONFIG_FILE, config.to_yaml
44
+ end
45
+
46
+ def configure_api_key
47
+ if api_key = read_config['api_key']
48
+ Updown.configuration.api_key = api_key
49
+ else
50
+ abort "no api key configured!\nrun `updown configure API_KEY`"
51
+ end
52
+ end
53
+
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module Updown
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/updown.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
 
24
24
  spec.add_dependency 'rest-client'
25
+ spec.add_dependency 'thor'
25
26
 
26
27
  spec.add_runtime_dependency 'gem_config'
27
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: updown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aske Hansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-23 00:00:00.000000000 Z
11
+ date: 2015-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: gem_config
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -69,7 +83,8 @@ dependencies:
69
83
  description: A wrapper for the Updown.io API
70
84
  email:
71
85
  - aske@deeco.dk
72
- executables: []
86
+ executables:
87
+ - updown
73
88
  extensions: []
74
89
  extra_rdoc_files: []
75
90
  files:
@@ -78,9 +93,11 @@ files:
78
93
  - LICENSE.txt
79
94
  - README.md
80
95
  - Rakefile
96
+ - bin/updown
81
97
  - lib/updown.rb
82
98
  - lib/updown/call.rb
83
99
  - lib/updown/check.rb
100
+ - lib/updown/cli.rb
84
101
  - lib/updown/downtime.rb
85
102
  - lib/updown/version.rb
86
103
  - updown.gemspec