paperclip-location 0.0.7 → 0.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d83cfb902c31a155ba56326a8452faba62e1628
4
- data.tar.gz: 7767686c871797fd35b2ad4901162e0dc74ac4f9
3
+ metadata.gz: 61cc4a113b560c024732791abaa7d44bc88e1620
4
+ data.tar.gz: dd9c3f54cd407c18e91e7fe5a7538b86299da7ee
5
5
  SHA512:
6
- metadata.gz: f1afc944888f33116265fbfc6492ec7d14ee5585c9b1262ea7fb2d2b4ad876779909d7469ec1234ebac1f099da4bf708acbe5bc7576ea5697723c50b5e887d62
7
- data.tar.gz: f9b3b0ba67b8e1ed87b2b3561d791f9e2d1f6fafec06ccce14138ea9a86f8e305cea924bfe283b6806dcb634db6d0fdea5ccc83f490a1ef3049852448a353eb3
6
+ metadata.gz: 87b9448cfbd7e7dfa5f60a7c79d6495e93d28bf87ea04ce322847548e52c51f6823f131a92a3ab1d0bdc6f61308f764688fa9b855550375b011addcc1e9e3e43
7
+ data.tar.gz: ee1c932e25568a1463703056758fa6174eff4307c1a2a61e2ad852bbf93c5cb2e91f0b53e734c943ca8883734e6c36eb8b2eaf4b95d2d1264a431c58c70a45fc
@@ -4,7 +4,7 @@ require 'paperclip'
4
4
  module Paperclip::Location
5
5
  class Processor < Paperclip::Processor
6
6
  delegate :instance, to: :attachment, allow_nil: true
7
- delegate :gps, to: :exif
7
+ delegate :gps, to: :exif, allow_nil: true
8
8
 
9
9
  def self.register!(name = :location)
10
10
  Paperclip.configure do |c|
@@ -27,11 +27,13 @@ module Paperclip::Location
27
27
  end
28
28
 
29
29
  def can_process?
30
- !location_locked? && gps.present? && instance.present?
30
+ !location_locked? && gps.present? && instance.present? && exif.present?
31
31
  end
32
32
 
33
33
  def exif
34
34
  @exif ||= EXIFR::JPEG.new(file.path)
35
+ rescue EXIFR::MalformedJPEG => ex
36
+ nil
35
37
  end
36
38
  end
37
39
  end
@@ -3,24 +3,24 @@ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "paperclip-location"
7
- spec.version = "0.0.7"
8
- spec.authors = ["Sean Doyle"]
9
- spec.email = ["sean.p.doyle24@gmail.com"]
6
+ spec.name = 'paperclip-location'
7
+ spec.version = '0.0.8'
8
+ spec.authors = ['Sean Doyle']
9
+ spec.email = ['sean.p.doyle24@gmail.com']
10
10
  spec.description = %q{extract geolocation during Paperclip processing}
11
11
  spec.summary = %q{extract geolocation EXIF data during Paperclip processing}
12
- spec.homepage = "https://github.com/seanpdoyle/paperclip-location"
13
- spec.license = "MIT"
12
+ spec.homepage = 'https://github.com/seanpdoyle/paperclip-location'
13
+ spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files`.split($/)
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
18
+ spec.require_paths = ['lib']
19
19
 
20
- spec.add_development_dependency "bundler", "~> 1.3"
21
- spec.add_development_dependency "rake", "~> 10.1"
22
- spec.add_development_dependency "rspec", "~> 2.14"
20
+ spec.add_development_dependency 'bundler', '~> 1.3'
21
+ spec.add_development_dependency 'rake', '~> 10.1'
22
+ spec.add_development_dependency 'rspec', '~> 2.14'
23
23
 
24
- spec.add_dependency "paperclip", ">= 3.5"
25
- spec.add_dependency "exifr", "~> 1.1"
24
+ spec.add_dependency 'paperclip', '>= 3.5'
25
+ spec.add_dependency 'exifr', '~> 1.1'
26
26
  end
@@ -23,7 +23,7 @@ describe Paperclip::Location::Processor, '#make' do
23
23
 
24
24
  context "when the model's location is locked" do
25
25
  let(:file){ File.new(Photos::WITH_EXIF.path) }
26
-
26
+
27
27
  before do
28
28
  expect(model).to receive(:location_locked?) { true }
29
29
  end
@@ -66,5 +66,17 @@ describe Paperclip::Location::Processor, '#make' do
66
66
  does_nothing(model)
67
67
  end
68
68
  end
69
+
70
+ context 'given an invalid file' do
71
+ let(:file){ File.new(Photos::INVALID.path) }
72
+
73
+ after do
74
+ subject.make
75
+ end
76
+
77
+ it 'does not modify the Attachment model' do
78
+ does_nothing(model)
79
+ end
80
+ end
69
81
  end
70
- end
82
+ end
Binary file
@@ -13,4 +13,10 @@ module Photos
13
13
  lat: nil,
14
14
  lng: nil
15
15
  ).freeze
16
- end
16
+
17
+ INVALID = OpenStruct.new(
18
+ path: File.join(ROOT, 'not-a-jpg.jpg'),
19
+ lat: nil,
20
+ lng: nil
21
+ )
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-location
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Doyle
@@ -99,6 +99,7 @@ files:
99
99
  - lib/paperclip/location/railtie.rb
100
100
  - paperclip-location.gemspec
101
101
  - spec/paperclip/location/processor_spec.rb
102
+ - spec/photos/not-a-jpg.jpg
102
103
  - spec/photos/with-exif.jpg
103
104
  - spec/photos/without-exif.jpg
104
105
  - spec/spec_helper.rb
@@ -129,6 +130,7 @@ specification_version: 4
129
130
  summary: extract geolocation EXIF data during Paperclip processing
130
131
  test_files:
131
132
  - spec/paperclip/location/processor_spec.rb
133
+ - spec/photos/not-a-jpg.jpg
132
134
  - spec/photos/with-exif.jpg
133
135
  - spec/photos/without-exif.jpg
134
136
  - spec/spec_helper.rb