pb-cli 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +53 -0
- data/README.md +49 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/exe/pb +5 -0
- data/lib/pb/cli/util.rb +39 -0
- data/lib/pb/cli/version.rb +6 -0
- data/lib/pb/cli.rb +55 -0
- data/pb-cli.gemspec +31 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b8be764f8eb69bb8e9a2c17043a3243e23fd893a
|
4
|
+
data.tar.gz: 5839590a5423c6a7ca814873385ca13a37e1db3a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e9d55e545367bea51a0a965765790a914854582b00bf972ae7d42115282c564a845c912e00bf2353497282c6de727811db7774bd4ed1b3ba00d7486872febdef
|
7
|
+
data.tar.gz: 3ea9a5542d44701fc3ae4f09d820bb510d6dbc0f4e33f3eec02a1487d40a33fd2b96aeb3ea98000dc9757f6fac34780eed5eb388202b9d4b06f906387f586a51
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pb-cli (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.5)
|
10
|
+
domain_name (0.5.24)
|
11
|
+
unf (>= 0.0.5, < 1.0.0)
|
12
|
+
http-cookie (1.0.2)
|
13
|
+
domain_name (~> 0.5)
|
14
|
+
json (1.8.3)
|
15
|
+
mime-types (2.6.2)
|
16
|
+
netrc (0.10.3)
|
17
|
+
rake (10.4.2)
|
18
|
+
rest-client (1.8.0)
|
19
|
+
http-cookie (>= 1.0.2, < 2.0)
|
20
|
+
mime-types (>= 1.16, < 3.0)
|
21
|
+
netrc (~> 0.7)
|
22
|
+
rspec (3.3.0)
|
23
|
+
rspec-core (~> 3.3.0)
|
24
|
+
rspec-expectations (~> 3.3.0)
|
25
|
+
rspec-mocks (~> 3.3.0)
|
26
|
+
rspec-core (3.3.2)
|
27
|
+
rspec-support (~> 3.3.0)
|
28
|
+
rspec-expectations (3.3.1)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.3.0)
|
31
|
+
rspec-mocks (3.3.2)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.3.0)
|
34
|
+
rspec-support (3.3.0)
|
35
|
+
thor (0.19.1)
|
36
|
+
unf (0.1.4)
|
37
|
+
unf_ext
|
38
|
+
unf_ext (0.0.7.1)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
bundler (~> 1.10)
|
45
|
+
json
|
46
|
+
pb-cli!
|
47
|
+
rake (~> 10.0)
|
48
|
+
rest-client
|
49
|
+
rspec
|
50
|
+
thor
|
51
|
+
|
52
|
+
BUNDLED WITH
|
53
|
+
1.10.6
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# pb-cli
|
2
|
+
|
3
|
+
A command line interface for Pushbullet.
|
4
|
+
|
5
|
+
https://www.pushbullet.com/
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Run:
|
10
|
+
|
11
|
+
```
|
12
|
+
$ gem install pb-cli
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```
|
18
|
+
$ pb init <ACCESS-TOKEN>
|
19
|
+
```
|
20
|
+
|
21
|
+
To access the Pushbullet API you'll need an access token so the server knows who you are. You can get one from your [Account Settings](https://www.pushbullet.com/#settings/account) page.
|
22
|
+
|
23
|
+
## How to use
|
24
|
+
|
25
|
+
Send notification.
|
26
|
+
|
27
|
+
```
|
28
|
+
$ pb push <MESSAGE> [--title <TITLE>]
|
29
|
+
```
|
30
|
+
|
31
|
+
See also `pb help`.
|
32
|
+
|
33
|
+
## Development
|
34
|
+
|
35
|
+
```
|
36
|
+
$ git clone git@github.com:miya0001/pb-cli.git
|
37
|
+
$ cd pb-cli
|
38
|
+
$ bundle install --path vendor/bundle
|
39
|
+
```
|
40
|
+
|
41
|
+
### Running automated testing
|
42
|
+
|
43
|
+
```
|
44
|
+
$ bundle exec rspec
|
45
|
+
```
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/miya0001/pb-cli.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pb/cli"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/pb
ADDED
data/lib/pb/cli/util.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# vim: ft=ruby expandtab shiftwidth=2 tabstop=2
|
3
|
+
|
4
|
+
require "yaml"
|
5
|
+
|
6
|
+
module Pushbullet_CLI
|
7
|
+
class Utils
|
8
|
+
class << self
|
9
|
+
def get_config
|
10
|
+
conf = {}
|
11
|
+
if File.exists?( File.join( ENV["HOME"], '.pb-cli/config.yml' ) )
|
12
|
+
_custom = YAML.load(
|
13
|
+
File.open(
|
14
|
+
File.join( ENV["HOME"], '.pb-cli/config.yml' ),
|
15
|
+
File::RDONLY
|
16
|
+
).read
|
17
|
+
)
|
18
|
+
conf.merge!(_custom) if _custom.is_a?(Hash)
|
19
|
+
end
|
20
|
+
return conf
|
21
|
+
end
|
22
|
+
|
23
|
+
def send( url, access_token, args )
|
24
|
+
begin
|
25
|
+
RestClient.post(
|
26
|
+
url,
|
27
|
+
args.to_json,
|
28
|
+
:content_type => :json,
|
29
|
+
:accept => :json,
|
30
|
+
"Access-Token" => access_token
|
31
|
+
)
|
32
|
+
rescue => e
|
33
|
+
$stderr.puts e.message
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/pb/cli.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# vim: ft=ruby expandtab shiftwidth=2 tabstop=2
|
3
|
+
|
4
|
+
require "pb/cli/version"
|
5
|
+
require "pb/cli/util"
|
6
|
+
require "thor"
|
7
|
+
require "rest-client"
|
8
|
+
require "yaml"
|
9
|
+
|
10
|
+
module Pushbullet_CLI
|
11
|
+
class Command < Thor
|
12
|
+
|
13
|
+
def self.exit_on_failure?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "push <MESSAGE>", "Send a push to devices or another persons."
|
18
|
+
method_option :title, :aliases => "-t", :desc => "Title of the notification."
|
19
|
+
# method_option :device, :aliases => "-d", :desc => "Target device to push."
|
20
|
+
# method_option :person, :aliases => "-p", :desc => "Delete the file after parsing it"
|
21
|
+
def push( message = "" )
|
22
|
+
if File.pipe?(STDIN) || File.select([STDIN], [], [], 0) != nil then
|
23
|
+
message = STDIN.readlines().join( "" )
|
24
|
+
end
|
25
|
+
|
26
|
+
url = "https://api.pushbullet.com/v2/pushes"
|
27
|
+
|
28
|
+
if message
|
29
|
+
config = Utils::get_config
|
30
|
+
|
31
|
+
args = {
|
32
|
+
"type" => "note",
|
33
|
+
"body" => message,
|
34
|
+
"title" => ( options[:title] ? options[:title] : "" )
|
35
|
+
}
|
36
|
+
|
37
|
+
Utils::send( url, config['access_token'], args )
|
38
|
+
else
|
39
|
+
puts "Nothing to do."
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "init <ACCESS-TOKEN>", "Initialize pb-cli"
|
44
|
+
def init( access_token )
|
45
|
+
unless Dir.exist? File.join( ENV["HOME"], '.pb-cli' )
|
46
|
+
FileUtils.mkdir( File.join( ENV["HOME"], '.pb-cli' ) );
|
47
|
+
end
|
48
|
+
File.open( File.join( ENV["HOME"], '.pb-cli', 'config.yml' ), "w" ) do | file |
|
49
|
+
file.write( "access_token: " + access_token )
|
50
|
+
end
|
51
|
+
FileUtils.chmod( 0600, File.join( ENV["HOME"], '.pb-cli', 'config.yml' ) )
|
52
|
+
end
|
53
|
+
|
54
|
+
end # end class Command
|
55
|
+
end # end module Pushbullet_CLi
|
data/pb-cli.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pb/cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pb-cli"
|
8
|
+
spec.version = Pushbullet_CLI::VERSION
|
9
|
+
spec.authors = ["miya0001"]
|
10
|
+
spec.email = ["miya@wpist.me"]
|
11
|
+
|
12
|
+
spec.summary = %q{Use Pushbullet from cli.}
|
13
|
+
spec.description = %q{Use Pushbullet from cli.}
|
14
|
+
spec.homepage = "https://github.com/miya0001/pb-cli"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pb-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- miya0001
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-02 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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
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
|
+
description: Use Pushbullet from cli.
|
42
|
+
email:
|
43
|
+
- miya@wpist.me
|
44
|
+
executables:
|
45
|
+
- pb
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".rspec"
|
51
|
+
- ".travis.yml"
|
52
|
+
- Gemfile
|
53
|
+
- Gemfile.lock
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/console
|
57
|
+
- bin/setup
|
58
|
+
- exe/pb
|
59
|
+
- lib/pb/cli.rb
|
60
|
+
- lib/pb/cli/util.rb
|
61
|
+
- lib/pb/cli/version.rb
|
62
|
+
- pb-cli.gemspec
|
63
|
+
homepage: https://github.com/miya0001/pb-cli
|
64
|
+
licenses: []
|
65
|
+
metadata:
|
66
|
+
allowed_push_host: https://rubygems.org
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.4.8
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Use Pushbullet from cli.
|
87
|
+
test_files: []
|