Class: YMDT::Base

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

Overview

Wraps calls to the Yahoo! Mail Development Tool for creating applications with the Yahoo! Mail Development Platform.

Usage

@ymdt = YMDT::Base.new(:username => "username", :password => "password")

Uploads all files in “my_app/views”:

@ymdt.put(:path => "/my_app/views/*")

Creates a new local server from the given application_id:

@ymdt.create(:path => "/my_new_app", :application_id => "abcdefg")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ymdt.rb', line 33

def initialize(params={})
  @username = params[:username]
  @password = params[:password]
  @applications_path = params[:applications_path] || "./servers"
  
  unless @username
    raise ArgumentError.new("username required")
  end
  unless @password
    raise ArgumentError.new("password required")
  end
  @script_path = params[:script_path] || "./script/ymdt"
end

Instance Attribute Details

#applications_pathObject

Returns the value of attribute applications_path.



31
32
33
# File 'lib/ymdt.rb', line 31

def applications_path
  @applications_path
end

#passwordObject

Returns the value of attribute password.



31
32
33
# File 'lib/ymdt.rb', line 31

def password
  @password
end

#script_pathObject

Returns the value of attribute script_path.



31
32
33
# File 'lib/ymdt.rb', line 31

def script_path
  @script_path
end

#usernameObject

Returns the value of attribute username.



31
32
33
# File 'lib/ymdt.rb', line 31

def username
  @username
end

Instance Method Details

#compress(params = {}) ⇒ Object



55
56
57
# File 'lib/ymdt.rb', line 55

def compress(params={})
  invoke(:compress, params)
end

#create(params = {}) ⇒ Object

Raises:

  • (ArgumentError)


59
60
61
62
# File 'lib/ymdt.rb', line 59

def create(params={})
  raise ArgumentError.new("application_id required") unless params[:application_id]
  invoke(:get, params)
end

#get(params = {}) ⇒ Object



51
52
53
# File 'lib/ymdt.rb', line 51

def get(params={})
  invoke(:get, params)
end

#invoke(command, params = {}) ⇒ Object

prepares the commands to correctly reference the application and path



74
75
76
77
78
# File 'lib/ymdt.rb', line 74

def invoke(command, params={})
  command_string = compile_command(command, params)
  output_command(command_string)
  execute(command_string, params)
end

#ls(params = {}) ⇒ Object



64
65
66
# File 'lib/ymdt.rb', line 64

def ls(params={})
  invoke(:ls, {:return => true}.merge(params))
end

#put(params = {}) ⇒ Object



47
48
49
# File 'lib/ymdt.rb', line 47

def put(params={})
  invoke(:put, params)
end

#upgrade(params = {}) ⇒ Object



68
69
70
# File 'lib/ymdt.rb', line 68

def upgrade(params={})
  invoke(:upgrade, params)
end