hoot 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 68ee23c9c0e51de3603808a780cbfa1a92746ff4
4
+ data.tar.gz: e0f322e4e02efb56501c82ba80263012e92b03ff
5
+ SHA512:
6
+ metadata.gz: 3c3a2d452d66b89739c7f424d6465a829bfdf1333992f6c0346a80379830169e8b4f59820f90bce20f910893dcc4d9b2612628b1df57edd84cfdcea4b5114971
7
+ data.tar.gz: 271f524f576e965219956847f30fa9303e178fd750109f30b5d8faab62af38c72b50af3ddd0c6569283afeb4448f8f58bd7ba6e8deeed7e35b60f68b924b60a3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hoot.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hoot (0.1.0)
5
+ json
6
+ netrc
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ json (1.8.3)
12
+ netrc (0.10.3)
13
+ rake (10.4.2)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ bundler (~> 1.10)
20
+ hoot!
21
+ rake (~> 10.0)
22
+
23
+ BUNDLED WITH
24
+ 1.10.6
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Rudd Fawcett
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # Hoot
2
+
3
+ This is Hoot! Hoot is a simple command line tool to alert you when a Terminal process has finished, with a push notification right to your device!
4
+
5
+ > Hoot! Your process has finished! Come back!
6
+
7
+ ## Installation
8
+
9
+ Hoot is currently command line only, so you can't use it in your own project.
10
+
11
+ To install `hoot`, simply execute:
12
+
13
+ sudo gem install hoot
14
+
15
+ ## How it Works
16
+
17
+ Hoot uses a Node.js middleware server that I've dubbed `hedwig`. Hoot simply posts the email and password you used to sign up in the iOS app -- and sends a notification to that device using Parse.
18
+
19
+ Because of the current setup Hoot is intended _just_ for a simple computer to iPhone alert, to come back and visit your completed process.
20
+
21
+ Hedwig is also open source, and can be found at [ruddfawcett/hedwig](https://github.com/ruddfawcett/hedwig).
22
+
23
+ Hoot may in the future transition over to a `npm` module.
24
+
25
+ ## Usage
26
+
27
+ Hoot is not very fancy...
28
+
29
+ When you first install hoot, you will need to authenticate yourself using the email and password you used in the iOS app.
30
+
31
+ Simply execute `hoot`, and you will be prompted to enter your credentials. Note as of right now you cannot change these with the tool, you'll have to manually edit your `.netrc` file.
32
+
33
+ To use, you can do something like the following,
34
+
35
+ sh my-long-process.sh && hoot
36
+
37
+ After your scraping tool/parser/long task has been completed, you'll get an alert on your phone.
38
+
39
+ > Hoot! Your process has finished! Come back!
40
+
41
+ ## Development
42
+
43
+ I'd love to flesh out the project some more, but currently it fits my needs. Things that definitely need to be added are a more effective authentication gem (I don't know exactly which one), and `commander` (or another tool that makes processing arguments easier). Maybe even some testing?
44
+
45
+ To add features, I'd recommend also using your own branch of `hedwig` ([ruddfawcett/hedwig](https://github.com/ruddfawcett/hedwig)). You can hack on Hoot with your local copy of Hedwig, and enable development mode using the following:
46
+
47
+ HEDWING_ENDPOINT="http://localhost:5000" DEV=true hoot
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruddfawcett/hoot.
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/hoot ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'hoot'
4
+
5
+ Signal.trap('INT') {} # Suppress backtrace when exiting command
6
+
7
+ if Hoot::User.isAuthenticated?
8
+ client = Hoot::Client.new
9
+
10
+ client.send
11
+ else
12
+ Hoot::User.authenticate
13
+ end
data/hoot.gemspec ADDED
@@ -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 'hoot/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "hoot"
8
+ s.version = Hoot::VERSION
9
+ s.authors = ["Rudd Fawcett"]
10
+ s.email = ["rudd.fawcett@gmail.com"]
11
+
12
+ s.summary = "Send push notifications to your phone when a Terminal process has completed."
13
+ s.description = ""
14
+ s.homepage = "https://github.com/ruddfawcett/hoot"
15
+ s.license = "MIT"
16
+
17
+ s.add_dependency "netrc"
18
+ s.add_dependency "json"
19
+
20
+ s.files = Dir["./**/*"].reject { |file| file =~ /\.\/(bin|log|pkg|script|spec|test|vendor)/ }
21
+ s.executables = ["hoot"]
22
+ s.require_paths = ["lib"]
23
+
24
+ s.add_development_dependency "bundler", "~> 1.10"
25
+ s.add_development_dependency "rake", "~> 10.0"
26
+ end
@@ -0,0 +1,55 @@
1
+ require 'json'
2
+ require 'net/https'
3
+ require 'uri'
4
+
5
+ module Hoot
6
+ unless ENV['DEV']
7
+ HEDWING_ENDPOINT = 'https://hedwig.herokuapp.com'
8
+ else
9
+ HEDWING_ENDPOINT = 'http://localhost:5000'
10
+ end
11
+
12
+ class Client
13
+ attr_accessor :hedwig
14
+ attr_accessor :credentials
15
+
16
+ def initialize
17
+ @hedwig = ENV['HEDWING_ENDPOINT'] || HEDWING_ENDPOINT
18
+ @credentials = Hoot::User::credentials
19
+ end
20
+
21
+ def send
22
+ # TODO: Custom messages
23
+
24
+ response = request(@hedwig)
25
+ response = JSON.parse(response.body)
26
+
27
+ if response['error']
28
+ abort('A server error occurred.')
29
+ end
30
+
31
+ if response['result']
32
+ abort('A Hoot was sent to your device.')
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def request(uri)
39
+ uri = URI.parse(uri)
40
+ http = Net::HTTP.new(uri.host, uri.port)
41
+
42
+ unless ENV['DEV']
43
+ http.use_ssl = true
44
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
45
+ end
46
+
47
+ request = Net::HTTP::Post.new('/api/v1/send')
48
+ request.add_field('Content-Type', 'application/json')
49
+ request.set_form_data({'credentials[email]' => @credentials[0], 'credentials[password]' => @credentials[1]})
50
+ response = http.request(request)
51
+
52
+ response
53
+ end
54
+ end
55
+ end
data/lib/hoot/user.rb ADDED
@@ -0,0 +1,76 @@
1
+ require 'netrc'
2
+ require 'io/console'
3
+ require 'digest/sha1'
4
+
5
+ module Hoot
6
+ module User
7
+ @n = Netrc.read
8
+
9
+ def self.isAuthenticated?
10
+ @n = Netrc.read
11
+ login, password = @n['hedwig.herokuapp.com']
12
+
13
+ if login.nil? || password.nil?
14
+ false
15
+ else
16
+ true
17
+ end
18
+ end
19
+
20
+ def self.form
21
+ puts 'Please enter your Hoot credentials.'
22
+
23
+ print 'Email: '
24
+ login = gets.chomp
25
+
26
+ while login.length == 0
27
+ puts 'Please enter an email...'
28
+ print 'Email: '
29
+ login = gets.chomp
30
+ end
31
+
32
+ if STDIN.respond_to?(:noecho)
33
+ def self.get_password(prompt='Password: ')
34
+ print prompt
35
+ STDIN.noecho(&:gets).chomp
36
+ end
37
+ else
38
+ def self.get_password(prompt='Password: ')
39
+ `read -s -p '#{prompt}' password; echo $password`.chomp
40
+ end
41
+ end
42
+
43
+ password = self.get_password
44
+
45
+ while password.length == 0
46
+ puts 'Please enter a password...'
47
+ password = self.get_password
48
+ end
49
+
50
+ password = Digest::SHA1.hexdigest(password)
51
+
52
+ [login, password]
53
+ end
54
+
55
+
56
+ def self.authenticate
57
+ credentials = self.form
58
+
59
+ @n['hedwig.herokuapp.com'] = credentials[0], credentials[1]
60
+ @n.save
61
+
62
+ puts
63
+ puts 'Your credentials have been saved.'
64
+ end
65
+
66
+ def self.credentials
67
+ if self.isAuthenticated?
68
+ login, password = @n['hedwig.herokuapp.com']
69
+
70
+ [login, password]
71
+ else
72
+ self.authenticate
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,3 @@
1
+ module Hoot
2
+ VERSION = "0.1.0"
3
+ end
data/lib/hoot.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "hoot/version"
2
+ require "hoot/client"
3
+ require "hoot/user"
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hoot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rudd Fawcett
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: netrc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
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.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: ''
70
+ email:
71
+ - rudd.fawcett@gmail.com
72
+ executables:
73
+ - hoot
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - "./Gemfile"
78
+ - "./Gemfile.lock"
79
+ - "./LICENSE"
80
+ - "./README.md"
81
+ - "./Rakefile"
82
+ - "./hoot.gemspec"
83
+ - "./lib/hoot.rb"
84
+ - "./lib/hoot/client.rb"
85
+ - "./lib/hoot/user.rb"
86
+ - "./lib/hoot/version.rb"
87
+ - bin/hoot
88
+ homepage: https://github.com/ruddfawcett/hoot
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.4.8
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Send push notifications to your phone when a Terminal process has completed.
112
+ test_files: []