paperclip-location 0.0.3 → 0.0.4
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 +4 -4
- data/README.md +15 -10
- data/lib/paperclip/location.rb +9 -1
- data/lib/paperclip/location/processor.rb +15 -11
- data/lib/paperclip/location/railtie.rb +4 -11
- data/paperclip-location.gemspec +1 -1
- data/spec/spec_helper.rb +1 -3
- metadata +2 -3
- data/lib/paperclip/paperclip.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b486d5f70b9fdd6429bf4efa1ab66c57bd8874b
|
4
|
+
data.tar.gz: b1c4a527384185b4825f17b9eacc9d379c7a1160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 362c19d1487bd876a6ff4889535abc254ddb312b557e974733190146e2a7b4936ce1b71c0130e6c84b760066aad0c785aecec28477b3692b5353d45f622944fc
|
7
|
+
data.tar.gz: ae0868adc43c8cc33d71adf3ec77888d95592a08795b0a5703734f8d3427006d305d58ac4c98c574bf77772bab8ba50f048c2975ac0f9b7527fa0d5e8c5b6b47
|
data/README.md
CHANGED
@@ -8,24 +8,29 @@ and attaches it to the associated model.
|
|
8
8
|
## Installation
|
9
9
|
|
10
10
|
Add this line to your application's Gemfile:
|
11
|
+
|
11
12
|
```ruby
|
12
|
-
|
13
|
+
gem 'paperclip-location'
|
13
14
|
```
|
14
15
|
|
15
16
|
And then execute:
|
16
17
|
|
17
|
-
|
18
|
+
```console
|
19
|
+
$ bundle
|
20
|
+
```
|
18
21
|
|
19
22
|
Or install it yourself as:
|
20
23
|
|
21
|
-
|
24
|
+
```console
|
25
|
+
$ gem install paperclip-location
|
26
|
+
```
|
22
27
|
|
23
28
|
## Usage
|
24
29
|
|
25
30
|
Use it like any other `Paperclip::Processor`
|
26
31
|
|
27
32
|
```ruby
|
28
|
-
class
|
33
|
+
class Place < ActiveRecord::Base
|
29
34
|
|
30
35
|
has_attached_file :photo, styles: { large: '600x600#' },
|
31
36
|
processors: [:thumbnail, :location]
|
@@ -36,17 +41,17 @@ end
|
|
36
41
|
The processor expects that the model in question has the following:
|
37
42
|
|
38
43
|
* `location_locked` - a boolean flag to determine if the location has been manually overridden
|
39
|
-
* `lat` - a
|
40
|
-
* `lng` - a
|
44
|
+
* `lat` - a decimal representing the latitude
|
45
|
+
* `lng` - a decimal representing the longitude
|
41
46
|
|
42
47
|
If you don't have either, run a migration to add them
|
43
48
|
|
44
49
|
```ruby
|
45
|
-
class
|
50
|
+
class AddLocationToPlaces < ActiveRecord::Migration
|
46
51
|
def self.change
|
47
|
-
add_column :
|
48
|
-
add_column :
|
49
|
-
add_column :
|
52
|
+
add_column :places, :location_locked, :boolean, default: false, null: false
|
53
|
+
add_column :places, :lat, :decimal, precision: 10, scale: 15
|
54
|
+
add_column :places, :lng, :decimal, precision: 10, scale: 15
|
50
55
|
end
|
51
56
|
end
|
52
57
|
```
|
data/lib/paperclip/location.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
|
-
require 'paperclip'
|
2
1
|
require 'exifr'
|
2
|
+
require 'paperclip'
|
3
3
|
|
4
|
-
module Paperclip
|
5
|
-
|
6
|
-
class Processor < Paperclip::Processor
|
7
|
-
|
4
|
+
module Paperclip::Location
|
5
|
+
class Processor < Paperclip::Processor
|
8
6
|
delegate :location_locked?, to: :instance, allow_nil: true
|
9
7
|
delegate :instance, to: :attachment, allow_nil: true
|
10
8
|
delegate :gps, to: :exif
|
11
9
|
|
10
|
+
def self.register!(name = :location)
|
11
|
+
Paperclip.configure do |c|
|
12
|
+
c.register_processor name, self
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
12
16
|
def make
|
13
17
|
if can_process?
|
14
18
|
instance.lat = gps.latitude
|
@@ -18,13 +22,13 @@ module Paperclip
|
|
18
22
|
end
|
19
23
|
|
20
24
|
private
|
21
|
-
def can_process?
|
22
|
-
!location_locked? && gps.present? && instance.present?
|
23
|
-
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def can_process?
|
27
|
+
!location_locked? && gps.present? && instance.present?
|
28
|
+
end
|
29
|
+
|
30
|
+
def exif
|
31
|
+
@exif ||= EXIFR::JPEG.new(file.path)
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
@@ -1,14 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
module Location
|
6
|
-
class Railtie < Rails::Railtie
|
7
|
-
initializer "paperclip-location.configure_rails_initialization" do
|
8
|
-
Paperclip.configure do |c|
|
9
|
-
c.register_processor :location, Paperclip::Location::Processor
|
10
|
-
end
|
11
|
-
end
|
1
|
+
module Paperclip::Location
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
initializer "paperclip-location.configure_rails_initialization" do
|
4
|
+
Paperclip::Location::Processor.register
|
12
5
|
end
|
13
6
|
end
|
14
7
|
end
|
data/paperclip-location.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "paperclip-location"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.4"
|
8
8
|
spec.authors = ["Sean Doyle"]
|
9
9
|
spec.email = ["sean.p.doyle24@gmail.com"]
|
10
10
|
spec.description = %q{extract geolocation during Paperclip processing}
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-location
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Doyle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,7 +97,6 @@ files:
|
|
97
97
|
- lib/paperclip/location.rb
|
98
98
|
- lib/paperclip/location/processor.rb
|
99
99
|
- lib/paperclip/location/railtie.rb
|
100
|
-
- lib/paperclip/paperclip.rb
|
101
100
|
- paperclip-location.gemspec
|
102
101
|
- spec/paperclip/location/processor_spec.rb
|
103
102
|
- spec/photos/with-exif.jpg
|
data/lib/paperclip/paperclip.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'paperclip/location'
|