mbulat-rubyprot 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +14 -0
- data/Rakefile +58 -0
- data/VERSION +1 -0
- data/lib/rubyprot.rb +97 -0
- data/lib/rubyprot/deserializer.rb +11 -0
- data/lib/rubyprot/serializer.rb +23 -0
- data/lib/rubyprot/storage.rb +48 -0
- data/rubyprot.gemspec +69 -0
- data/test/configuration_test.rb +33 -0
- data/test/deserializer_test.rb +32 -0
- data/test/serializer_test.rb +88 -0
- data/test/storage_test.rb +39 -0
- data/test/test_files/models/test_class.rb +9 -0
- data/test/test_files/models/test_class_two.rb +3 -0
- data/test/test_files/models/test_module.rb +4 -0
- data/test/test_files/test_data/TestClass +0 -0
- data/test/test_helper.rb +13 -0
- metadata +100 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Michael Bulat
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
= rubyprot
|
2
|
+
|
3
|
+
Simple library to aid in object serialization and messaging via Rubys Marshal
|
4
|
+
|
5
|
+
== An Overview
|
6
|
+
|
7
|
+
Rubyprot helps with the task of using Ruby's marshal utility to package objects into binary format for storage and messaging. Marshal's speed and simplicity make it perfect for Ruby centric applications that require disconnected object sharing.
|
8
|
+
|
9
|
+
Rubyprot currently allows for the utilization of Amazon's S3 servers for storage and retrieval of marshaled data.
|
10
|
+
|
11
|
+
|
12
|
+
== Copyright
|
13
|
+
|
14
|
+
Copyright (c) 2009 Michael Bulat. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rubyprot"
|
8
|
+
gem.summary = "Simple library to aid in object serialization and messaging via Rubys Marshal"
|
9
|
+
gem.email = "mbulat@facesmedia.com"
|
10
|
+
gem.homepage = "http://github.com/mbulat/rubyprot"
|
11
|
+
gem.authors = ["Michael Bulat"]
|
12
|
+
gem.add_dependency('aws-s3', '>= 0.5.1')
|
13
|
+
gem.add_dependency('mechanize', '>= 0.8.5')
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/*_test.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/*_test.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
task :default => :test
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
if File.exist?('VERSION.yml')
|
47
|
+
config = YAML.load(File.read('VERSION.yml'))
|
48
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
49
|
+
else
|
50
|
+
version = ""
|
51
|
+
end
|
52
|
+
|
53
|
+
rdoc.rdoc_dir = 'rdoc'
|
54
|
+
rdoc.title = "rubyprot #{version}"
|
55
|
+
rdoc.rdoc_files.include('README*')
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
+
end
|
58
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.5.0
|
data/lib/rubyprot.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# == About rubyprot.rb
|
2
|
+
#
|
3
|
+
# All of Rubyprot's various part are loaded when you use <tt>require 'rubyprot'</tt>.
|
4
|
+
#
|
5
|
+
# * rubyprot/serializer.rb: serializes objects via marshal into file
|
6
|
+
# * rubyprot/deserializer.rb: deserializes files via marshal into objects
|
7
|
+
#
|
8
|
+
# Created by Michael Bulat on 2009-07-23.
|
9
|
+
# Copyright 2009 Michael Bulat. All rights reserved.
|
10
|
+
#
|
11
|
+
require 'rubyprot/serializer'
|
12
|
+
require 'rubyprot/deserializer'
|
13
|
+
require 'rubyprot/storage'
|
14
|
+
|
15
|
+
module Rubyprot
|
16
|
+
class << self
|
17
|
+
# top level path where temporary files will be placed
|
18
|
+
attr_accessor :dump_path
|
19
|
+
# amazon s3 bucket for file storage
|
20
|
+
attr_accessor :amazon_bucket_name
|
21
|
+
# amazon access key
|
22
|
+
attr_accessor :amazon_access_key_id
|
23
|
+
# amazon secret key
|
24
|
+
attr_accessor :amazon_secret_access_key
|
25
|
+
|
26
|
+
#Allows block configuration of Rubyprot attributes
|
27
|
+
#
|
28
|
+
# Rubyprot.configure do |config|
|
29
|
+
# config.dump_path = "my_folder/my_path"
|
30
|
+
# config.amazon_bucket_name = "my_bucket"
|
31
|
+
# config.amazon_access_key_id = "my_key"
|
32
|
+
# config.amazon_secret_access_key = "my_access_key"
|
33
|
+
# end
|
34
|
+
def configure
|
35
|
+
yield self
|
36
|
+
end
|
37
|
+
|
38
|
+
# Marshals any object into a file named after the object class and stores
|
39
|
+
# the file in the folder specified by the +dump_path+ attribute.
|
40
|
+
# Returns the name of the file.
|
41
|
+
#
|
42
|
+
# >> Rubyprot.serialize(object)
|
43
|
+
# => "Object"
|
44
|
+
def serialize(object)
|
45
|
+
return Rubyprot::Serializer.serialize(object)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Unmarshals named file from the folder specified
|
49
|
+
# by the +dump_path+ attribute.
|
50
|
+
# Returns the object.
|
51
|
+
#
|
52
|
+
# >> Rubyprot.deserialize("Object")
|
53
|
+
# => #<Object:0x18a30d0>
|
54
|
+
def deserialize(name)
|
55
|
+
return Rubyprot::Deserializer.deserialize(name)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Downloads file from amazon
|
59
|
+
# using +amazon_bucket_name+, +amazon_access_key_id+, +amazon_secret_access_key+
|
60
|
+
# attributes to +dump_path+.
|
61
|
+
#
|
62
|
+
# Returns the file name for use to deserialize object
|
63
|
+
#
|
64
|
+
# Rubyprot.deserialize(Rubyprot.aws_download("path_to_data", "Object"))
|
65
|
+
def aws_download(location, name)
|
66
|
+
return Rubyprot::Storage.aws_download(location, name)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Downloads file from amazon using
|
70
|
+
# using +amazon_bucket_name+, +amazon_access_key_id+, +amazon_secret_access_key+
|
71
|
+
# to given +location+ on s3.
|
72
|
+
#
|
73
|
+
# Returns HTTP status
|
74
|
+
#
|
75
|
+
# Rubyprot.aws_upload("path_to_data", Rubyprot.serialize(conversations))
|
76
|
+
def aws_upload(location, name)
|
77
|
+
return Rubyprot::Storage.aws_upload(location, name)
|
78
|
+
end
|
79
|
+
|
80
|
+
def dump_path=(value) #:nodoc:
|
81
|
+
begin
|
82
|
+
unless value.nil?
|
83
|
+
unless File.directory?(value)
|
84
|
+
FileUtils.mkdir(value)
|
85
|
+
end
|
86
|
+
if File.directory?(value)
|
87
|
+
@dump_path = value
|
88
|
+
end
|
89
|
+
else
|
90
|
+
@dump_path = nil
|
91
|
+
end
|
92
|
+
rescue
|
93
|
+
raise "Dump path directory invalid. Please check your configuration."
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Rubyprot
|
2
|
+
class Serializer #:nodoc:
|
3
|
+
def self.serialize(object)
|
4
|
+
raise "Dump path attribute must be set" if Rubyprot.dump_path.nil?
|
5
|
+
|
6
|
+
if object.is_a?(Array) then
|
7
|
+
if object[0].class.name.rindex("s") == object[0].class.name.length - 1
|
8
|
+
plural_string = "es"
|
9
|
+
else
|
10
|
+
plural_string = "s"
|
11
|
+
end
|
12
|
+
file_name = object[0].class.name + plural_string
|
13
|
+
else
|
14
|
+
file_name = object.class.name
|
15
|
+
end
|
16
|
+
file = File.new(Rubyprot.dump_path + "/" + file_name, "w")
|
17
|
+
file.write(Marshal.dump(object))
|
18
|
+
file.close
|
19
|
+
|
20
|
+
file_name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'aws/s3'
|
2
|
+
require 'mechanize'
|
3
|
+
|
4
|
+
module Rubyprot
|
5
|
+
class Storage #:nodoc:
|
6
|
+
def self.aws_download(location, name)
|
7
|
+
raise "amazon_bucket_name attribute must be set" unless Rubyprot.amazon_bucket_name
|
8
|
+
raise "amazon_secret_access_key attribute must be set" unless Rubyprot.amazon_secret_access_key
|
9
|
+
raise "amazon_access_key_id attribute must be set" unless Rubyprot.amazon_access_key_id
|
10
|
+
|
11
|
+
AWS::S3::Base.establish_connection!(
|
12
|
+
:access_key_id => Rubyprot.amazon_access_key_id,
|
13
|
+
:secret_access_key => Rubyprot.amazon_secret_access_key
|
14
|
+
)
|
15
|
+
|
16
|
+
marshalled_data = AWS::S3::S3Object.find location + "/" + name, Rubyprot.amazon_bucket_name
|
17
|
+
url = URI.parse(marshalled_data.url)
|
18
|
+
|
19
|
+
agent = WWW::Mechanize.new
|
20
|
+
marshalled_file = agent.get(url)
|
21
|
+
marshalled_file.save_as(Rubyprot.dump_path + '/' + name)
|
22
|
+
|
23
|
+
name
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.aws_upload(location, name)
|
27
|
+
raise "amazon_bucket_name attribute must be set" unless Rubyprot.amazon_bucket_name
|
28
|
+
raise "amazon_secret_access_key attribute must be set" unless Rubyprot.amazon_secret_access_key
|
29
|
+
raise "amazon_access_key_id attribute must be set" unless Rubyprot.amazon_access_key_id
|
30
|
+
|
31
|
+
AWS::S3::Base.establish_connection!(
|
32
|
+
:access_key_id => Rubyprot.amazon_access_key_id,
|
33
|
+
:secret_access_key => Rubyprot.amazon_secret_access_key
|
34
|
+
)
|
35
|
+
|
36
|
+
file = File.open(Rubyprot.dump_path + "/" + name)
|
37
|
+
|
38
|
+
AWS::S3::S3Object.store(location + "/" + name,
|
39
|
+
file,
|
40
|
+
Rubyprot.amazon_bucket_name,
|
41
|
+
:cache_control => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0")
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
data/rubyprot.gemspec
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{rubyprot}
|
5
|
+
s.version = "0.5.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Michael Bulat"]
|
9
|
+
s.date = %q{2009-07-28}
|
10
|
+
s.email = %q{mbulat@facesmedia.com}
|
11
|
+
s.extra_rdoc_files = [
|
12
|
+
"LICENSE",
|
13
|
+
"README.rdoc"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".document",
|
17
|
+
".gitignore",
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"lib/rubyprot.rb",
|
23
|
+
"lib/rubyprot/deserializer.rb",
|
24
|
+
"lib/rubyprot/serializer.rb",
|
25
|
+
"lib/rubyprot/storage.rb",
|
26
|
+
"rubyprot.gemspec",
|
27
|
+
"test/configuration_test.rb",
|
28
|
+
"test/deserializer_test.rb",
|
29
|
+
"test/serializer_test.rb",
|
30
|
+
"test/storage_test.rb",
|
31
|
+
"test/test_files/models/test_class.rb",
|
32
|
+
"test/test_files/models/test_class_two.rb",
|
33
|
+
"test/test_files/models/test_module.rb",
|
34
|
+
"test/test_files/test_data/TestClass",
|
35
|
+
"test/test_helper.rb"
|
36
|
+
]
|
37
|
+
s.has_rdoc = true
|
38
|
+
s.homepage = %q{http://github.com/mbulat/rubyprot}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.1}
|
42
|
+
s.summary = %q{Simple library to aid in object serialization and messaging via Rubys Marshal}
|
43
|
+
s.test_files = [
|
44
|
+
"test/configuration_test.rb",
|
45
|
+
"test/deserializer_test.rb",
|
46
|
+
"test/serializer_test.rb",
|
47
|
+
"test/storage_test.rb",
|
48
|
+
"test/test_files/models/test_class.rb",
|
49
|
+
"test/test_files/models/test_class_two.rb",
|
50
|
+
"test/test_files/models/test_module.rb",
|
51
|
+
"test/test_helper.rb"
|
52
|
+
]
|
53
|
+
|
54
|
+
if s.respond_to? :specification_version then
|
55
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
56
|
+
s.specification_version = 2
|
57
|
+
|
58
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
59
|
+
s.add_runtime_dependency(%q<aws-s3>, [">= 0.5.1"])
|
60
|
+
s.add_runtime_dependency(%q<mechanize>, [">= 0.8.5"])
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<aws-s3>, [">= 0.5.1"])
|
63
|
+
s.add_dependency(%q<mechanize>, [">= 0.8.5"])
|
64
|
+
end
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<aws-s3>, [">= 0.5.1"])
|
67
|
+
s.add_dependency(%q<mechanize>, [">= 0.8.5"])
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ConfigurationTest < Test::Unit::TestCase
|
4
|
+
should "be done with a block" do
|
5
|
+
Rubyprot.configure do |config|
|
6
|
+
config.dump_path = "test/test_files/my_path"
|
7
|
+
config.amazon_bucket_name = "my_bucket"
|
8
|
+
config.amazon_access_key_id = "my_key"
|
9
|
+
config.amazon_secret_access_key = "my_access_key"
|
10
|
+
end
|
11
|
+
|
12
|
+
assert_equal "test/test_files/my_path", Rubyprot.dump_path
|
13
|
+
assert_equal "my_bucket", Rubyprot.amazon_bucket_name
|
14
|
+
assert_equal "my_key", Rubyprot.amazon_access_key_id
|
15
|
+
assert_equal "my_access_key", Rubyprot.amazon_secret_access_key
|
16
|
+
|
17
|
+
Rubyprot.configure do |config|
|
18
|
+
config.dump_path = nil
|
19
|
+
config.amazon_bucket_name = nil
|
20
|
+
config.amazon_access_key_id = nil
|
21
|
+
config.amazon_secret_access_key = nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
should "raise error if bad path supplied" do
|
26
|
+
assert_raise RuntimeError do
|
27
|
+
Rubyprot.configure do |config|
|
28
|
+
config.dump_path = "/this/is/a/bad/path"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DeserializerTest < Test::Unit::TestCase
|
4
|
+
context "Rubyprot deserializer" do
|
5
|
+
setup do
|
6
|
+
@test_file_path = "test/test_files/test_data"
|
7
|
+
@object_name = "TestClass"
|
8
|
+
Rubyprot.configure do |config|
|
9
|
+
Rubyprot.dump_path = @test_file_path
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
should "should unmarshal file by name into working object" do
|
15
|
+
|
16
|
+
assert_nothing_raised do
|
17
|
+
my_object = Rubyprot.deserialize(@object_name)
|
18
|
+
|
19
|
+
assert_kind_of TestClass, my_object
|
20
|
+
|
21
|
+
assert_equal my_object.test_method, 'this method returned'
|
22
|
+
assert_nothing_raised do
|
23
|
+
my_object.test_attr = 'hello world'
|
24
|
+
end
|
25
|
+
assert_equal my_object.test_attr, 'hello world'
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SerializerTest < Test::Unit::TestCase
|
4
|
+
context "Rubyprot serializer" do
|
5
|
+
setup do
|
6
|
+
@test_file_path = "test/test_files/dump"
|
7
|
+
@object_name = "TestClass"
|
8
|
+
end
|
9
|
+
|
10
|
+
teardown do
|
11
|
+
unless Rubyprot.dump_path.nil?
|
12
|
+
FileUtils.rmtree(Rubyprot.dump_path)
|
13
|
+
Rubyprot.dump_path = nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
should "raise error if dump path not set" do
|
18
|
+
assert_raise RuntimeError do
|
19
|
+
object = TestClass.new
|
20
|
+
Rubyprot.serialize(object)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
should "create marshalled file from object" do
|
25
|
+
Rubyprot.configure do |config|
|
26
|
+
Rubyprot.dump_path = @test_file_path
|
27
|
+
end
|
28
|
+
|
29
|
+
object = TestClass.new
|
30
|
+
Rubyprot.serialize(object)
|
31
|
+
|
32
|
+
assert_nothing_raised do
|
33
|
+
file = File.open(@test_file_path + "/" + @object_name)
|
34
|
+
end
|
35
|
+
|
36
|
+
FileUtils.rmtree(Rubyprot.dump_path)
|
37
|
+
end
|
38
|
+
|
39
|
+
should "have valid marshaled file" do
|
40
|
+
Rubyprot.configure do |config|
|
41
|
+
Rubyprot.dump_path = @test_file_path
|
42
|
+
end
|
43
|
+
|
44
|
+
object = TestClass.new
|
45
|
+
Rubyprot.serialize(object)
|
46
|
+
|
47
|
+
assert_nothing_raised do
|
48
|
+
file = File.open(@test_file_path + "/" + @object_name)
|
49
|
+
new_object = Marshal.load(file)
|
50
|
+
file.close
|
51
|
+
|
52
|
+
assert_equal new_object.test_method, 'this method returned'
|
53
|
+
assert_nothing_raised do
|
54
|
+
new_object.test_attr = 'hello world'
|
55
|
+
end
|
56
|
+
assert_equal new_object.test_attr, 'hello world'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
should "return a string name" do
|
61
|
+
Rubyprot.configure do |config|
|
62
|
+
Rubyprot.dump_path = @test_file_path
|
63
|
+
end
|
64
|
+
|
65
|
+
object = TestClass.new
|
66
|
+
name = Rubyprot.serialize(object)
|
67
|
+
|
68
|
+
assert_kind_of String, name
|
69
|
+
end
|
70
|
+
|
71
|
+
should "return array string name for array" do
|
72
|
+
Rubyprot.configure do |config|
|
73
|
+
Rubyprot.dump_path = @test_file_path
|
74
|
+
end
|
75
|
+
|
76
|
+
array = Array.new
|
77
|
+
object = TestClass.new
|
78
|
+
array[0] = object
|
79
|
+
array[1] = object
|
80
|
+
|
81
|
+
name = Rubyprot.serialize(array)
|
82
|
+
|
83
|
+
assert_kind_of String, name
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class StorageTest < Test::Unit::TestCase
|
4
|
+
context "Rubyprot Storage" do
|
5
|
+
setup do
|
6
|
+
@location = "marshalled_data/"
|
7
|
+
@object_name = "TestClass"
|
8
|
+
Rubyprot.configure do |config|
|
9
|
+
Rubyprot.dump_path = "test/test_files/test_data"
|
10
|
+
#change these values to run the tests
|
11
|
+
#config.amazon_bucket_name = "YOUR_BUCKET"
|
12
|
+
#config.amazon_access_key_id = "YOUR_KEY"
|
13
|
+
#config.amazon_secret_access_key = "YOUR_SECRET"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
if Rubyprot.amazon_bucket_name && Rubyprot.amazon_access_key_id && Rubyprot.amazon_secret_access_key
|
19
|
+
|
20
|
+
should "should upload file to amazon and return true" do
|
21
|
+
assert_nothing_raised do
|
22
|
+
assert Rubyprot.aws_upload(@location, @object_name)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
should "should load file from amazon" do
|
27
|
+
assert_nothing_raised do
|
28
|
+
assert Rubyprot.aws_download(@location, @object_name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
else
|
33
|
+
should "skip tests" do
|
34
|
+
assert true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
Binary file
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
require 'rubyprot'
|
8
|
+
require 'test_files/models/test_class'
|
9
|
+
require 'test_files/models/test_class_two'
|
10
|
+
require 'test_files/models/test_module'
|
11
|
+
|
12
|
+
class Test::Unit::TestCase
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mbulat-rubyprot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Bulat
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-28 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: aws-s3
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.5.1
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mechanize
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.8.5
|
34
|
+
version:
|
35
|
+
description:
|
36
|
+
email: mbulat@facesmedia.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- lib/rubyprot.rb
|
52
|
+
- lib/rubyprot/deserializer.rb
|
53
|
+
- lib/rubyprot/serializer.rb
|
54
|
+
- lib/rubyprot/storage.rb
|
55
|
+
- rubyprot.gemspec
|
56
|
+
- test/configuration_test.rb
|
57
|
+
- test/deserializer_test.rb
|
58
|
+
- test/serializer_test.rb
|
59
|
+
- test/storage_test.rb
|
60
|
+
- test/test_files/models/test_class.rb
|
61
|
+
- test/test_files/models/test_class_two.rb
|
62
|
+
- test/test_files/models/test_module.rb
|
63
|
+
- test/test_files/test_data/TestClass
|
64
|
+
- test/test_helper.rb
|
65
|
+
has_rdoc: true
|
66
|
+
homepage: http://github.com/mbulat/rubyprot
|
67
|
+
licenses:
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options:
|
70
|
+
- --charset=UTF-8
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
version:
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: "0"
|
84
|
+
version:
|
85
|
+
requirements: []
|
86
|
+
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.3.5
|
89
|
+
signing_key:
|
90
|
+
specification_version: 2
|
91
|
+
summary: Simple library to aid in object serialization and messaging via Rubys Marshal
|
92
|
+
test_files:
|
93
|
+
- test/configuration_test.rb
|
94
|
+
- test/deserializer_test.rb
|
95
|
+
- test/serializer_test.rb
|
96
|
+
- test/storage_test.rb
|
97
|
+
- test/test_files/models/test_class.rb
|
98
|
+
- test/test_files/models/test_class_two.rb
|
99
|
+
- test/test_files/models/test_module.rb
|
100
|
+
- test/test_helper.rb
|