rpbertp13-dm-s3 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.rdoc +71 -1
  2. data/Rakefile +1 -1
  3. data/VERSION.yml +1 -1
  4. data/dm-s3.gemspec +2 -2
  5. metadata +2 -2
data/README.rdoc CHANGED
@@ -1,6 +1,76 @@
1
1
  = dm-s3
2
2
 
3
- Description goes here.
3
+ Very often we want to store a file in s3 and keep a record of it in our database.
4
+
5
+ == Setting
6
+
7
+ If you have a model class that will have s3 objects living in different buckets do
8
+
9
+ property :s3_key, String
10
+ property :s3_bucket, String
11
+
12
+ has_s3_file
13
+
14
+ and define a method to save your resource and your s3 object
15
+
16
+ def self.create!(key, bucket, file, options)
17
+ object = self.new :s3_key => key, :s3_bucket => bucket
18
+ object.save if object.store_with(file, options)
19
+ end
20
+
21
+ If all the s3 objects will live in the same bucket then do
22
+
23
+ property :s3_key, String
24
+
25
+ has_s3_file_at 'my-bucket-name'
26
+
27
+ The save method will reflect the difference
28
+
29
+ def self.create!(key, file, options)
30
+ object = self.new :s3_key => key
31
+ object.save if object.store_with(file, options)
32
+ end
33
+
34
+ You can directly access the bucket object associated with this model too
35
+
36
+ MyModel.bucket
37
+
38
+ == Getting
39
+
40
+ To retrieve data from s3 simply pull the datamapper object, e.g.
41
+
42
+ object = MyModel.first
43
+
44
+ Doing
45
+
46
+ object.s3
47
+
48
+ Will give you the s3 object. So you can do things like
49
+
50
+ object.s3.value
51
+ object.s3.url
52
+ object.s3.about
53
+
54
+ etc.
55
+
56
+ For convenience, the methods 'value', 'metadata', 'about' and 'url' get bound to the datamapper object directly so the following is valid
57
+
58
+ object.value
59
+ object.metadata
60
+ object.about
61
+ object.url
62
+
63
+ Make sure these don't conflict with your properties.
64
+
65
+ == Gotchas
66
+
67
+ * The gem assumes that you will call
68
+
69
+ AWS::S3::Base.establish_connection!
70
+
71
+ with the appropriate credentials some time before you create or access your s3 enabled models
72
+
73
+ * The gem won't create buckets for you. Make sure the buckets exist before attempting to use them.
4
74
 
5
75
  == Copyright
6
76
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "dm-s3"
8
- gem.summary = %Q{TODO}
8
+ gem.summary = "A simple gem that makes it easy to associate datamapper objects with s3 objects "
9
9
  gem.email = "roberto.n.thais@gmail.com"
10
10
  gem.homepage = "http://github.com/rpbertp13/dm-s3"
11
11
  gem.authors = ["Roberto Thais"]
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 0
4
+ :patch: 2
data/dm-s3.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{dm-s3}
5
- s.version = "0.1.0"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Roberto Thais"]
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.rdoc_options = ["--charset=UTF-8"]
29
29
  s.require_paths = ["lib"]
30
30
  s.rubygems_version = %q{1.3.4}
31
- s.summary = %q{TODO}
31
+ s.summary = %q{A simple gem that makes it easy to associate datamapper objects with s3 objects}
32
32
  s.test_files = [
33
33
  "test/dm-s3_test.rb",
34
34
  "test/test_helper.rb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpbertp13-dm-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Thais
@@ -77,7 +77,7 @@ rubyforge_project:
77
77
  rubygems_version: 1.2.0
78
78
  signing_key:
79
79
  specification_version: 3
80
- summary: TODO
80
+ summary: A simple gem that makes it easy to associate datamapper objects with s3 objects
81
81
  test_files:
82
82
  - test/dm-s3_test.rb
83
83
  - test/test_helper.rb