activestorage-exif-analyzer 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a1f4f34080928fa1b2b7e369b3bd7840b6caf76d23d8f595d797c97504842638
4
+ data.tar.gz: e0283e9f4cf40d98081551c24da57a82ec1b47e0479ab2bb600a7c7188c6c445
5
+ SHA512:
6
+ metadata.gz: 2ba2c775d63af918dbf614735739b26535c0b6ea3566edfd1da2572f7a24cd28bee28afe4aa4a6eadf0de53a6a2be915c37c825245ad261808f52739a45b8ba9
7
+ data.tar.gz: aafe53599e2867fc3e6d0b73767e9ad3c7a8629943e01cd188b02151701d6d7c5614fa06ddb57a5807ddc14067430028c092d6c6fe76ae0c23090a694d4d698f
@@ -0,0 +1,24 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ build:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby 2.6
17
+ uses: actions/setup-ruby@v1
18
+ with:
19
+ ruby-version: 2.6.x
20
+ - name: Build and test with Rake
21
+ run: |
22
+ gem install bundler
23
+ bundle install --jobs 4 --retry 3
24
+ bundle exec rake
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in activestorage-exif-analyzer.gemspec
6
+ gemspec
@@ -0,0 +1,118 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ activestorage-exif-analyzer (0.1.0)
5
+ activestorage
6
+ mini_magick
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionpack (6.0.2.2)
12
+ actionview (= 6.0.2.2)
13
+ activesupport (= 6.0.2.2)
14
+ rack (~> 2.0, >= 2.0.8)
15
+ rack-test (>= 0.6.3)
16
+ rails-dom-testing (~> 2.0)
17
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
+ actionview (6.0.2.2)
19
+ activesupport (= 6.0.2.2)
20
+ builder (~> 3.1)
21
+ erubi (~> 1.4)
22
+ rails-dom-testing (~> 2.0)
23
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
+ activejob (6.0.2.2)
25
+ activesupport (= 6.0.2.2)
26
+ globalid (>= 0.3.6)
27
+ activemodel (6.0.2.2)
28
+ activesupport (= 6.0.2.2)
29
+ activerecord (6.0.2.2)
30
+ activemodel (= 6.0.2.2)
31
+ activesupport (= 6.0.2.2)
32
+ activestorage (6.0.2.2)
33
+ actionpack (= 6.0.2.2)
34
+ activejob (= 6.0.2.2)
35
+ activerecord (= 6.0.2.2)
36
+ marcel (~> 0.3.1)
37
+ activesupport (6.0.2.2)
38
+ concurrent-ruby (~> 1.0, >= 1.0.2)
39
+ i18n (>= 0.7, < 2)
40
+ minitest (~> 5.1)
41
+ tzinfo (~> 1.1)
42
+ zeitwerk (~> 2.2)
43
+ ast (2.4.0)
44
+ builder (3.2.4)
45
+ concurrent-ruby (1.1.6)
46
+ crass (1.0.6)
47
+ diff-lcs (1.3)
48
+ erubi (1.9.0)
49
+ globalid (0.4.2)
50
+ activesupport (>= 4.2.0)
51
+ i18n (1.8.2)
52
+ concurrent-ruby (~> 1.0)
53
+ jaro_winkler (1.5.4)
54
+ loofah (2.4.0)
55
+ crass (~> 1.0.2)
56
+ nokogiri (>= 1.5.9)
57
+ marcel (0.3.3)
58
+ mimemagic (~> 0.3.2)
59
+ mimemagic (0.3.4)
60
+ mini_magick (4.9.5)
61
+ mini_portile2 (2.4.0)
62
+ minitest (5.14.0)
63
+ nokogiri (1.10.9)
64
+ mini_portile2 (~> 2.4.0)
65
+ parallel (1.19.1)
66
+ parser (2.7.0.5)
67
+ ast (~> 2.4.0)
68
+ rack (2.2.2)
69
+ rack-test (1.1.0)
70
+ rack (>= 1.0, < 3)
71
+ rails-dom-testing (2.0.3)
72
+ activesupport (>= 4.2.0)
73
+ nokogiri (>= 1.6)
74
+ rails-html-sanitizer (1.3.0)
75
+ loofah (~> 2.3)
76
+ rainbow (3.0.0)
77
+ rake (10.5.0)
78
+ rexml (3.2.4)
79
+ rspec (3.8.0)
80
+ rspec-core (~> 3.8.0)
81
+ rspec-expectations (~> 3.8.0)
82
+ rspec-mocks (~> 3.8.0)
83
+ rspec-core (3.8.2)
84
+ rspec-support (~> 3.8.0)
85
+ rspec-expectations (3.8.4)
86
+ diff-lcs (>= 1.2.0, < 2.0)
87
+ rspec-support (~> 3.8.0)
88
+ rspec-mocks (3.8.1)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.8.0)
91
+ rspec-support (3.8.2)
92
+ rubocop (0.80.1)
93
+ jaro_winkler (~> 1.5.1)
94
+ parallel (~> 1.10)
95
+ parser (>= 2.7.0.1)
96
+ rainbow (>= 2.2.2, < 4.0)
97
+ rexml
98
+ ruby-progressbar (~> 1.7)
99
+ unicode-display_width (>= 1.4.0, < 1.7)
100
+ ruby-progressbar (1.10.1)
101
+ thread_safe (0.3.6)
102
+ tzinfo (1.2.6)
103
+ thread_safe (~> 0.1)
104
+ unicode-display_width (1.6.1)
105
+ zeitwerk (2.3.0)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ activestorage-exif-analyzer!
112
+ bundler (~> 2.0)
113
+ rake (~> 10.0)
114
+ rspec (~> 3.0)
115
+ rubocop
116
+
117
+ BUNDLED WITH
118
+ 2.0.2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Ackama
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,59 @@
1
+ # ActiveStorage::Exif::Analyzer
2
+
3
+ This gem packages a simple analyzer to extract EXIF metadata from supported files.
4
+ "Supported files" means anything supported by ImageMagick - i.e. more than just JPEG.
5
+
6
+ The actual analyzer is very simple, and can be found in `lib/active_storage/exif/analyzer` if you would
7
+ prefer to just drop this in `app/analyzers` in your codebase and prepend it to the analyzers list yourself.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'activestorage-exif-analyzer', require: "active_storage/exif/analyzer"
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install activestorage-exif-analyzer
24
+
25
+ This gem will automatically add itself to the analyzer pipeline and run across any
26
+ supported image files. If you wish to control the precise analyzer order, you can
27
+ manipulate the `ActiveStorage.analyzers` array.
28
+
29
+ ## Usage
30
+
31
+ This gem automatically adds itself to the analysis pipeline, simply ensure that analysis is run on your uploaded files.
32
+
33
+ To manually see what kind of metadata is extracted from a particular blob, simply grab an attachment and pass the the
34
+ blob directly to the analyzer:
35
+
36
+ ``` ruby
37
+ ActiveStorage::Exif::Analyzer.new(ActiveStorage::Attachment.first.blob).metadata
38
+ => {"width"=>4208,
39
+ "height"=>3120,
40
+ "analyzed"=>true,
41
+ "exif"=> {
42
+ "ApertureValue"=>"200/100",
43
+ "ColorSpace"=>"1",
44
+ "ComponentsConfiguration"=>"1, 2, 3, 0",
45
+ "DateTimeDigitized"=>"2002:12:08 12:00:00",
46
+ "DateTimeOriginal"=>"2015:09:26 18:15:50",
47
+ # ...
48
+ }}
49
+ ```
50
+
51
+ ## Development
52
+
53
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the lint checks and tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
54
+
55
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ackama/activestorage-exif-analyzer.
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+
7
+ RuboCop::RakeTask.new(:rubocop) do |t|
8
+ t.options = ['--parallel']
9
+ end
10
+
11
+ RSpec::Core::RakeTask.new(:spec)
12
+
13
+ task default: %i[rubocop spec]
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'activestorage-exif-analyzer'
8
+ spec.version = '0.1.0'
9
+ spec.authors = ['Josh McArthur']
10
+ spec.email = ['joshua.mcarthur@gmail.com']
11
+
12
+ spec.summary = 'Extracts EXIF data from supported images.'
13
+ spec.description = '
14
+ Add ActiveStorage Analyzer class to extract EXIF data
15
+ from supported images.'
16
+ spec.homepage = 'https://github.com/ackama/activestorage-exif-analyzer'
17
+
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = spec.homepage
20
+ spec.metadata['changelog_uri'] = spec.homepage
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been
24
+ # added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ end
30
+ spec.bindir = 'exe'
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ['lib']
33
+
34
+ spec.add_development_dependency 'bundler', '~> 2.0'
35
+ spec.add_development_dependency 'rake', '~> 10.0'
36
+ spec.add_development_dependency 'rspec', '~> 3.0'
37
+ spec.add_development_dependency 'rubocop'
38
+ spec.add_dependency 'activestorage'
39
+ spec.add_dependency 'mini_magick'
40
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'activestorage/exif/analyzer'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+ bundle exec rake
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_storage'
4
+ require 'active_storage/analyzer/image_analyzer'
5
+
6
+ module ActiveStorage
7
+ module Exif
8
+ ##
9
+ # Uses MiniMagick to extract EXIF metadata from an image file.
10
+ # By extending ImageAnalyzer, all the error handling is done
11
+ # for us.
12
+ class Analyzer < ActiveStorage::Analyzer::ImageAnalyzer
13
+ def metadata
14
+ { exif: read_image(&:exif) }
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ require 'active_storage/exif/railtie' if defined?(Rails)
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveStorage
4
+ module Exif
5
+ class Railtie < Rails::Railtie
6
+ config.active_storage.analyzers.prepend ActiveStorage::Exif::Analyzer
7
+ end
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activestorage-exif-analyzer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh McArthur
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-03-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activestorage
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mini_magick
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: |2-
98
+
99
+ Add ActiveStorage Analyzer class to extract EXIF data
100
+ from supported images.
101
+ email:
102
+ - joshua.mcarthur@gmail.com
103
+ executables: []
104
+ extensions: []
105
+ extra_rdoc_files: []
106
+ files:
107
+ - ".github/workflows/ruby.yml"
108
+ - ".gitignore"
109
+ - ".rspec"
110
+ - Gemfile
111
+ - Gemfile.lock
112
+ - LICENSE
113
+ - README.md
114
+ - Rakefile
115
+ - activestorage-exif-analyzer.gemspec
116
+ - bin/console
117
+ - bin/setup
118
+ - lib/active_storage/exif/analyzer.rb
119
+ - lib/active_storage/exif/railtie.rb
120
+ homepage: https://github.com/ackama/activestorage-exif-analyzer
121
+ licenses: []
122
+ metadata:
123
+ homepage_uri: https://github.com/ackama/activestorage-exif-analyzer
124
+ source_code_uri: https://github.com/ackama/activestorage-exif-analyzer
125
+ changelog_uri: https://github.com/ackama/activestorage-exif-analyzer
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubygems_version: 3.0.3
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Extracts EXIF data from supported images.
145
+ test_files: []