paperclip-location 0.0.3 → 0.0.4

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: df7dbc3741267077226c6e380077ad0af5365246
4
- data.tar.gz: 7a0ddacad662b5559c3d8d6822eb627565eaa571
3
+ metadata.gz: 5b486d5f70b9fdd6429bf4efa1ab66c57bd8874b
4
+ data.tar.gz: b1c4a527384185b4825f17b9eacc9d379c7a1160
5
5
  SHA512:
6
- metadata.gz: a02d309d4e24fdcdcbfe79569d7e563164bd7ea111288367685cdee89fff43d5642802a84c7e6979b2a3e425ddfab2975501a0d31bca8d160ef41663734b03fc
7
- data.tar.gz: bfb6b694f2255727a2849e7ee78286322fa8936b8b2b146596b0602451779723e7d8384fd9bb8d0eb5a2f0724340b1490930276edcd6d3c0fbc17fb0f327522b
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
- gem 'paperclip-location', github: 'seanpdoyle/paperclip-location'
13
+ gem 'paperclip-location'
13
14
  ```
14
15
 
15
16
  And then execute:
16
17
 
17
- $ bundle
18
+ ```console
19
+ $ bundle
20
+ ```
18
21
 
19
22
  Or install it yourself as:
20
23
 
21
- $ gem install paperclip-location
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 PlaceOfInterest < ActiveRecord::Base
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 float representing the latitude
40
- * `lng` - a float representing the longitude
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 AddLocationToModel < ActiveRecord::Migration
50
+ class AddLocationToPlaces < ActiveRecord::Migration
46
51
  def self.change
47
- add_column :model, :location_locked, :boolean, default: false, null: false
48
- add_column :model, :lat, :float
49
- add_column :model, :lng, :float
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
  ```
@@ -1,2 +1,10 @@
1
+ module Paperclip
2
+ module Location
3
+ end
4
+ end
5
+
1
6
  require 'paperclip/location/processor'
2
- require 'paperclip/location/railtie' if defined?(Rails)
7
+
8
+ if defined?(Rails)
9
+ require 'paperclip/location/railtie'
10
+ end
@@ -1,14 +1,18 @@
1
- require 'paperclip'
2
1
  require 'exifr'
2
+ require 'paperclip'
3
3
 
4
- module Paperclip
5
- module Location
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
- def exif
26
- @exif ||= EXIFR::JPEG.new(file.path)
27
- end
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
- require 'paperclip'
2
- require 'paperclip/location/processor'
3
-
4
- module Paperclip
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
@@ -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.3"
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}
@@ -1,5 +1,3 @@
1
- $LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
2
-
3
1
  Dir[File.join(File.dirname(File.realpath(__FILE__)), 'support/**/*.rb')].each { |file| require file }
4
2
 
5
- require 'paperclip/location'
3
+ require 'paperclip/location'
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.3
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: 2013-12-31 00:00:00.000000000 Z
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
@@ -1 +0,0 @@
1
- require 'paperclip/location'