attachie 1.1.2 → 1.2.0

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
  SHA256:
3
- metadata.gz: 1e46dfdb8f2b5d9b94594ca38b5d72b3164a7659ce165f6e5f328ee72275ee5a
4
- data.tar.gz: d88df51754ce79dc3f716b0e5ccbd7fc4853bde2b92dbf75a85bc65dbb5b83ae
3
+ metadata.gz: 2eb19de73f237ed0298861ef6b69bd4fdb0ca87b6fb4e30fdd26a3e594f25954
4
+ data.tar.gz: 3b2f115036c310943864d0732d369f9e796c784aa125a23ec85136c1e0956fdc
5
5
  SHA512:
6
- metadata.gz: 8f92ec31c86801736cdc8cd6c2cd7265ed6054d48e796d3961c00490b1e8a79cdfaeefddc4746c2d3d714e0659f95ab0e1873331b3d6835acf0eaf47ed9dca4f
7
- data.tar.gz: 2495f460854161a8e241c67babb8bd7eb72bf63bbaabd04b867a195e106207e6fbd5701c687acf8909bac241adecc25e32e571660d904ccebc32b3edd287d327
6
+ metadata.gz: 3094cc9dbf755c8c942ee0e8903a99e364180415f16b7fb69e959d01d8f4c34110722f77acc5f2585e5686b58c0a9553505a7843fd7bbe244ef2cc68cbfc861d
7
+ data.tar.gz: a976071b69c6a5429d53dc9b3f7427ab1fd3a2f5df665058f2325ae873478b3eb86a86aff71d24bdcd5c4b03cf6439f4954291f0496106f6483200cf3fd948ec
@@ -5,7 +5,7 @@ jobs:
5
5
  runs-on: ubuntu-latest
6
6
  strategy:
7
7
  matrix:
8
- ruby: ['2.5', '2.6', '2.7']
8
+ ruby: ['2.6', '2.7', '3.0']
9
9
  services:
10
10
  fake-s3:
11
11
  image: lphoward/fake-s3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.2.0
4
+ ### Added
5
+ * Return proper `last_modified` in `FakeDriver#info`
6
+
3
7
  ## 1.1.2
4
8
  ### Fixed
5
9
  * Make `FakeDriver` thread-safe
data/attachie.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rake"
28
28
  spec.add_development_dependency "rspec"
29
29
  spec.add_development_dependency "fakes3"
30
+ spec.add_development_dependency "timecop"
30
31
  end
@@ -49,8 +49,8 @@ module Attachie
49
49
  def info(name, bucket)
50
50
  synchronize do
51
51
  {
52
- last_modified: nil,
53
- content_length: objects(bucket)[name].size,
52
+ last_modified: objects(bucket)[name][:last_modified],
53
+ content_length: objects(bucket)[name][:data].size,
54
54
  content_type: MIME::Types.of(name).first&.to_s
55
55
  }
56
56
  end
@@ -62,13 +62,13 @@ module Attachie
62
62
 
63
63
  def store(name, data_or_io, bucket, options = {})
64
64
  synchronize do
65
- objects(bucket)[name] = data_or_io.respond_to?(:read) ? data_or_io.read : data_or_io
65
+ objects(bucket)[name] = { data: data_or_io.respond_to?(:read) ? data_or_io.read : data_or_io, last_modified: Time.now.utc }
66
66
  end
67
67
  end
68
68
 
69
69
  def store_multipart(name, bucket, options = {}, &block)
70
70
  synchronize do
71
- objects(bucket)[name] = FakeMultipartUpload.new(name, bucket, options, &block).data
71
+ objects(bucket)[name] = { data: FakeMultipartUpload.new(name, bucket, options, &block).data, last_modified: Time.now.utc }
72
72
  end
73
73
  end
74
74
 
@@ -86,9 +86,9 @@ module Attachie
86
86
 
87
87
  def value(name, bucket)
88
88
  synchronize do
89
- raise(ItemNotFound) unless objects(bucket).key?(name)
89
+ raise(ItemNotFound, "Object #{ name } does not exist in bucket #{ bucket }") unless objects(bucket).key?(name)
90
90
 
91
- objects(bucket)[name]
91
+ objects(bucket)[name][:data]
92
92
  end
93
93
  end
94
94
 
@@ -1,3 +1,3 @@
1
1
  module Attachie
2
- VERSION = "1.1.2"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -85,12 +85,16 @@ RSpec.describe Attachie::FakeDriver do
85
85
 
86
86
  describe "#info" do
87
87
  it "returns info about the object" do
88
- driver.store("name.txt", "blob", "bucket")
88
+ timestamp = Time.now.utc
89
+
90
+ Timecop.freeze timestamp do
91
+ driver.store("name.txt", "blob", "bucket")
92
+ end
89
93
 
90
94
  expect(driver.info("name.txt", "bucket")).to eq(
91
95
  content_length: 4,
92
96
  content_type: "text/plain",
93
- last_modified: nil
97
+ last_modified: timestamp
94
98
  )
95
99
  end
96
100
  end
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ require File.expand_path("../../lib/attachie", __FILE__)
4
4
  require "attachie/file_driver"
5
5
  require "attachie/fake_driver"
6
6
  require "attachie/s3_driver"
7
+ require "timecop"
7
8
 
8
9
  class Product
9
10
  include Attachie
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attachie
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Vetter
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-04 00:00:00.000000000 Z
11
+ date: 2022-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: timecop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: Declarative and flexible attachments
126
140
  email:
127
141
  - vetter@plainpicture.de
@@ -154,7 +168,7 @@ homepage: ''
154
168
  licenses:
155
169
  - MIT
156
170
  metadata: {}
157
- post_install_message:
171
+ post_install_message:
158
172
  rdoc_options: []
159
173
  require_paths:
160
174
  - lib
@@ -169,8 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
183
  - !ruby/object:Gem::Version
170
184
  version: '0'
171
185
  requirements: []
172
- rubygems_version: 3.0.3
173
- signing_key:
186
+ rubygems_version: 3.3.3
187
+ signing_key:
174
188
  specification_version: 4
175
189
  summary: Declarative and flexible attachments
176
190
  test_files: