Class: Unfuddle::Session

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
lib/unfuddle/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSession



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., 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

#accountObject

Returns the value of attribute account.



5
6
7
# File 'lib/unfuddle/session.rb', line 5

def 
  @account
end

#errorsObject

Returns the value of attribute errors.



5
6
7
# File 'lib/unfuddle/session.rb', line 5

def errors
  @errors
end

#passwordObject

Returns the value of attribute password.



5
6
7
# File 'lib/unfuddle/session.rb', line 5

def password
  @password
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/unfuddle/session.rb', line 5

def url
  @url
end

#usernameObject

Returns the value of attribute username.



5
6
7
# File 'lib/unfuddle/session.rb', line 5

def username
  @username
end

Instance Method Details

#siteObject



37
38
39
# File 'lib/unfuddle/session.rb', line 37

def site
  "#{protocol}://#{username}:#{password}@#{url}/api/v1"
end