dragonfly-activerecord 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71dee4838386007ab3187a967c5358452dcea848
4
- data.tar.gz: d754f01bb97796d20bebccec6f29ec38e52ae077
3
+ metadata.gz: 804ea5bfdd90237f08a7c477f0b0019e040648c8
4
+ data.tar.gz: 3ef8c72e9b1aea1e513400751f39369acf91647c
5
5
  SHA512:
6
- metadata.gz: 3160ed764fa8ccd08566c18b762b83a4a6166f54684ca82259ed01324a23f7f82d5566117f21bb03d621a4ea90742e1168f0560256c0bafcdda493e1f4f7545e
7
- data.tar.gz: bb021fb1742c9270608b91b8b7a178b4bda4df1ced7371a74899db468db033e7c2eb22059512636725b91d446d9999ec46c5c3fef991068ee443dfa55adc42c4
6
+ metadata.gz: 04dcc1651721230e8d937252fc08045f2b4e16afaf5359ff82408da7ac313a532f8ee9b18785ffe9b74d52414fe58594b5af2d0d88f4d7f425aea9c89a741b3b
7
+ data.tar.gz: 4cb3cd91cce1c350174cee6d4b91836d673ad33ece38f107884df2cc04651a4c77e073d119f02f74be912dad601ad4759ab5d3726a6400e2d4afd36bb56af519
data/.gitignore CHANGED
@@ -1,17 +1,5 @@
1
- *.gem
2
- *.rbc
3
1
  .bundle
4
2
  .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
3
  coverage
10
- doc/
11
- lib/bundler/man
12
4
  pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
5
  tmp
data/Gemfile.lock ADDED
@@ -0,0 +1,94 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dragonfly-activerecord (0.0.2)
5
+ activerecord (>= 3.2.6)
6
+
7
+ GEM
8
+ remote: http://yarp.dev/
9
+ specs:
10
+ activemodel (4.0.2)
11
+ activesupport (= 4.0.2)
12
+ builder (~> 3.1.0)
13
+ activerecord (4.0.2)
14
+ activemodel (= 4.0.2)
15
+ activerecord-deprecated_finders (~> 1.0.2)
16
+ activesupport (= 4.0.2)
17
+ arel (~> 4.0.0)
18
+ activerecord-deprecated_finders (1.0.3)
19
+ activesupport (4.0.2)
20
+ i18n (~> 0.6, >= 0.6.4)
21
+ minitest (~> 4.2)
22
+ multi_json (~> 1.3)
23
+ thread_safe (~> 0.1)
24
+ tzinfo (~> 0.3.37)
25
+ appraisal (0.5.2)
26
+ bundler
27
+ rake
28
+ arel (4.0.1)
29
+ atomic (1.1.14)
30
+ builder (3.1.4)
31
+ celluloid (0.15.2)
32
+ timers (~> 1.1.0)
33
+ coderay (1.1.0)
34
+ diff-lcs (1.2.5)
35
+ ffi (1.9.3)
36
+ formatador (0.2.4)
37
+ guard (2.2.5)
38
+ formatador (>= 0.2.4)
39
+ listen (~> 2.1)
40
+ lumberjack (~> 1.0)
41
+ pry (>= 0.9.12)
42
+ thor (>= 0.18.1)
43
+ guard-rspec (4.2.3)
44
+ guard (~> 2.1)
45
+ rspec (>= 2.14, < 4.0)
46
+ i18n (0.6.9)
47
+ listen (2.4.0)
48
+ celluloid (>= 0.15.2)
49
+ rb-fsevent (>= 0.9.3)
50
+ rb-inotify (>= 0.9)
51
+ lumberjack (1.0.4)
52
+ method_source (0.8.2)
53
+ minitest (4.7.5)
54
+ multi_json (1.8.2)
55
+ mysql2 (0.3.14)
56
+ pg (0.17.1)
57
+ pry (0.9.12.4)
58
+ coderay (~> 1.0)
59
+ method_source (~> 0.8)
60
+ slop (~> 3.4)
61
+ rake (10.1.1)
62
+ rb-fsevent (0.9.4)
63
+ rb-inotify (0.9.3)
64
+ ffi (>= 0.5.0)
65
+ rspec (2.14.1)
66
+ rspec-core (~> 2.14.0)
67
+ rspec-expectations (~> 2.14.0)
68
+ rspec-mocks (~> 2.14.0)
69
+ rspec-core (2.14.7)
70
+ rspec-expectations (2.14.4)
71
+ diff-lcs (>= 1.1.3, < 2.0)
72
+ rspec-mocks (2.14.4)
73
+ slop (3.4.7)
74
+ sqlite3 (1.3.8)
75
+ thor (0.18.1)
76
+ thread_safe (0.1.3)
77
+ atomic
78
+ timers (1.1.0)
79
+ tzinfo (0.3.38)
80
+
81
+ PLATFORMS
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ appraisal
86
+ bundler (~> 1.3)
87
+ dragonfly-activerecord!
88
+ guard
89
+ guard-rspec
90
+ mysql2
91
+ pg
92
+ rake
93
+ rspec
94
+ sqlite3
data/README.md CHANGED
@@ -10,16 +10,18 @@ backed by ActiveRecord.
10
10
 
11
11
  Requires a Rails application using Dragonfly 1.0+.
12
12
 
13
+ Tested with MRI 1.9.3, 2.0, 2.1; ActiveRecord 3.2 and 4.0; and MySQL,
14
+ PostgreSQL, and SQLite stores.
13
15
 
14
- ## Why?
16
+ ## Use case
15
17
 
16
- Because there's a fat chance our app already has a database. Why bother with S3
17
- when your DB can do the job just fine?
18
-
19
- Yes, storing files in a relational database may be a bad idea at scale, but for
20
- many use cases (up to a few gigabytes of storage) it really eases the
21
- maintenance burden.
18
+ If your app's dynamic assets (user uploaded images for instance) weigh up to a
19
+ few gigabytes, it can make sense to store them in the app's database instead of
20
+ another service (e.g. Amazon's S3): your stack has one less dependency to care
21
+ about, and backups get more complicated.
22
22
 
23
+ `dragonfly-activerecord`, lets you store assets to your app's relational
24
+ database.
23
25
 
24
26
  ## Installation
25
27
 
@@ -7,20 +7,20 @@ module Dragonfly::ActiveRecord
7
7
 
8
8
  # +temp_object+ should respond to +data+ and +meta+
9
9
  def write(temp_object, opts={})
10
- File.transaction do
11
- file = File.create!(metadata: temp_object.meta)
12
- file.data = temp_object.data
10
+ File.new.tap do |file|
11
+ file.metadata = temp_object.meta
12
+ file.data = temp_object.data
13
13
  file.save!
14
14
  return file.id.to_s
15
15
  end
16
16
  end
17
17
 
18
18
  def read(uid)
19
- file = File.find(uid.to_i)
20
- file.update_attributes!(accessed_at: Time.now)
19
+ file = File.where(id: uid.to_i).first
20
+ return nil if file.nil?
21
+
22
+ file.update_column(:accessed_at, Time.now)
21
23
  [ file.data, file.metadata ]
22
- rescue ActiveRecord::RecordNotFound
23
- nil
24
24
  end
25
25
 
26
26
  def destroy(uid)
@@ -1,5 +1,5 @@
1
1
  module Dragonfly
2
2
  module ActiveRecord
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-02 00:00:00.000000000 Z
11
+ date: 2014-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,7 @@ files:
163
163
  - .travis.yml
164
164
  - Appraisals
165
165
  - Gemfile
166
+ - Gemfile.lock
166
167
  - Guardfile
167
168
  - LICENSE.txt
168
169
  - README.md