imageboss-rb 1.0.3 → 2.0.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.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +3 -6
- data/README.md +9 -8
- data/lib/imageboss/client.rb +2 -2
- data/lib/imageboss/path.rb +8 -7
- data/lib/imageboss/version.rb +1 -1
- data/spec/imageboss/client_spec.rb +12 -11
- metadata +3 -5
- data/Gemfile.lock +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ee6455671dc8650560c56a4ee50124f95c249aca5f17ff05df4788f5b02947b1
|
4
|
+
data.tar.gz: 7e35f1d19d98e1a2f9a232cc76280d26f7de20828dc9ee765afad7fef597eb20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cea525427ac649f445d43ae0032e3fb284bed2430c12ad7cfd5f096513caf99f7eb547170d18e09dfe72d1487a0b1f759a34f072ed3ccb73f1e1174c21994dc4
|
7
|
+
data.tar.gz: b1f77be4a61ed57f2f2e79601819daac6eabcb9c3d83cfa9c6e1fdf90ddb22fe0cfd0e46d57865200c785a564111d003d4bf704f6958762c1370955898923a81
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# ImageBoss Helper for Ruby
|
4
4
|
[](https://travis-ci.org/imageboss/imageboss-rb) [](https://badge.fury.io/rb/imageboss-rb)
|
5
5
|
|
6
|
-
Official Gem for
|
6
|
+
Official Gem for Generating ImageBoss URLs.
|
7
7
|
[https://imageboss.me/](https://imageboss.me/)
|
8
8
|
|
9
9
|
**Table of Contents**
|
@@ -32,32 +32,32 @@ gem install imageboss-rb
|
|
32
32
|
## Usage
|
33
33
|
### Example `Image Resizing With Cover Operation`
|
34
34
|
```ruby
|
35
|
-
client = ImageBoss::Client.new(
|
35
|
+
client = ImageBoss::Client.new(source: 'mywebsite')
|
36
36
|
|
37
37
|
image_url = client.path('/images/img01.jpg')
|
38
38
|
.operation(:cover, width: 100, height: 100)
|
39
39
|
|
40
|
-
#=> https://img.imageboss.me/cover/100x100/
|
40
|
+
#=> https://img.imageboss.me/mywebsite/cover/100x100/images/img01.jpg
|
41
41
|
```
|
42
42
|
|
43
43
|
### Example `Image Resizing With Height Operation`
|
44
44
|
```ruby
|
45
|
-
client = ImageBoss::Client.new(
|
45
|
+
client = ImageBoss::Client.new(source: 'mywebsite')
|
46
46
|
|
47
47
|
image_url = client.path('/images/img01.jpg')
|
48
48
|
.operation(:height, height: 100)
|
49
49
|
|
50
|
-
#=> https://img.imageboss.me/height/100/
|
50
|
+
#=> https://img.imageboss.me/mywebsite/height/100/images/img01.jpg
|
51
51
|
```
|
52
52
|
|
53
53
|
### Example `Image Resizing With Extra Options`
|
54
54
|
```ruby
|
55
|
-
client = ImageBoss::Client.new(
|
55
|
+
client = ImageBoss::Client.new(source: 'mywebsite')
|
56
56
|
|
57
57
|
image_url = client.path('/images/img01.jpg')
|
58
58
|
.operation(:width, width: 100, options: { grayscale: true })
|
59
59
|
|
60
|
-
#=> https://img.imageboss.me/width/100/grayscale:true/
|
60
|
+
#=> https://img.imageboss.me/width/100/grayscale:true/images/img01.jpg
|
61
61
|
```
|
62
62
|
### All operations and options for Image Resizing
|
63
63
|
It's all available on our [Official Docs](https://imageboss.me/docs).
|
@@ -67,7 +67,7 @@ If you are coding on `test`, `development` environments and don't want to send a
|
|
67
67
|
you can always disable the URL generation and the client will just fallback to the original path provided.
|
68
68
|
|
69
69
|
```ruby
|
70
|
-
client = ImageBoss::Client.new(
|
70
|
+
client = ImageBoss::Client.new(source: 'mywebsite', disabled: true)
|
71
71
|
|
72
72
|
image_url = client.path('/images/img01.jpg')
|
73
73
|
.operation(:width, width: 100, options: { grayscale: true })
|
@@ -78,6 +78,7 @@ This will give you the ability to see your image without adding extra code to ha
|
|
78
78
|
|
79
79
|
## Tested on
|
80
80
|
Ruby
|
81
|
+
- 2.6.3
|
81
82
|
- 2.5.1
|
82
83
|
- 2.4.4
|
83
84
|
- 2.3.7
|
data/lib/imageboss/client.rb
CHANGED
data/lib/imageboss/path.rb
CHANGED
@@ -3,18 +3,19 @@ module ImageBoss
|
|
3
3
|
SERVICE_URL = 'https://img.imageboss.me'.freeze
|
4
4
|
OPERATIONS = {
|
5
5
|
cover: {
|
6
|
-
recipe: '/:operation::mode/:widthx:height/:options/', required: [:width, :height]
|
6
|
+
recipe: '/:source/:operation::mode/:widthx:height/:options/', required: [:width, :height]
|
7
7
|
},
|
8
8
|
width: {
|
9
|
-
recipe: '/:operation/:width/:options/', required: [:width]
|
9
|
+
recipe: '/:source/:operation/:width/:options/', required: [:width]
|
10
10
|
},
|
11
|
-
height: { recipe: '/:operation/:height/:options/', required: [:height]},
|
12
|
-
cdn: { recipe: '/:operation/:options/', required: [] }
|
11
|
+
height: { recipe: '/:source/:operation/:height/:options/', required: [:height]},
|
12
|
+
cdn: { recipe: '/:source/:operation/:options/', required: [] }
|
13
13
|
}.freeze
|
14
14
|
|
15
15
|
def initialize(client_options, asset_path)
|
16
16
|
@client_options = client_options
|
17
|
-
@
|
17
|
+
@service_url = client_options[:service_url] || SERVICE_URL
|
18
|
+
@source = client_options[:source]
|
18
19
|
@asset_path = asset_path
|
19
20
|
end
|
20
21
|
|
@@ -34,8 +35,7 @@ module ImageBoss
|
|
34
35
|
recipe = [
|
35
36
|
SERVICE_URL,
|
36
37
|
@operation[:recipe].chomp('/'),
|
37
|
-
@
|
38
|
-
@asset_path
|
38
|
+
@asset_path.gsub(/^\/?(.+)/, "\\1")
|
39
39
|
].join
|
40
40
|
parse(recipe)
|
41
41
|
end
|
@@ -43,6 +43,7 @@ module ImageBoss
|
|
43
43
|
|
44
44
|
def parse(recipe)
|
45
45
|
recipe
|
46
|
+
.sub(':source', @source.to_s)
|
46
47
|
.sub(':operation', @operation_name.to_s)
|
47
48
|
.sub(':width', @options[:width].to_s)
|
48
49
|
.sub(':height', @options[:height].to_s)
|
data/lib/imageboss/version.rb
CHANGED
@@ -2,8 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ImageBoss::Client do
|
4
4
|
let(:service) { 'https://img.imageboss.me' }
|
5
|
+
let(:source) { 'myassets' }
|
5
6
|
let(:client_args) {{
|
6
|
-
|
7
|
+
source: source
|
7
8
|
}}
|
8
9
|
|
9
10
|
let(:operation_args) { [:cover, width: 100, height: 100] }
|
@@ -12,7 +13,7 @@ describe ImageBoss::Client do
|
|
12
13
|
|
13
14
|
context 'initialize' do
|
14
15
|
it { expect(subject.instance_variable_get(:@options)).to eq({
|
15
|
-
|
16
|
+
source: client_args[:source],
|
16
17
|
enabled: true
|
17
18
|
})
|
18
19
|
}
|
@@ -27,25 +28,25 @@ describe ImageBoss::Client do
|
|
27
28
|
let(:image_url) { path.operation(*operation_args) }
|
28
29
|
|
29
30
|
context 'cover' do
|
30
|
-
it { expect(image_url).to eq "#{service}/cover/100x100/
|
31
|
+
it { expect(image_url).to eq "#{service}/#{source}/cover/100x100/assets/img01.jpg" }
|
31
32
|
|
32
33
|
context 'with options' do
|
33
34
|
let(:operation_args) { [:cover, width: 100, height: 100, options: { grayscale: true, blur: 2.0 } ] }
|
34
|
-
it { expect(image_url).to eq "#{service}/cover/100x100/grayscale:true,blur:2.0/
|
35
|
+
it { expect(image_url).to eq "#{service}/#{source}/cover/100x100/grayscale:true,blur:2.0/assets/img01.jpg" }
|
35
36
|
end
|
36
37
|
|
37
38
|
context 'with options #2' do
|
38
39
|
let(:operation_args) { [:cover, width: 100, height: 100, options: { animation: true } ] }
|
39
|
-
it { expect(image_url).to eq "#{service}/cover/100x100/animation:true/
|
40
|
+
it { expect(image_url).to eq "#{service}/#{source}/cover/100x100/animation:true/assets/img01.jpg" }
|
40
41
|
end
|
41
42
|
|
42
43
|
context 'mode' do
|
43
44
|
let(:operation_args) { [:cover, mode: :entropy, width: 100, height: 100 ] }
|
44
|
-
it { expect(image_url).to eq "#{service}/cover:entropy/100x100/
|
45
|
+
it { expect(image_url).to eq "#{service}/#{source}/cover:entropy/100x100/assets/img01.jpg" }
|
45
46
|
|
46
47
|
context 'with options' do
|
47
48
|
let(:operation_args) { [:cover, mode: :entropy, width: 100, height: 100, options: { grayscale: true, blur: 2.0 } ] }
|
48
|
-
it { expect(image_url).to eq "#{service}/cover:entropy/100x100/grayscale:true,blur:2.0/
|
49
|
+
it { expect(image_url).to eq "#{service}/#{source}/cover:entropy/100x100/grayscale:true,blur:2.0/assets/img01.jpg" }
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -53,22 +54,22 @@ describe ImageBoss::Client do
|
|
53
54
|
|
54
55
|
context 'width' do
|
55
56
|
let(:operation_args) { [:width, width: 100 ] }
|
56
|
-
it { expect(image_url).to eq "#{service}/width/100/
|
57
|
+
it { expect(image_url).to eq "#{service}/#{source}/width/100/assets/img01.jpg" }
|
57
58
|
end
|
58
59
|
|
59
60
|
context 'height' do
|
60
61
|
let(:operation_args) { [:height, height: 200 ] }
|
61
|
-
it { expect(image_url).to eq "#{service}/height/200/
|
62
|
+
it { expect(image_url).to eq "#{service}/#{source}/height/200/assets/img01.jpg" }
|
62
63
|
end
|
63
64
|
|
64
65
|
context 'cdn' do
|
65
66
|
let(:operation_args) { [:cdn] }
|
66
|
-
it { expect(image_url).to eq "#{service}/cdn/
|
67
|
+
it { expect(image_url).to eq "#{service}/#{source}/cdn/assets/img01.jpg" }
|
67
68
|
end
|
68
69
|
|
69
70
|
fcontext 'disabled client' do
|
70
71
|
let(:client_args) {{
|
71
|
-
|
72
|
+
source: source,
|
72
73
|
enabled: false
|
73
74
|
}}
|
74
75
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imageboss-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Escobar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -35,7 +35,6 @@ files:
|
|
35
35
|
- ".rspec"
|
36
36
|
- ".travis.yml"
|
37
37
|
- Gemfile
|
38
|
-
- Gemfile.lock
|
39
38
|
- LICENSE
|
40
39
|
- README.md
|
41
40
|
- imageboss-rb.gemspec
|
@@ -64,8 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
63
|
- !ruby/object:Gem::Version
|
65
64
|
version: '0'
|
66
65
|
requirements: []
|
67
|
-
|
68
|
-
rubygems_version: 2.5.1
|
66
|
+
rubygems_version: 3.0.6
|
69
67
|
signing_key:
|
70
68
|
specification_version: 4
|
71
69
|
summary: Official Ruby Gem for generating ImageBoss URLs.
|
data/Gemfile.lock
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
imageboss-rb (1.0.3)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.3)
|
10
|
-
rspec (3.7.0)
|
11
|
-
rspec-core (~> 3.7.0)
|
12
|
-
rspec-expectations (~> 3.7.0)
|
13
|
-
rspec-mocks (~> 3.7.0)
|
14
|
-
rspec-core (3.7.1)
|
15
|
-
rspec-support (~> 3.7.0)
|
16
|
-
rspec-expectations (3.7.0)
|
17
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
18
|
-
rspec-support (~> 3.7.0)
|
19
|
-
rspec-mocks (3.7.0)
|
20
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
-
rspec-support (~> 3.7.0)
|
22
|
-
rspec-support (3.7.1)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
ruby
|
26
|
-
|
27
|
-
DEPENDENCIES
|
28
|
-
imageboss-rb!
|
29
|
-
rspec
|
30
|
-
|
31
|
-
BUNDLED WITH
|
32
|
-
1.16.0
|