Class: Unfuddle::Session
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- Unfuddle::Session
- Defined in:
- lib/unfuddle/session.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#password ⇒ Object
Returns the value of attribute password.
-
#url ⇒ Object
Returns the value of attribute url.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize ⇒ Session
constructor
A new instance of Session.
- #site ⇒ Object
Constructor Details
#initialize ⇒ Session
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/unfuddle/session.rb', line 9 def initialize #file_path = File.join(RAILS_ROOT, "config", "unfuddle.yml") file_path = File.join(File.dirname(__FILE__), "..", "unfuddle.yml") @errors = [] if File.exists?(file_path) config = YAML.load_file(file_path)["development"] %W(account username password).each do |key| if(config[key].nil? || config[key] == "") @errors.push("Unfuddle Gem::Error Missing parameter #{key}") end end raise Exception.new(@errors.join(", ")) unless errors.size == 0 self.account, self.username, self.password, self.url = config["account"], config["username"], config["password"], "#{config["account"]}.unfuddle.com" else $stdout.puts "Unfuddle Gem::Error Missing unfuddle yaml config file, please create it in config/" end ActiveResource::Base.site = URI.parse(site) end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
5 6 7 |
# File 'lib/unfuddle/session.rb', line 5 def account @account end |
#errors ⇒ Object
Returns the value of attribute errors.
5 6 7 |
# File 'lib/unfuddle/session.rb', line 5 def errors @errors end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/unfuddle/session.rb', line 5 def password @password end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/unfuddle/session.rb', line 5 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/unfuddle/session.rb', line 5 def username @username end |
Instance Method Details
#site ⇒ Object
37 38 39 |
# File 'lib/unfuddle/session.rb', line 37 def site "#{protocol}://#{username}:#{password}@#{url}/api/v1" end |