pusher_whos_in 0.0.5

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 04f447bd3a9911488ab0b089ce05fd96124d3371
4
+ data.tar.gz: 66291082e17f795965ff2982929ea2e7125009d6
5
+ SHA512:
6
+ metadata.gz: 27fd4945c44fd3f4c7e8a592f012fe7180ca5ae2c3f29b2c6211efb45366d6d25a1467927622f2884714aa531574d99724fe85cbf92a24bf2fa73a498ed07b88
7
+ data.tar.gz: 0f653c80fe9a4ed813a5b6eb02dd1434054c0cc7d778b162b8afa92624a5e6ebeb96c7c46df468b7aa13a3c6dbd08e23fd94205197db2bebd26600e587a37289
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in whos_in_gem.gemspec
4
+ gemspec
5
+
6
+ gem 'commander'
7
+ gem 'rufus-scheduler'
@@ -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.
@@ -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
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+ while true
3
+ do
4
+ sh bin/local_scanner.sh $1
5
+ sleep 5
6
+ done
@@ -0,0 +1,32 @@
1
+ #!/bin/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
@@ -0,0 +1,32 @@
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 = 'Takes you to the Heroku page where you can deploy your own Who\'s In App'
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
@@ -0,0 +1,53 @@
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... \n\n When you're done run 'whos_in run *your_app_name* "
10
+ sleep 2
11
+ `open https://heroku.com/deploy?template=https://github.com/jpatel531/whos_in`
12
+ end
13
+
14
+ def setup
15
+ launch_heroku_deploy
16
+ end
17
+
18
+ # MAKE RUN SCRIPT
19
+
20
+ def self.tell_user_and_scan_network
21
+ script = File.expand_path('../../bin/local_scanner', __FILE__)
22
+
23
+ puts "Scanning local network and posting to #{@heroku_url}"
24
+ puts "Press Ctrl+C to interrupt"
25
+ `#{script} #{@heroku_url}`
26
+ end
27
+
28
+ def self.run_script
29
+ tell_user_and_scan_network
30
+ scheduler = Rufus::Scheduler.new
31
+ scheduler.every '2m' do
32
+ tell_user_and_scan_network
33
+ end
34
+ scheduler.join
35
+ end
36
+
37
+ def self.open_app
38
+ puts "Opening your application"
39
+ sleep 2
40
+ `open #{@heroku_app}`
41
+ sleep 3
42
+ end
43
+
44
+ def self.run_app app_name
45
+ @heroku_app = "http://#{app_name}.herokuapp.com"
46
+ @heroku_url = @heroku_app + "/people"
47
+ self.open_app
48
+ self.run_script
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,3 @@
1
+ module WhosIn
2
+ VERSION = "0.0.5"
3
+ end
@@ -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 = "pusher_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 = ["pusher_whos_in", "local_scanner"]
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,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pusher_whos_in
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Jamie Patel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-31 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
+ - pusher_whos_in
75
+ - local_scanner
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/every-5-seconds.sh
85
+ - bin/local_scanner
86
+ - bin/pusher_whos_in
87
+ - lib/whos_in.rb
88
+ - lib/whos_in/version.rb
89
+ - whos_in_gem.gemspec
90
+ homepage: ''
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.4.2
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Sets up and deploys your own Who's In application
114
+ test_files: []