joint 0.5.5 → 0.6.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/Gemfile +7 -4
- data/Gemfile.lock +24 -21
- data/joint.gemspec +1 -5
- data/lib/joint.rb +6 -4
- data/lib/joint/attachment_proxy.rb +1 -0
- data/lib/joint/class_methods.rb +1 -1
- data/lib/joint/instance_methods.rb +1 -1
- data/lib/joint/io.rb +11 -2
- data/lib/joint/version.rb +1 -1
- data/test/helper.rb +6 -1
- data/test/test_joint.rb +12 -0
- metadata +11 -55
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,32 +1,39 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
joint (0.
|
4
|
+
joint (0.6.0)
|
5
5
|
mime-types
|
6
|
-
mongo_mapper (~> 0.
|
6
|
+
mongo_mapper (~> 0.9.0)
|
7
7
|
wand (~> 0.4)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
activemodel (3.1.0)
|
13
|
+
activesupport (= 3.1.0)
|
14
|
+
bcrypt-ruby (~> 3.0.0)
|
15
|
+
builder (~> 3.0.0)
|
16
|
+
i18n (~> 0.6)
|
17
|
+
activesupport (3.1.0)
|
18
|
+
multi_json (~> 1.0)
|
19
|
+
bcrypt-ruby (3.0.1)
|
20
|
+
bson (1.3.1)
|
21
|
+
bson_ext (1.3.1)
|
22
|
+
builder (3.0.0)
|
23
|
+
i18n (0.6.0)
|
16
24
|
jnunemaker-matchy (0.4.0)
|
17
|
-
jnunemaker-validatable (1.8.4)
|
18
|
-
activesupport (>= 2.3.4)
|
19
25
|
mime-types (1.16)
|
20
26
|
mocha (0.9.10)
|
21
27
|
rake
|
22
|
-
mongo (1.1
|
23
|
-
bson (>= 1.1
|
24
|
-
mongo_mapper (0.
|
25
|
-
|
26
|
-
|
27
|
-
plucky (~> 0.3.
|
28
|
-
|
29
|
-
|
28
|
+
mongo (1.3.1)
|
29
|
+
bson (>= 1.3.1)
|
30
|
+
mongo_mapper (0.9.2)
|
31
|
+
activemodel (~> 3.0)
|
32
|
+
activesupport (~> 3.0)
|
33
|
+
plucky (~> 0.3.8)
|
34
|
+
multi_json (1.0.2)
|
35
|
+
plucky (0.3.8)
|
36
|
+
mongo (~> 1.3)
|
30
37
|
rake (0.8.7)
|
31
38
|
safe_shell (1.0.0)
|
32
39
|
shoulda (2.11.3)
|
@@ -38,12 +45,8 @@ PLATFORMS
|
|
38
45
|
ruby
|
39
46
|
|
40
47
|
DEPENDENCIES
|
41
|
-
bson_ext
|
42
|
-
i18n (= 0.4.2)
|
48
|
+
bson_ext
|
43
49
|
jnunemaker-matchy
|
44
50
|
joint!
|
45
|
-
mime-types
|
46
51
|
mocha
|
47
|
-
mongo_mapper (~> 0.8.6)
|
48
52
|
shoulda
|
49
|
-
wand (~> 0.4)
|
data/joint.gemspec
CHANGED
@@ -12,11 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.add_dependency 'wand', '~> 0.4'
|
14
14
|
s.add_dependency 'mime-types'
|
15
|
-
s.add_dependency 'mongo_mapper', '~> 0.
|
16
|
-
|
17
|
-
s.add_development_dependency 'shoulda'
|
18
|
-
s.add_development_dependency 'mocha'
|
19
|
-
s.add_development_dependency 'jnunemaker-matchy'
|
15
|
+
s.add_dependency 'mongo_mapper', '~> 0.9.0'
|
20
16
|
|
21
17
|
s.files = `git ls-files`.split("\n")
|
22
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/joint.rb
CHANGED
@@ -3,10 +3,12 @@ require 'mime/types'
|
|
3
3
|
require 'wand'
|
4
4
|
|
5
5
|
module Joint
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
class_attribute :attachment_names
|
10
|
+
self.attachment_names = Set.new
|
11
|
+
include attachment_accessor_module
|
10
12
|
end
|
11
13
|
|
12
14
|
def self.name(file)
|
data/lib/joint/class_methods.rb
CHANGED
data/lib/joint/io.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
|
1
3
|
module Joint
|
2
4
|
class IO
|
3
5
|
attr_accessor :name, :content, :type, :size
|
@@ -5,10 +7,17 @@ module Joint
|
|
5
7
|
def initialize(attrs={})
|
6
8
|
attrs.each { |key, value| send("#{key}=", value) }
|
7
9
|
@type ||= 'plain/text'
|
8
|
-
|
10
|
+
end
|
11
|
+
|
12
|
+
def content=(value)
|
13
|
+
@io = StringIO.new(value || nil)
|
14
|
+
@size = value ? value.size : 0
|
15
|
+
end
|
16
|
+
|
17
|
+
def read(*args)
|
18
|
+
@io.read(*args)
|
9
19
|
end
|
10
20
|
|
11
21
|
alias path name
|
12
|
-
alias read content
|
13
22
|
end
|
14
23
|
end
|
data/lib/joint/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.setup(:default, 'test', 'development')
|
3
|
+
|
1
4
|
require 'tempfile'
|
2
5
|
require 'pp'
|
3
6
|
require 'shoulda'
|
@@ -67,7 +70,9 @@ module JointTestHelpers
|
|
67
70
|
end
|
68
71
|
|
69
72
|
def open_file(name)
|
70
|
-
File.open(File.join(File.dirname(__FILE__), 'fixtures', name), 'r')
|
73
|
+
f = File.open(File.join(File.dirname(__FILE__), 'fixtures', name), 'r')
|
74
|
+
f.binmode
|
75
|
+
f
|
71
76
|
end
|
72
77
|
|
73
78
|
def grid
|
data/test/test_joint.rb
CHANGED
@@ -158,6 +158,11 @@ class JointTest < Test::Unit::TestCase
|
|
158
158
|
subject.file.nil?.should be(false)
|
159
159
|
end
|
160
160
|
|
161
|
+
should "respond with false when asked if the attachment is blank?" do
|
162
|
+
subject.image.blank?.should be(false)
|
163
|
+
subject.file.blank?.should be(false)
|
164
|
+
end
|
165
|
+
|
161
166
|
should "clear assigned attachments so they don't get uploaded twice" do
|
162
167
|
Mongo::Grid.any_instance.expects(:put).never
|
163
168
|
subject.save
|
@@ -247,6 +252,11 @@ class JointTest < Test::Unit::TestCase
|
|
247
252
|
subject.image.nil?.should be(true)
|
248
253
|
end
|
249
254
|
|
255
|
+
should "respond with true when asked if the attachment is blank?" do
|
256
|
+
subject.image = nil
|
257
|
+
subject.image.blank?.should be(true)
|
258
|
+
end
|
259
|
+
|
250
260
|
should "clear nil attachments after save and not attempt to delete again" do
|
251
261
|
Mongo::Grid.any_instance.expects(:delete).once
|
252
262
|
subject.image = nil
|
@@ -323,6 +333,8 @@ class JointTest < Test::Unit::TestCase
|
|
323
333
|
include MongoMapper::Document
|
324
334
|
plugin Joint
|
325
335
|
attachment :file, :required => true
|
336
|
+
|
337
|
+
def self.name; "Foo"; end
|
326
338
|
end
|
327
339
|
end
|
328
340
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 7
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Nunemaker
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-09-14 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: wand
|
@@ -55,56 +54,14 @@ dependencies:
|
|
55
54
|
requirements:
|
56
55
|
- - ~>
|
57
56
|
- !ruby/object:Gem::Version
|
58
|
-
hash:
|
57
|
+
hash: 59
|
59
58
|
segments:
|
60
59
|
- 0
|
61
|
-
-
|
62
|
-
-
|
63
|
-
version: 0.
|
60
|
+
- 9
|
61
|
+
- 0
|
62
|
+
version: 0.9.0
|
64
63
|
type: :runtime
|
65
64
|
version_requirements: *id003
|
66
|
-
- !ruby/object:Gem::Dependency
|
67
|
-
name: shoulda
|
68
|
-
prerelease: false
|
69
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
|
-
requirements:
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
hash: 3
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
version: "0"
|
78
|
-
type: :development
|
79
|
-
version_requirements: *id004
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: mocha
|
82
|
-
prerelease: false
|
83
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
|
-
requirements:
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
hash: 3
|
89
|
-
segments:
|
90
|
-
- 0
|
91
|
-
version: "0"
|
92
|
-
type: :development
|
93
|
-
version_requirements: *id005
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: jnunemaker-matchy
|
96
|
-
prerelease: false
|
97
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
|
-
requirements:
|
100
|
-
- - ">="
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
hash: 3
|
103
|
-
segments:
|
104
|
-
- 0
|
105
|
-
version: "0"
|
106
|
-
type: :development
|
107
|
-
version_requirements: *id006
|
108
65
|
description: MongoMapper and GridFS joined in file upload love.
|
109
66
|
email: nunemaker@gmail.com
|
110
67
|
executables: []
|
@@ -138,7 +95,6 @@ files:
|
|
138
95
|
- test/helper.rb
|
139
96
|
- test/joint/test_io.rb
|
140
97
|
- test/test_joint.rb
|
141
|
-
has_rdoc: true
|
142
98
|
homepage: http://github.com/jnunemaker/joint
|
143
99
|
licenses: []
|
144
100
|
|
@@ -168,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
124
|
requirements: []
|
169
125
|
|
170
126
|
rubyforge_project:
|
171
|
-
rubygems_version: 1.
|
127
|
+
rubygems_version: 1.8.9
|
172
128
|
signing_key:
|
173
129
|
specification_version: 3
|
174
130
|
summary: MongoMapper and GridFS joined in file upload love.
|