image_flux 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +45 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +82 -0
- data/.travis.yml +5 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +56 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/image_flux.gemspec +33 -0
- data/lib/image_flux.rb +15 -0
- data/lib/image_flux/attribute.rb +80 -0
- data/lib/image_flux/error.rb +9 -0
- data/lib/image_flux/option.rb +109 -0
- data/lib/image_flux/origin.rb +41 -0
- data/lib/image_flux/version.rb +5 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 986f54bd3b8b9403395fdef47c91f007b70b959e
|
4
|
+
data.tar.gz: 96994e08bb172eb651c02f89b138e8078be36aef
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9ee0566b415768c7788d47e3282c9b14b65440bf4ef5508e2891820a293258dbd876e57dd409e93359c3d7bc78935c00aac8b4c621e166ca916dee5aedd70fb2
|
7
|
+
data.tar.gz: 182408c61948d5c92e5e4b0004d15194b21e103d37efaad910b206251489f8e55a9fb3da45f6333a8a86a723cda9c4d417918e84b17b9eb71cd22656accdb422
|
@@ -0,0 +1,45 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
docker:
|
5
|
+
- image: circleci/ruby:2.4.1
|
6
|
+
working_directory: ~/repo
|
7
|
+
|
8
|
+
steps:
|
9
|
+
- checkout
|
10
|
+
|
11
|
+
- run:
|
12
|
+
name: Update Bunndler
|
13
|
+
command: gem update bundler
|
14
|
+
|
15
|
+
- restore_cache:
|
16
|
+
keys:
|
17
|
+
- v1-dependencies-{{ checksum "image_flux.gemspec" }}
|
18
|
+
- v1-dependencies-
|
19
|
+
|
20
|
+
- run:
|
21
|
+
name: install dependencies
|
22
|
+
command: |
|
23
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
24
|
+
|
25
|
+
- save_cache:
|
26
|
+
paths:
|
27
|
+
- ./vendor/bundle
|
28
|
+
key: v1-dependencies-{{ checksum "image_flux.gemspec" }}
|
29
|
+
|
30
|
+
- run:
|
31
|
+
name: RSpec
|
32
|
+
command: |
|
33
|
+
mkdir /tmp/test-results
|
34
|
+
|
35
|
+
bundle exec rspec --format progress \
|
36
|
+
--format RspecJunitFormatter \
|
37
|
+
--out /tmp/test-results/rspec.xml \
|
38
|
+
--format progress
|
39
|
+
|
40
|
+
# collect reports
|
41
|
+
- store_test_results:
|
42
|
+
path: /tmp/test-results
|
43
|
+
- store_artifacts:
|
44
|
+
path: /tmp/test-results
|
45
|
+
destination: test-results
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
DisplayStyleGuide: true
|
4
|
+
|
5
|
+
Layout/AlignParameters:
|
6
|
+
EnforcedStyle: with_fixed_indentation
|
7
|
+
|
8
|
+
Style/ClassAndModuleChildren:
|
9
|
+
EnforcedStyle: compact
|
10
|
+
Exclude:
|
11
|
+
- config/application.rb
|
12
|
+
|
13
|
+
Style/Documentation:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/FrozenStringLiteralComment:
|
17
|
+
EnforcedStyle: always
|
18
|
+
Enabled: true
|
19
|
+
|
20
|
+
Style/RegexpLiteral:
|
21
|
+
EnforcedStyle: percent_r
|
22
|
+
|
23
|
+
#################### Metrics ###############################
|
24
|
+
|
25
|
+
Metrics/AbcSize:
|
26
|
+
Max: 15
|
27
|
+
|
28
|
+
Metrics/BlockLength:
|
29
|
+
CountComments: false
|
30
|
+
Max: 25
|
31
|
+
ExcludedMethods: []
|
32
|
+
Exclude:
|
33
|
+
- Guardfile
|
34
|
+
|
35
|
+
Metrics/BlockNesting:
|
36
|
+
CountBlocks: false
|
37
|
+
Max: 3
|
38
|
+
|
39
|
+
Metrics/ClassLength:
|
40
|
+
CountComments: false
|
41
|
+
Max: 200
|
42
|
+
|
43
|
+
Metrics/CyclomaticComplexity:
|
44
|
+
Max: 12
|
45
|
+
|
46
|
+
Metrics/LineLength:
|
47
|
+
Max: 180
|
48
|
+
|
49
|
+
Metrics/MethodLength:
|
50
|
+
Max: 20
|
51
|
+
|
52
|
+
Metrics/ModuleLength:
|
53
|
+
Max: 200
|
54
|
+
|
55
|
+
Metrics/ParameterLists:
|
56
|
+
Max: 5
|
57
|
+
|
58
|
+
Metrics/PerceivedComplexity:
|
59
|
+
Max: 7
|
60
|
+
|
61
|
+
#################### Lint ##################################
|
62
|
+
|
63
|
+
Lint/UnusedBlockArgument:
|
64
|
+
IgnoreEmptyBlocks: true
|
65
|
+
AllowUnusedKeywordArguments: true
|
66
|
+
|
67
|
+
Lint/UnusedMethodArgument:
|
68
|
+
AllowUnusedKeywordArguments: true
|
69
|
+
IgnoreEmptyMethods: true
|
70
|
+
|
71
|
+
#################### Performance ###########################
|
72
|
+
|
73
|
+
Performance/DoubleStartEndWith:
|
74
|
+
IncludeActiveSupportAliases: false
|
75
|
+
|
76
|
+
Performance/RedundantMerge:
|
77
|
+
MaxKeyValuePairs: 2
|
78
|
+
|
79
|
+
#################### Rails #################################
|
80
|
+
|
81
|
+
Rails/ActionFilter:
|
82
|
+
EnforcedStyle: action
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Sho Kusano
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# ImageFlux
|
2
|
+
|
3
|
+
[![Gem](https://img.shields.io/gem/v/image_flux.svg)](https://rubygems.org/gems/image_flux)
|
4
|
+
[![CircleCI](https://img.shields.io/circleci/project/github/space-pirates-llc/image_flux.svg)](https://circleci.com/gh/space-pirates-llc/image_flux)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/space-pirates-llc/image_flux/badge.svg?branch=master)](https://coveralls.io/github/space-pirates-llc/image_flux?branch=master)
|
6
|
+
|
7
|
+
URL builder for [ImageFlux](https://www.sakura.ad.jp/services/imageflux/)®.
|
8
|
+
|
9
|
+
WIP: Provide API client
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'image_flux'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install image_flux
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
### Generate resize url for a path
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'image_flux'
|
33
|
+
origin = ImageFlux::Origin.new(domain: 'example.imageflux.jp')
|
34
|
+
|
35
|
+
origin.image_url("/original.jpg', width: 100)
|
36
|
+
# => https://example.imageflux.jp/c/w=100/original.jpg
|
37
|
+
```
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
42
|
+
|
43
|
+
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).
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/space-pirates-llc/image_flux>.
|
48
|
+
|
49
|
+
## License
|
50
|
+
|
51
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
52
|
+
|
53
|
+
## Notation
|
54
|
+
|
55
|
+
- ImageFlux is a registered trademark of [SAKURA Internet Inc](https://www.sakura.ad.jp/).
|
56
|
+
- Regarding the use of this gem, pixiv Inc and SAKURA Internet Inc makes no responsibility.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'image_flux'
|
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__)
|
data/bin/setup
ADDED
data/image_flux.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'image_flux/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'image_flux'
|
10
|
+
spec.version = ImageFlux::VERSION
|
11
|
+
spec.authors = ['Sho Kusano']
|
12
|
+
spec.email = ['sho-kusano@space-pirates.jp']
|
13
|
+
|
14
|
+
spec.summary = 'URL builder for ImageFlux'
|
15
|
+
spec.description = spec.summary
|
16
|
+
spec.homepage = 'https://github.com/space-pirates-llc/image_flux'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
27
|
+
spec.add_development_dependency 'ffaker'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
spec.add_development_dependency 'rspec_junit_formatter'
|
31
|
+
spec.add_development_dependency 'simplecov'
|
32
|
+
spec.add_development_dependency 'coveralls'
|
33
|
+
end
|
data/lib/image_flux.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'image_flux/version'
|
4
|
+
require 'image_flux/origin'
|
5
|
+
require 'image_flux/option'
|
6
|
+
|
7
|
+
module ImageFlux
|
8
|
+
class << self
|
9
|
+
attr_accessor :default_origin
|
10
|
+
|
11
|
+
def image_url(path, options = {})
|
12
|
+
default_origin.image_url(path, options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'erb'
|
4
|
+
require 'image_flux'
|
5
|
+
|
6
|
+
class ImageFlux::Attribute
|
7
|
+
def initialize(name, type, default: nil, aliases: [], enum: nil, query: true)
|
8
|
+
@name = name.to_s.to_sym
|
9
|
+
@type = type
|
10
|
+
@default = default
|
11
|
+
@aliases = aliases.flatten.map { |a| a.to_s.to_sym }.uniq
|
12
|
+
@enum = enum
|
13
|
+
@validators = []
|
14
|
+
@query = query
|
15
|
+
end
|
16
|
+
attr_reader :name, :type, :default, :aliases
|
17
|
+
|
18
|
+
def validate(&block)
|
19
|
+
@validators.push(block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def expand(value)
|
23
|
+
@enum ? @enum.fetch(value) { value } : value
|
24
|
+
end
|
25
|
+
|
26
|
+
def querize(value, ignore_default: true)
|
27
|
+
value = expand(value)
|
28
|
+
return nil if !@query || (ignore_default && default == value)
|
29
|
+
|
30
|
+
value = case type
|
31
|
+
when :string
|
32
|
+
ERB::Util.url_encode(value.to_s)
|
33
|
+
when :integer
|
34
|
+
value.to_i.to_s
|
35
|
+
when :float
|
36
|
+
value.to_f.to_s
|
37
|
+
when :integer_array
|
38
|
+
value.map(&:to_i).join(':')
|
39
|
+
when :float_array
|
40
|
+
value.map(&:to_f).join(':')
|
41
|
+
when :boolean
|
42
|
+
value ? '1' : '0'
|
43
|
+
else
|
44
|
+
value
|
45
|
+
end
|
46
|
+
|
47
|
+
"#{name}=#{value}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def validate!(value)
|
51
|
+
errors = []
|
52
|
+
value = expand(value)
|
53
|
+
errors.push(validate_type(value))
|
54
|
+
@validators.each do |validator|
|
55
|
+
errors.push(validator.call(value))
|
56
|
+
end
|
57
|
+
errors.reject(&:nil?)
|
58
|
+
end
|
59
|
+
|
60
|
+
def validate_type(value)
|
61
|
+
check = case type
|
62
|
+
when :string
|
63
|
+
value.is_a?(String) || value.respond_to?(:to_s)
|
64
|
+
when :integer
|
65
|
+
value.is_a?(Integer) || value.respond_to?(:to_i)
|
66
|
+
when :float
|
67
|
+
value.is_a?(Float) || value.respond_to?(:to_f)
|
68
|
+
when :integer_array
|
69
|
+
value.is_a?(Array) && value.all? { |elem| elem.is_a?(Integer) || elem.respond_to?(:to_i) }
|
70
|
+
when :float_array
|
71
|
+
value.is_a?(Array) && value.all? { |elem| elem.is_a?(Float) || elem.respond_to?(:to_i) }
|
72
|
+
when :boolean
|
73
|
+
value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
74
|
+
else
|
75
|
+
true
|
76
|
+
end
|
77
|
+
|
78
|
+
return "#{name} is invalid type(expected be a #{type})" unless check
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'image_flux'
|
4
|
+
require 'image_flux/attribute'
|
5
|
+
require 'image_flux/error'
|
6
|
+
|
7
|
+
class ImageFlux::Option
|
8
|
+
def self.attributes
|
9
|
+
@attributes ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.key_pairs
|
13
|
+
@key_pairs ||= {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.attribute(name, type, options = {}, &block)
|
17
|
+
attribute = ImageFlux::Attribute.new(name, type, options)
|
18
|
+
attribute.instance_eval(&block) if block_given?
|
19
|
+
key_pairs[attribute.name] = attribute
|
20
|
+
attribute.aliases.each do |key|
|
21
|
+
key_pairs[key] = attribute
|
22
|
+
end
|
23
|
+
|
24
|
+
attributes.push(attribute)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Predefined prefix path
|
28
|
+
attribute :prefix, :string, default: nil, query: false
|
29
|
+
|
30
|
+
# resize attributes
|
31
|
+
attribute :w, :integer, default: nil, aliases: %i[width]
|
32
|
+
attribute :h, :integer, default: nil, aliases: %i[height]
|
33
|
+
attribute :u, :boolean, default: true, aliases: %i[upscale]
|
34
|
+
attribute :a, :integer, default: 1, aliases: %i[aspect]
|
35
|
+
attribute :c, :integer_array, default: nil, aliases: %i[crop]
|
36
|
+
attribute :cr, :float_array, default: nil, aliases: %i[]
|
37
|
+
attribute :g, :integer, default: 4, aliases: %i[gravity], enum: {
|
38
|
+
top_left: 1,
|
39
|
+
top_center: 2,
|
40
|
+
top_right: 3,
|
41
|
+
middle_left: 4,
|
42
|
+
middle_center: 5,
|
43
|
+
middle_right: 6,
|
44
|
+
bottom_left: 7,
|
45
|
+
bottom_center: 8,
|
46
|
+
bottom_right: 9
|
47
|
+
}
|
48
|
+
attribute :b, :string, default: 'ffffff', aliases: %i[background] do
|
49
|
+
validate do |value|
|
50
|
+
'b should be a color code' unless value.to_s =~ %r{\A[0-9a-fA-F]{6}\z}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
attribute :r, :integer, default: 1, aliases: %i[rotate]
|
54
|
+
# overlay attributes
|
55
|
+
attribute :l, :string, default: nil
|
56
|
+
attribute :lx, :integer, default: nil
|
57
|
+
attribute :lxr, :integer, default: nil
|
58
|
+
attribute :ly, :integer, default: nil
|
59
|
+
attribute :lyr, :integer, default: nil
|
60
|
+
attribute :lg, :integer, default: 5, aliases: %i[gravity], enum: {
|
61
|
+
top_left: 1,
|
62
|
+
top_center: 2,
|
63
|
+
top_right: 3,
|
64
|
+
middle_left: 4,
|
65
|
+
middle_center: 5,
|
66
|
+
middle_right: 6,
|
67
|
+
bottom_left: 7,
|
68
|
+
bottom_center: 8,
|
69
|
+
bottom_right: 9
|
70
|
+
}
|
71
|
+
# output attributes
|
72
|
+
attribute :f, :string, default: 'auto', aliases: %i[format] do
|
73
|
+
validate do |value|
|
74
|
+
%w[auto jpg png gif webp:jpeg webp:png].include?(value.to_s)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
attribute :q, :integer, default: 75, aliases: %i[quality]
|
78
|
+
attribute :o, :boolean, default: true, aliases: %i[optimize]
|
79
|
+
|
80
|
+
attribute :sig, :nonescape_string, default: nil
|
81
|
+
|
82
|
+
def initialize(options = {})
|
83
|
+
@values = {}
|
84
|
+
|
85
|
+
options.each_pair do |key, val|
|
86
|
+
key = key.to_s.to_sym
|
87
|
+
attribute = self.class.key_pairs[key]
|
88
|
+
@values[attribute] = val if attribute
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def prefix_path
|
93
|
+
prefix_attr = self.class.key_pairs[:prefix]
|
94
|
+
@values[prefix_attr]
|
95
|
+
end
|
96
|
+
|
97
|
+
def to_query(ignore_default: true)
|
98
|
+
errors = []
|
99
|
+
queries = @values.to_a.map do |pair|
|
100
|
+
attribute = pair.first
|
101
|
+
value = pair.last
|
102
|
+
errors.concat(attribute.validate!(value))
|
103
|
+
attribute.querize(value)
|
104
|
+
end
|
105
|
+
raise ImageFlux::InvalidOptionError, errors.join(', ') unless errors.length.zero?
|
106
|
+
|
107
|
+
queries.reject(&:nil?).join(',')
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'openssl'
|
5
|
+
require 'base64'
|
6
|
+
require 'image_flux'
|
7
|
+
|
8
|
+
class ImageFlux::Origin
|
9
|
+
attr_reader :domain, :scheme, :signing_version, :signing_secret
|
10
|
+
def initialize(domain:, scheme: 'https', signing_version: '1', signing_secret: nil, **_options)
|
11
|
+
@domain = domain.to_s
|
12
|
+
@scheme = scheme.to_s
|
13
|
+
@signing_version = signing_version
|
14
|
+
@signing_secret = signing_secret
|
15
|
+
end
|
16
|
+
|
17
|
+
def base_url
|
18
|
+
@base_url ||= URI("#{@scheme}://#{@domain}/")
|
19
|
+
end
|
20
|
+
|
21
|
+
def image_url(path, options = {})
|
22
|
+
path = "/#{path}" unless path.start_with?('/')
|
23
|
+
|
24
|
+
options = options.merge(sig: sign(path)) if @signing_secret
|
25
|
+
opt = ImageFlux::Option.new(options)
|
26
|
+
|
27
|
+
path = "#{opt.prefix_path}#{path}" if opt.prefix_path
|
28
|
+
query = opt.to_query
|
29
|
+
|
30
|
+
url = base_url.dup
|
31
|
+
url.path = query.length.zero? ? path : "/c/#{opt.to_query}#{path}"
|
32
|
+
|
33
|
+
url
|
34
|
+
end
|
35
|
+
|
36
|
+
def sign(path)
|
37
|
+
digest = OpenSSL::HMAC.digest('sha256', @signing_secret, path)
|
38
|
+
|
39
|
+
"#{@signing_version}.#{Base64.urlsafe_encode64(digest)}"
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: image_flux
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sho Kusano
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-07 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: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ffaker
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec_junit_formatter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
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: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: URL builder for ImageFlux
|
112
|
+
email:
|
113
|
+
- sho-kusano@space-pirates.jp
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".circleci/config.yml"
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- ".travis.yml"
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- bin/console
|
128
|
+
- bin/setup
|
129
|
+
- image_flux.gemspec
|
130
|
+
- lib/image_flux.rb
|
131
|
+
- lib/image_flux/attribute.rb
|
132
|
+
- lib/image_flux/error.rb
|
133
|
+
- lib/image_flux/option.rb
|
134
|
+
- lib/image_flux/origin.rb
|
135
|
+
- lib/image_flux/version.rb
|
136
|
+
homepage: https://github.com/space-pirates-llc/image_flux
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
metadata: {}
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 2.6.13
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: URL builder for ImageFlux
|
160
|
+
test_files: []
|