Class: WhosIn::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/whos_in.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.open_appObject



68
69
70
71
72
73
# File 'lib/whos_in.rb', line 68

def self.open_app
	puts "Opening your application"
	sleep 2
	`open #{@heroku_app}`
	sleep 3
end

.run_app(app_name) ⇒ Object



75
76
77
78
79
80
# File 'lib/whos_in.rb', line 75

def self.run_app app_name
	@heroku_app = "http://#{app_name}.herokuapp.com"
	@heroku_url = @heroku_app + "/people"
	self.open_app
	self.run_script
end

.run_scriptObject



59
60
61
62
63
64
65
66
# File 'lib/whos_in.rb', line 59

def self.run_script
	tell_user_and_scan_network
	scheduler = Rufus::Scheduler.new
	scheduler.every '2m' do
		tell_user_and_scan_network
	end
	scheduler.join
end

.tell_user_and_scan_networkObject

MAKE RUN SCRIPT



52
53
54
55
56
57
# File 'lib/whos_in.rb', line 52

def self.tell_user_and_scan_network
	puts "Scanning local network and posting to #{@heroku_url}"
	puts "Press Ctrl+C to interrupt"
	# puts `pwd`
	`local_scanner #{@heroku_url}`
end

Instance Method Details

#ask_for_app_idObject



29
30
31
32
# File 'lib/whos_in.rb', line 29

def ask_for_app_id
	puts "What is your app id?"
	@app_id = STDIN.gets.chomp
end

#ask_for_app_nameObject



14
15
16
17
# File 'lib/whos_in.rb', line 14

def ask_for_app_name
	puts "What is the name of your Heroku application?"
	@name = STDIN.gets.chomp
end

#ask_for_pusher_detailsObject



34
35
36
# File 'lib/whos_in.rb', line 34

def ask_for_pusher_details
	ask_for_app_name and ask_for_pusher_key and ask_for_pusher_secret and ask_for_app_id
end

#ask_for_pusher_keyObject



19
20
21
22
# File 'lib/whos_in.rb', line 19

def ask_for_pusher_key
	puts "What is your Pusher app key?"
	@pusher_key = STDIN.gets.chomp
end

#ask_for_pusher_secretObject



24
25
26
27
# File 'lib/whos_in.rb', line 24

def ask_for_pusher_secret
	puts "What is your Pusher app secret?"
	@pusher_secret = STDIN.gets.chomp
end

#launch_heroku_deployObject



8
9
10
11
12
# File 'lib/whos_in.rb', line 8

def launch_heroku_deploy
	puts "Launching deployment setup... come back here when you're done" 
	sleep 2
	`open https://heroku.com/deploy?template=https://github.com/jpatel531/whos_in`
end

#set_config_varsObject



38
39
40
41
42
# File 'lib/whos_in.rb', line 38

def set_config_vars
	vars = "WHOS_IN_KEY=#{@pusher_key} WHOS_IN_SECRET=#{@pusher_secret} WHOS_IN_ID=#{@app_id}"
	puts "Setting #{vars} of #{@name}"
	`heroku config:set #{vars} -a #{@name}`
end

#setupObject



44
45
46
47
48
# File 'lib/whos_in.rb', line 44

def setup
	launch_heroku_deploy
	ask_for_pusher_details
	set_config_vars
end