Class: RhoDevelopment::Subscriber
- Defined in:
- lib/build/development/subscriber.rb
Instance Attribute Summary collapse
-
#application ⇒ Object
Returns the value of attribute application.
-
#name ⇒ Object
Returns the value of attribute name.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #beDisabled ⇒ Object
- #beEnabled ⇒ Object
- #enabled? ⇒ Boolean
- #full_notify(aFilename) ⇒ Object
- #has_ip(aString) ⇒ Object
-
#initialize ⇒ Subscriber
constructor
A new instance of Subscriber.
- #ip ⇒ Object
- #normalized_platform_name ⇒ Object
- #notify(anUrl) ⇒ Object
- #notify_url(filename) ⇒ Object
- #partial_notify(aFilename) ⇒ Object
- #port ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Subscriber
Returns a new instance of Subscriber.
16 17 18 |
# File 'lib/build/development/subscriber.rb', line 16 def initialize self.beEnabled end |
Instance Attribute Details
#application ⇒ Object
Returns the value of attribute application.
14 15 16 |
# File 'lib/build/development/subscriber.rb', line 14 def application @application end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/build/development/subscriber.rb', line 13 def name @name end |
#platform ⇒ Object
Returns the value of attribute platform.
12 13 14 |
# File 'lib/build/development/subscriber.rb', line 12 def platform @platform end |
#uri ⇒ Object
Returns the value of attribute uri.
11 12 13 |
# File 'lib/build/development/subscriber.rb', line 11 def uri @uri end |
Instance Method Details
#beDisabled ⇒ Object
36 37 38 |
# File 'lib/build/development/subscriber.rb', line 36 def beDisabled @enabled = false end |
#beEnabled ⇒ Object
32 33 34 |
# File 'lib/build/development/subscriber.rb', line 32 def beEnabled @enabled = true end |
#enabled? ⇒ Boolean
28 29 30 |
# File 'lib/build/development/subscriber.rb', line 28 def enabled? @enabled end |
#full_notify(aFilename) ⇒ Object
88 89 90 |
# File 'lib/build/development/subscriber.rb', line 88 def full_notify(aFilename) self.notify(self.notify_url(aFilename)) end |
#has_ip(aString) ⇒ Object
50 51 52 |
# File 'lib/build/development/subscriber.rb', line 50 def has_ip(aString) self.ip == aString end |
#ip ⇒ Object
20 21 22 |
# File 'lib/build/development/subscriber.rb', line 20 def ip @uri.split(':')[0] end |
#normalized_platform_name ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/build/development/subscriber.rb', line 40 def normalized_platform_name if ['apple', 'iphone'].include?(@platform.downcase) return 'iphone' end if ['ANDROID'].include?(@platform.downcase) return 'android' end @platform.downcase end |
#notify(anUrl) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/build/development/subscriber.rb', line 69 def notify(anUrl) puts anUrl.to_s print "Notifying #{self} ...".primary begin http = Net::HTTP.new(anUrl.host, anUrl.port) http.open_timeout = 5 http.start() { |http| http.get(anUrl.path + '?' + anUrl.query) } puts 'done'.success rescue *Configuration::handledNetworkExceptions => e puts 'failed'.warning end end |
#notify_url(filename) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/build/development/subscriber.rb', line 54 def notify_url(filename) url = URI("http://#{@uri}/development/update_bundle") params = [] params << "package_url=http://#{Configuration::webserver_ip}:#{Configuration::webserver_port}/download/#{self.normalized_platform_name}/#{filename}" params << "server_ip=#{Configuration::webserver_ip}" params << "server_port=#{Configuration::webserver_port}" if Configuration::auto_refresh? then params << 'refresh_after_update=true' end query = params.join('&') url.query = query #puts url.to_s.warning return url end |
#partial_notify(aFilename) ⇒ Object
84 85 86 |
# File 'lib/build/development/subscriber.rb', line 84 def partial_notify(aFilename) self.notify(self.notify_url(aFilename)) end |
#port ⇒ Object
24 25 26 |
# File 'lib/build/development/subscriber.rb', line 24 def port @uri.split(':')[1] end |