Class: RhoDevelopment::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/build/development/subscriber.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSubscriber

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

#applicationObject

Returns the value of attribute application.



14
15
16
# File 'lib/build/development/subscriber.rb', line 14

def application
  @application
end

#nameObject

Returns the value of attribute name.



13
14
15
# File 'lib/build/development/subscriber.rb', line 13

def name
  @name
end

#platformObject

Returns the value of attribute platform.



12
13
14
# File 'lib/build/development/subscriber.rb', line 12

def platform
  @platform
end

#uriObject

Returns the value of attribute uri.



11
12
13
# File 'lib/build/development/subscriber.rb', line 11

def uri
  @uri
end

Instance Method Details

#beDisabledObject



36
37
38
# File 'lib/build/development/subscriber.rb', line 36

def beDisabled
  @enabled = false
end

#beEnabledObject



32
33
34
# File 'lib/build/development/subscriber.rb', line 32

def beEnabled
  @enabled = true
end

#enabled?Boolean

Returns:

  • (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

#ipObject



20
21
22
# File 'lib/build/development/subscriber.rb', line 20

def ip
  @uri.split(':')[0]
end

#normalized_platform_nameObject



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

#portObject



24
25
26
# File 'lib/build/development/subscriber.rb', line 24

def port
  @uri.split(':')[1]
end

#to_sObject



93
94
95
# File 'lib/build/development/subscriber.rb', line 93

def to_s
  "#{self.class}(uri=#{@uri}, name=#{@name}, platform=#{@platform}, app=#{@application}, enabled=#{@enabled})"
end