Class: Gallery::Remote
- Inherits:
-
Object
- Object
- Gallery::Remote
- Defined in:
- lib/gallery/remote.rb
Constant Summary collapse
- GR_STAT_SUCCESS =
0
- PROTO_MAJ_VER_INVAL =
101
- PROTO_MIN_VER_INVAL =
102
- PROTO_VER_FMT_INVAL =
103
- PROTO_VER_MISSING =
104
- PASSWD_WRONG =
201
- LOGIN_MISSING =
202
- UNKNOWN_CMD =
301
- NO_ADD_PERMISSION =
401
- NO_FILENAME =
402
- UPLOAD_PHOTO_FAIL =
403
- NO_WRITE_PERMISSION =
404
- NO_VIEW_PERMISSIO =
405
- NO_CREATE_ALBUM_PERMISSION =
501
- CREATE_ALBUM_FAILED =
502
- MOVE_ALBUM_FAILED =
503
- ROTATE_IMAGE_FAILED =
504
- STATUS_DESCRIPTIONS =
{ GR_STAT_SUCCESS => 'The command the client sent in the request completed successfully. The data (if any) in the response should be considered valid.', PROTO_MAJ_VER_INVAL => 'The protocol major version the client is using is not supported.', PROTO_MIN_VER_INVAL => 'The protocol minor version the client is using is not supported.', PROTO_VER_FMT_INVAL => 'The format of the protocol version string the client sent in the request is invalid.', PROTO_VER_MISSING => 'The request did not contain the required protocol_version key.', PASSWD_WRONG => 'The password and/or username the client send in the request is invalid.', LOGIN_MISSING => 'The client used the login command in the request but failed to include either the username or password (or both) in the request.', UNKNOWN_CMD => 'The value of the cmd key is not valid.', NO_ADD_PERMISSION => 'The user does not have permission to add an item to the gallery.', NO_FILENAME => 'No filename was specified.', UPLOAD_PHOTO_FAIL => 'The file was received, but could not be processed or added to the album.', NO_WRITE_PERMISSION => 'No write permission to destination album.', NO_VIEW_PERMISSIO => 'No view permission for this image.', NO_CREATE_ALBUM_PERMISSION => 'A new album could not be created because the user does not have permission to do so.', CREATE_ALBUM_FAILED => 'A new album could not be created, for a different reason (name conflict).', MOVE_ALBUM_FAILED => 'The album could not be moved.', ROTATE_IMAGE_FAILED => 'The image could not be rotated' }
- @@supported_types =
{ '.avi' => 'video/x-msvideo', '.bmp' => 'image/bmp', '.gif' => 'image/gif', '.jpe' => 'image/jpeg', '.jpg' => 'image/jpeg', '.jpeg' => 'image/jpeg', '.mov' => 'video/quicktime', '.qt' => 'video/quicktime', '.mp4' => 'video/mp4', '.tif' => 'image/tiff', '.tiff' => 'image/tiff' }
Instance Attribute Summary collapse
-
#last_response ⇒ Object
Returns the value of attribute last_response.
-
#status ⇒ Object
Returns the value of attribute status.
-
#status_text ⇒ Object
Returns the value of attribute status_text.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_item(set_albumName, userfile_name, params = {}) ⇒ Object
cmd=add-item protocol_version=2.0 set_albumName=album name userfile=user-file userfile_name=file-name caption=caption [optional] force_filename=force-filename [optional] auto_rotate=yes/no [optional, since 2.5] extrafield.fieldname=fieldvalue [optional, since 2.3].
-
#album_properties(set_albumName, params = {}) ⇒ Object
cmd=album-properties protocol_version=2.0 set_albumName=album-name.
-
#fetch_album_images(set_albumName, params = {}) ⇒ Object
cmd=fetch-album-images protocol_version=2.4 set_albumName=album-name albums_too=yes/no [optional, since 2.13] random=yes/no [optional, G2 since ***] limit=number-of-images [optional, G2 since ***] extrafields=yes/no [optional, G2 since 2.12] all_sizes=yes/no [optional, G2 since 2.14].
-
#fetch_albums_prune(params = {}) ⇒ Object
cmd=fetch-albums-prune protocol_version=2.2 no_perms=yes/no [optional, G2 since 2.9].
-
#image_properties(id, params = {}) ⇒ Object
cmd=image-properties protocol_version=*** id=item-id.
-
#initialize(url) ⇒ Remote
constructor
A new instance of Remote.
-
#login(uname, password, params = {}) ⇒ Object
cmd=login protocol_version=2.0 uname=gallery-user-name password=cleartext-password.
-
#new_album(set_albumName, params = {}) ⇒ Object
cmd=new-album protocol_version=2.1 set_albumName=parent-album-name newAlbumName=album-name [optional] newAlbumTitle=album-title [optional] newAlbumDesc=album-description [optional].
- #status_msg ⇒ Object
Constructor Details
#initialize(url) ⇒ Remote
Returns a new instance of Remote.
64 65 66 67 68 69 70 71 72 |
# File 'lib/gallery/remote.rb', line 64 def initialize(url) @uri = URI.parse(url) @base_params = { 'g2_controller' => 'remote:GalleryRemote', 'g2_form[protocol_version]' => '2.9' } @cookie_jar = CookieJar.new @boundary = '7d21f123d00c4' end |
Instance Attribute Details
#last_response ⇒ Object
Returns the value of attribute last_response.
7 8 9 |
# File 'lib/gallery/remote.rb', line 7 def last_response @last_response end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/gallery/remote.rb', line 7 def status @status end |
#status_text ⇒ Object
Returns the value of attribute status_text.
7 8 9 |
# File 'lib/gallery/remote.rb', line 7 def status_text @status_text end |
Class Method Details
.supported_type?(extension) ⇒ Boolean
60 61 62 |
# File 'lib/gallery/remote.rb', line 60 def self.supported_type?(extension) @@supported_types.has_key?(extension) end |
Instance Method Details
#add_item(set_albumName, userfile_name, params = {}) ⇒ Object
cmd=add-item protocol_version=2.0 set_albumName=album name userfile=user-file userfile_name=file-name caption=caption [optional] force_filename=force-filename [optional] auto_rotate=yes/no [optional, since 2.5] extrafield.fieldname=fieldvalue [optional, since 2.3]
100 101 102 103 |
# File 'lib/gallery/remote.rb', line 100 def add_item(set_albumName, userfile_name, params = {}) params = { :cmd => 'add-item', :set_albumName => set_albumName, :userfile_name => userfile_name }.merge(params) send_request(params) end |
#album_properties(set_albumName, params = {}) ⇒ Object
cmd=album-properties protocol_version=2.0 set_albumName=album-name
108 109 110 111 |
# File 'lib/gallery/remote.rb', line 108 def album_properties(set_albumName, params = {}) params = { :cmd => 'album-properties', :set_albumName => set_albumName }.merge(params) send_request(params) end |
#fetch_album_images(set_albumName, params = {}) ⇒ Object
cmd=fetch-album-images protocol_version=2.4 set_albumName=album-name albums_too=yes/no [optional, since 2.13] random=yes/no [optional, G2 since ***] limit=number-of-images [optional, G2 since ***] extrafields=yes/no [optional, G2 since 2.12] all_sizes=yes/no [optional, G2 since 2.14]
132 133 134 135 |
# File 'lib/gallery/remote.rb', line 132 def fetch_album_images(set_albumName, params = {}) params = { :cmd => 'fetch-album-images', :set_albumName => set_albumName }.merge(params) send_request(params) end |
#fetch_albums_prune(params = {}) ⇒ Object
cmd=fetch-albums-prune protocol_version=2.2 no_perms=yes/no [optional, G2 since 2.9]
86 87 88 89 |
# File 'lib/gallery/remote.rb', line 86 def fetch_albums_prune(params = {}) params = { :cmd => 'fetch-albums-prune', :no_perms => 'y' }.merge(params) send_request(params) end |
#image_properties(id, params = {}) ⇒ Object
cmd=image-properties protocol_version=*** id=item-id
140 141 142 143 |
# File 'lib/gallery/remote.rb', line 140 def image_properties(id, params = {}) params = { :cmd => 'image-properties', :id => id }.merge(params) send_request(params) end |
#login(uname, password, params = {}) ⇒ Object
cmd=login protocol_version=2.0 uname=gallery-user-name password=cleartext-password
78 79 80 81 |
# File 'lib/gallery/remote.rb', line 78 def login(uname, password, params = {}) params = { :cmd => 'login', :uname => uname, :password => password }.merge(params) send_request(params) end |
#new_album(set_albumName, params = {}) ⇒ Object
cmd=new-album protocol_version=2.1 set_albumName=parent-album-name newAlbumName=album-name [optional] newAlbumTitle=album-title [optional] newAlbumDesc=album-description [optional]
119 120 121 122 |
# File 'lib/gallery/remote.rb', line 119 def new_album(set_albumName, params = {}) params = { :cmd => 'new-album', :set_albumName => set_albumName }.merge(params) send_request(params) end |
#status_msg ⇒ Object
145 146 147 |
# File 'lib/gallery/remote.rb', line 145 def status_msg "#{@status} - (#{@status_text})" end |