rushover-cli 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +7 -0
- data/bin/rushover +63 -0
- data/lib/rushover/cli.rb +95 -0
- data/lib/rushover/cli/version.rb +6 -0
- data/rushover-cli.gemspec +26 -0
- data/spec/rushover/cli_spec.rb +22 -0
- data/spec/spec_helper.rb +2 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0bf71cf3daecc9702a49854db85fb3f06d00300b
|
4
|
+
data.tar.gz: e5bd32a3f063318b4125a37650539bfde29608f3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 913cacac65282493f853ee01dbef46aac065c8194d955206203ec5df23fd69a7769198c4c76b1bdbd99c7879bb50faa1c0e9f653990294eaa770fdaf9d9af949
|
7
|
+
data.tar.gz: 2534df47a5452c213a08e293e1f04a6690dc90036a70d0e2ce7cca7c212eead7dab83195bd48db85901967eb29799e0b53ee3287eabc9972074465e0ad4a06ad
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 0.0.10 --- 2014-10-08
|
4
|
+
|
5
|
+
### Fixed
|
6
|
+
|
7
|
+
- Fixed bug where running `rushover config` without any flags would delete keys
|
8
|
+
|
9
|
+
## 0.0.9 --- 2014-10-08
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- Changed wording of usage from "rush" to "rushover"
|
14
|
+
|
15
|
+
## 0.0.8 --- 2014-10-07
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
- `push` command now used to send Pushover notifications
|
20
|
+
- `config` command now used to set user keys and app tokens
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 brandonpittman
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Rushover::Cli
|
2
|
+
|
3
|
+
`rushover-cli` is a command line interface to the `rushover` gem.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rushover-cli'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rushover-cli
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
rushover config -u USER_KEY -a APP_TOKEN
|
24
|
+
rushover push MESSAGE [-t title]
|
25
|
+
|
26
|
+
## Caveats
|
27
|
+
|
28
|
+
`rushover-cli` requires a `:user` key and a `:rush` key to be saved to `~/.rushrc`.
|
29
|
+
|
30
|
+
# Example
|
31
|
+
|
32
|
+
---
|
33
|
+
:user: youruserkey
|
34
|
+
:rush: anyapptoken
|
35
|
+
|
36
|
+
The application you use doesn't need to be named 'rush'. It just needs to be any app token. If you want to change the title that gets passed to Pushover, just use the `-t` option.
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it ( https://github.com/[my-github-username]/rushover-cli/fork )
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/rushover
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rushover/cli'
|
4
|
+
|
5
|
+
rush = Rushover::Cli::Rush.new
|
6
|
+
|
7
|
+
opts = Slop.parse! do
|
8
|
+
on :v, :version, 'Print version number' do
|
9
|
+
puts Rushover::Cli::VERSION
|
10
|
+
end
|
11
|
+
on :h, :help, 'Display help'
|
12
|
+
|
13
|
+
# This command is used to set user key and app token in the YAML::Store.
|
14
|
+
# @since 0.0.8
|
15
|
+
command 'config' do
|
16
|
+
banner 'Usage: rushover config -u USER_KEY -a APP_TOKEN'
|
17
|
+
on :u=, :user=, 'Your user key'
|
18
|
+
on :a=, :app=, 'Your app token'
|
19
|
+
on :h, :help, 'Print help'
|
20
|
+
|
21
|
+
run do |opts|
|
22
|
+
if opts[:h] || (!opts[:u] && !opts[:a])
|
23
|
+
puts opts
|
24
|
+
exit
|
25
|
+
else
|
26
|
+
rush.add_key(:user, opts[:user])
|
27
|
+
rush.add_key(:rush, opts[:app])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# This command is used to send notifications using Pushover.
|
33
|
+
# @since 0.0.8
|
34
|
+
command 'push' do
|
35
|
+
banner 'Usage: rushover push MESSAGE [-t TITLE]'
|
36
|
+
on 't=', 'title=', 'An optional title'
|
37
|
+
on :h, :help, 'Print help'
|
38
|
+
|
39
|
+
run do |opts, args|
|
40
|
+
message = args.join(" ")
|
41
|
+
|
42
|
+
if opts[:h] || message.empty?
|
43
|
+
puts opts
|
44
|
+
exit
|
45
|
+
elsif message.length > 0
|
46
|
+
user_key = rush.get_key(:user)
|
47
|
+
app_token = rush.get_key(:rush)
|
48
|
+
client = Rushover::Client.new(app_token)
|
49
|
+
user = Rushover::User.new(user_key, client)
|
50
|
+
user.notify(message, title: opts[:title])
|
51
|
+
else
|
52
|
+
raise "You didn't provide a message."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# This little bit just helps catch the times when `rushover` is run without any
|
59
|
+
# arguments or with the --help options.
|
60
|
+
# @since 0.0.8
|
61
|
+
if opts[:h] || ARGV.empty?
|
62
|
+
puts opts
|
63
|
+
end
|
data/lib/rushover/cli.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'rushover'
|
2
|
+
require "rushover/cli/version"
|
3
|
+
require 'slop'
|
4
|
+
require 'pathname'
|
5
|
+
require 'yaml/store'
|
6
|
+
|
7
|
+
# @author Brandon Pittman
|
8
|
+
# This module is namespaced as Rushover::Cli in order to show it's connected to
|
9
|
+
# the rushover gem.
|
10
|
+
module Rushover
|
11
|
+
# This is the CLI for rushover.
|
12
|
+
module Cli
|
13
|
+
|
14
|
+
# This class is accessing helper methods used in the bin file.
|
15
|
+
class Rush
|
16
|
+
|
17
|
+
# @!group Rushover objects
|
18
|
+
# @param app_token [String]
|
19
|
+
# @return [Rushover::Client] Client object to be used in #notify
|
20
|
+
# @see #notify
|
21
|
+
# @since 0.0.2
|
22
|
+
def client(app_token)
|
23
|
+
Rushover::Client.new(app_token)
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param user_key [String]
|
27
|
+
# @param client [Rushover::Client]
|
28
|
+
# @return [Rushover::User] User object to be used in #notify
|
29
|
+
# @see #notify
|
30
|
+
# @since 0.0.2
|
31
|
+
def user(user_key, client)
|
32
|
+
Rushover::User.new(user_key, client)
|
33
|
+
end
|
34
|
+
# @!endgroup
|
35
|
+
|
36
|
+
# @param user [Rushover::User]
|
37
|
+
# @return [Hash] response from Pushover
|
38
|
+
# @since 0.0.2
|
39
|
+
# @see #user
|
40
|
+
# @see #client
|
41
|
+
def notify(user)
|
42
|
+
user.notify(message, title: opts[:title])
|
43
|
+
end
|
44
|
+
|
45
|
+
# @!group Configuration management
|
46
|
+
# @return [Pathname] location of .rushrc file
|
47
|
+
# @since 0.0.2
|
48
|
+
def rc_file
|
49
|
+
Pathname.new("#{ENV['HOME']}/.rushrc")
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [Psych::Store] YAML Store consisting of a :user and :rush keys
|
53
|
+
# @since 0.0.2
|
54
|
+
def config
|
55
|
+
YAML::Store.new(rc_file)
|
56
|
+
end
|
57
|
+
# @!endgroup
|
58
|
+
|
59
|
+
# @!group Key management
|
60
|
+
# @param key_symbol [Symbol] symbol to fetch
|
61
|
+
# @return [String] value of fetched key
|
62
|
+
# @since 0.0.2
|
63
|
+
def get_key(key_symbol)
|
64
|
+
store = config
|
65
|
+
store.transaction do
|
66
|
+
store.fetch(key_symbol)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# @param key_symbol [Symbol] symbol to add
|
71
|
+
# @param key_value [String] value to assign to key_symbol
|
72
|
+
# @return [Psych::Store] updated YAML Store
|
73
|
+
# @since 0.0.2
|
74
|
+
# @note Currently not used by rushover-cli
|
75
|
+
# @todo Add ability to set :user and :rush keys
|
76
|
+
def add_key(key_symbol, key_value)
|
77
|
+
store = config
|
78
|
+
store.transaction do
|
79
|
+
store[key_symbol] = key_value
|
80
|
+
end
|
81
|
+
end
|
82
|
+
# @!endgroup
|
83
|
+
|
84
|
+
# @!group Miscellaneous
|
85
|
+
# @return [String] version number of `rushover-cli` as a String
|
86
|
+
# @since 0.0.2
|
87
|
+
def version
|
88
|
+
Rushover::Cli::VERSION
|
89
|
+
end
|
90
|
+
# @!endgroup
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rushover/cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rushover-cli"
|
8
|
+
spec.version = Rushover::Cli::VERSION
|
9
|
+
spec.authors = ["brandonpittman"]
|
10
|
+
spec.email = ["brandonpittman@gmail.com"]
|
11
|
+
spec.summary = %q{A command-line interface for the rushover gem.}
|
12
|
+
spec.description = %q{A command-line interface for the rushover gem.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_dependency "slop", "~> 3.6"
|
25
|
+
spec.add_dependency "rushover"
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rushover::Cli do
|
4
|
+
|
5
|
+
let(:rc_file) {Pathname.new("#{ENV['HOME']}/.rushrc")}
|
6
|
+
let(:rush) {Rushover::Cli::Rush.new}
|
7
|
+
|
8
|
+
it 'has a version number' do
|
9
|
+
expect(Rushover::Cli::VERSION).not_to be nil
|
10
|
+
end
|
11
|
+
|
12
|
+
context ".rushrc file exists" do
|
13
|
+
it "can read a rc file" do
|
14
|
+
if rc_file.exist?
|
15
|
+
expect(rush.get_key(:user)).to be_truthy
|
16
|
+
expect(rush.get_key(:rush)).to be_truthy
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rushover-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- brandonpittman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: slop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.6'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rushover
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: A command-line interface for the rushover gem.
|
84
|
+
email:
|
85
|
+
- brandonpittman@gmail.com
|
86
|
+
executables:
|
87
|
+
- rushover
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/rushover
|
99
|
+
- lib/rushover/cli.rb
|
100
|
+
- lib/rushover/cli/version.rb
|
101
|
+
- rushover-cli.gemspec
|
102
|
+
- spec/rushover/cli_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: ''
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.4.2
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: A command-line interface for the rushover gem.
|
128
|
+
test_files:
|
129
|
+
- spec/rushover/cli_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
has_rdoc:
|