whos_in 0.0.1
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/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/every-5-seconds.sh +6 -0
- data/bin/local_scanner.sh +32 -0
- data/bin/whos_in +44 -0
- data/lib/whos_in/version.rb +3 -0
- data/lib/whos_in.rb +83 -0
- data/whos_in_gem.gemspec +25 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5643c7da5a6b9bb9f5514833879a16da5dca4cd0
|
4
|
+
data.tar.gz: 9380ad6f6d7dae8cb3c7fec2b2d9e2ec2d9f76e3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 73058b99c21aacd0bdb0c2a6bda3863017609f7653851400cb6785ddccbbf09c5455d25f701bece425c70afa093364cbdc785e3eb2dc529ee74c47d84712459e
|
7
|
+
data.tar.gz: 666b01e48a2a9a6f484cc1b268af9c1a15c0b538dc5ab9f52031c125a942df8d22aa57eb9ff0de5b8f9e2d6733a6842dd6b46ef0474148e56b84591043382225
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jamie Patel
|
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,31 @@
|
|
1
|
+
# WhosInGem
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'whos_in_gem'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install whos_in_gem
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/whos_in_gem/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
APP_USERNAME="foo"
|
4
|
+
APP_PASSWORD="bar"
|
5
|
+
WHOSIN_URL=$1
|
6
|
+
|
7
|
+
local_scan() {
|
8
|
+
macs=( $(sudo nmap -sn 192.168.1.0/24 | grep -Eio "([0-9A-F]{2}:){5}[0-9A-F]{2}") )
|
9
|
+
}
|
10
|
+
|
11
|
+
update_offline_since() {
|
12
|
+
local json=()
|
13
|
+
local DATE=$(date)
|
14
|
+
|
15
|
+
for i in "${!macs[@]}"; do
|
16
|
+
json[$i]="{\"mac\": \"${macs[$i]}\"}"
|
17
|
+
done
|
18
|
+
|
19
|
+
json=$( IFS=, ; echo "${json[*]}")
|
20
|
+
json="[$json]"
|
21
|
+
|
22
|
+
curl -X POST -d "$json" $WHOSIN_URL >/dev/null 2>&1
|
23
|
+
|
24
|
+
}
|
25
|
+
|
26
|
+
local_scan
|
27
|
+
|
28
|
+
if [ ${#macs[@]} -eq 0 ]; then
|
29
|
+
echo "{'error': 'Nobody here'}"
|
30
|
+
else
|
31
|
+
update_offline_since
|
32
|
+
fi
|
data/bin/whos_in
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'commander/import'
|
5
|
+
require_relative '../lib/whos_in'
|
6
|
+
|
7
|
+
program :version, '0.0.1'
|
8
|
+
program :description, 'Setting up your whos_in realtime Heroku app'
|
9
|
+
|
10
|
+
command :init do |c|
|
11
|
+
c.syntax = 'whos_in init, [options]'
|
12
|
+
c.summary = 'Sets up your own Who\'s In? application'
|
13
|
+
c.description = 'Step-by-step it takes you to the Heroku deploy site, asks for your Pusher keys and sets up your application'
|
14
|
+
c.example 'description', 'command example'
|
15
|
+
c.option '--some-switch', 'Some switch that does something'
|
16
|
+
c.action do |args, options|
|
17
|
+
application = WhosIn::Application.new
|
18
|
+
application.setup
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
command :run do |c|
|
23
|
+
c.syntax = 'whos_in run APP_NAME'
|
24
|
+
c.summary = 'Pass in the application name and it runs the local scanner script and posts it to your app'
|
25
|
+
c.description = ''
|
26
|
+
c.example 'description', 'whos_in run _your_app_name_'
|
27
|
+
c.option '--some-switch', 'Some switch that does something'
|
28
|
+
c.action do |args, options|
|
29
|
+
app_name = args.first
|
30
|
+
WhosIn::Application.run_app app_name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# command :kill do |c|
|
35
|
+
# c.syntax = 'whos_in kill APP_NAME'
|
36
|
+
# c.summary = 'Stops the cron script'
|
37
|
+
# c.description = ''
|
38
|
+
# c.example 'description', 'whos_in kill _your_app_name_'
|
39
|
+
# c.option '--some-switch', 'Some switch that does something'
|
40
|
+
# c.action do |args, options|
|
41
|
+
# # app_name = args.first
|
42
|
+
# # WhosIn::Application.kill
|
43
|
+
# end
|
44
|
+
# end
|
data/lib/whos_in.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require_relative "whos_in/version"
|
2
|
+
require 'rufus-scheduler'
|
3
|
+
|
4
|
+
module WhosIn
|
5
|
+
|
6
|
+
class Application
|
7
|
+
|
8
|
+
def launch_heroku_deploy
|
9
|
+
puts "Launching deployment setup... come back here when you're done"
|
10
|
+
sleep 2
|
11
|
+
`open https://heroku.com/deploy?template=https://github.com/jpatel531/whos_in`
|
12
|
+
end
|
13
|
+
|
14
|
+
def ask_for_app_name
|
15
|
+
puts "What is the name of your Heroku application?"
|
16
|
+
@name = STDIN.gets.chomp
|
17
|
+
end
|
18
|
+
|
19
|
+
def ask_for_pusher_key
|
20
|
+
puts "What is your Pusher app key?"
|
21
|
+
@pusher_key = STDIN.gets.chomp
|
22
|
+
end
|
23
|
+
|
24
|
+
def ask_for_pusher_secret
|
25
|
+
puts "What is your Pusher app secret?"
|
26
|
+
@pusher_secret = STDIN.gets.chomp
|
27
|
+
end
|
28
|
+
|
29
|
+
def ask_for_app_id
|
30
|
+
puts "What is your app id?"
|
31
|
+
@app_id = STDIN.gets.chomp
|
32
|
+
end
|
33
|
+
|
34
|
+
def ask_for_pusher_details
|
35
|
+
ask_for_app_name and ask_for_pusher_key and ask_for_pusher_secret and ask_for_app_id
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_config_vars
|
39
|
+
vars = "WHOS_IN_KEY=#{@pusher_key} WHOS_IN_SECRET=#{@pusher_secret} WHOS_IN_ID=#{@app_id}"
|
40
|
+
puts "Setting #{vars} of #{@name}"
|
41
|
+
`heroku config:set #{vars} -a #{@name}`
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup
|
45
|
+
launch_heroku_deploy
|
46
|
+
ask_for_pusher_details
|
47
|
+
set_config_vars
|
48
|
+
end
|
49
|
+
|
50
|
+
# MAKE RUN SCRIPT
|
51
|
+
|
52
|
+
def self.tell_user_and_scan_network
|
53
|
+
puts "Scanning local network and posting to #{@heroku_url}"
|
54
|
+
puts "Press Ctrl+C to interrupt"
|
55
|
+
`bin/local_scanner.sh #{@heroku_url}`
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.run_script
|
59
|
+
tell_user_and_scan_network
|
60
|
+
scheduler = Rufus::Scheduler.new
|
61
|
+
scheduler.every '2m' do
|
62
|
+
tell_user_and_scan_network
|
63
|
+
end
|
64
|
+
scheduler.join
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.open_app
|
68
|
+
puts "Opening your application"
|
69
|
+
sleep 2
|
70
|
+
`open #{@heroku_app}`
|
71
|
+
sleep 3
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.run_app app_name
|
75
|
+
@heroku_app = "http://#{app_name}.herokuapp.com"
|
76
|
+
@heroku_url = @heroku_app + "/people"
|
77
|
+
self.open_app
|
78
|
+
self.run_script
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/whos_in_gem.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'whos_in/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "whos_in"
|
8
|
+
spec.version = WhosIn::VERSION
|
9
|
+
spec.authors = ["Jamie Patel"]
|
10
|
+
spec.email = ["jamie@notespublication.com"]
|
11
|
+
spec.summary = %q{Sets up and deploys your own Who's In application}
|
12
|
+
spec.description = %q{Sets up heroku deployment, config variables and the script that scans the local network and posts to your app}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = ["whos_in"]
|
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_runtime_dependency "commander", ">= 4.2.1"
|
24
|
+
spec.add_runtime_dependency "rufus-scheduler", "~> 3.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: whos_in
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jamie Patel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-30 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: commander
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 4.2.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 4.2.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rufus-scheduler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Sets up heroku deployment, config variables and the script that scans
|
70
|
+
the local network and posts to your app
|
71
|
+
email:
|
72
|
+
- jamie@notespublication.com
|
73
|
+
executables:
|
74
|
+
- whos_in
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/every-5-seconds.sh
|
84
|
+
- bin/local_scanner.sh
|
85
|
+
- bin/whos_in
|
86
|
+
- lib/whos_in.rb
|
87
|
+
- lib/whos_in/version.rb
|
88
|
+
- whos_in_gem.gemspec
|
89
|
+
homepage: ''
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.4.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Sets up and deploys your own Who's In application
|
113
|
+
test_files: []
|