Module: Rubyprot

Defined in:
lib/rubyprot.rb,
lib/rubyprot/storage.rb,
lib/rubyprot/serializer.rb,
lib/rubyprot/deserializer.rb

Defined Under Namespace

Classes: Deserializer, Serializer, Storage

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.amazon_access_key_idObject

amazon access key



22
23
24
# File 'lib/rubyprot.rb', line 22

def amazon_access_key_id
  @amazon_access_key_id
end

.amazon_bucket_nameObject

amazon s3 bucket for file storage



20
21
22
# File 'lib/rubyprot.rb', line 20

def amazon_bucket_name
  @amazon_bucket_name
end

.amazon_secret_access_keyObject

amazon secret key



24
25
26
# File 'lib/rubyprot.rb', line 24

def amazon_secret_access_key
  @amazon_secret_access_key
end

.dump_pathObject

top level path where temporary files will be placed



18
19
20
# File 'lib/rubyprot.rb', line 18

def dump_path
  @dump_path
end

Class Method Details

.aws_download(location, name) ⇒ Object

Downloads file from amazon using amazon_bucket_name, amazon_access_key_id, amazon_secret_access_key attributes to dump_path.

Returns the file name for use to deserialize object

Rubyprot.deserialize(Rubyprot.aws_download("path_to_data", "Object"))


65
66
67
# File 'lib/rubyprot.rb', line 65

def aws_download(location, name)
  return Rubyprot::Storage.aws_download(location, name)
end

.aws_upload(location, name) ⇒ Object

Downloads file from amazon using using amazon_bucket_name, amazon_access_key_id, amazon_secret_access_key to given location on s3.

Returns HTTP status

Rubyprot.aws_upload("path_to_data", Rubyprot.serialize(conversations))


76
77
78
# File 'lib/rubyprot.rb', line 76

def aws_upload(location, name)
  return Rubyprot::Storage.aws_upload(location, name)
end

.configure {|_self| ... } ⇒ Object

Allows block configuration of Rubyprot attributes

Rubyprot.configure do |config|
  config.dump_path = "my_folder/my_path"
  config.amazon_bucket_name = "my_bucket"
  config.amazon_access_key_id = "my_key"
  config.amazon_secret_access_key = "my_access_key"
end

Yields:

  • (_self)

Yield Parameters:

  • _self (Rubyprot)

    the object that the method was called on



34
35
36
# File 'lib/rubyprot.rb', line 34

def configure
  yield self
end

.deserialize(name) ⇒ Object

Unmarshals named file from the folder specified by the dump_path attribute. Returns the object.

>> Rubyprot.deserialize("Object")
=> #<Object:0x18a30d0>


54
55
56
# File 'lib/rubyprot.rb', line 54

def deserialize(name)
  return Rubyprot::Deserializer.deserialize(name)
end

.serialize(object) ⇒ Object

Marshals any object into a file named after the object class and stores the file in the folder specified by the dump_path attribute. Returns the name of the file.

>> Rubyprot.serialize(object)
=> "Object"


44
45
46
# File 'lib/rubyprot.rb', line 44

def serialize(object)
  return Rubyprot::Serializer.serialize(object)
end