imageboss-rb 1.0.0 → 1.0.1
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/Gemfile.lock +1 -3
- data/README.md +23 -5
- data/lib/imageboss/client.rb +6 -3
- data/lib/imageboss/path.rb +5 -2
- data/lib/imageboss/version.rb +1 -1
- data/spec/imageboss/client_spec.rb +15 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eec9d1afdfab1c6d949f3b94db2b975170458cdc
|
4
|
+
data.tar.gz: 16717c093fbb2e432bf27a704125c0ea4e85b78e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5a07ee9cafcef9ee1901c60d59f827b1cd5be7c824a585aaf97f1b466acc977a80c0c27bcdb0631195ce66b480561731e18e33efcf67f8840b685435612a5b5
|
7
|
+
data.tar.gz: abacadc151cebaa6485598d5cd83e397b162611e4fa2a1644a09b67ab045d2426d8d1fe63eab2ae34aaddfb2e063db4c1f14e711ac1e108132444fa13ef35bb4
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
imageboss-rb (1.0.
|
4
|
+
imageboss-rb (1.0.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
byebug (10.0.0)
|
10
9
|
diff-lcs (1.3)
|
11
10
|
rspec (3.7.0)
|
12
11
|
rspec-core (~> 3.7.0)
|
@@ -26,7 +25,6 @@ PLATFORMS
|
|
26
25
|
ruby
|
27
26
|
|
28
27
|
DEPENDENCIES
|
29
|
-
byebug
|
30
28
|
imageboss-rb!
|
31
29
|
rspec
|
32
30
|
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# ImageBoss Helper for Ruby
|
1
|
+
# ImageBoss Helper for Ruby
|
2
|
+
[](https://travis-ci.org/imageboss/imageboss-rb) [](https://badge.fury.io/rb/imageboss-rb)
|
2
3
|
|
3
4
|
Official Gem for generating ImageBoss URLs.
|
4
5
|
[https://imageboss.me/](https://imageboss.me/)
|
@@ -18,33 +19,50 @@ gem install imageboss-rb
|
|
18
19
|
## Usage
|
19
20
|
### Example `Image Resizing With Cover Operation`
|
20
21
|
```ruby
|
21
|
-
client = ImageBoss::Client.new('https://mywebsite.com')
|
22
|
+
client = ImageBoss::Client.new(domain: 'https://mywebsite.com')
|
22
23
|
|
23
24
|
image_url = client.path('/images/img01.jpg')
|
24
25
|
.operation(:cover, width: 100, height: 100)
|
26
|
+
|
25
27
|
#=> https://service.imageboss.me/cover/100x100/https://mywebsite.com/images/img01.jpg
|
26
28
|
```
|
27
29
|
|
28
30
|
### Example `Image Resizing With Height Operation`
|
29
31
|
```ruby
|
30
|
-
client = ImageBoss::Client.new('https://mywebsite.com')
|
32
|
+
client = ImageBoss::Client.new(domain: 'https://mywebsite.com')
|
31
33
|
|
32
34
|
image_url = client.path('/images/img01.jpg')
|
33
35
|
.operation(:height, height: 100)
|
36
|
+
|
34
37
|
#=> https://service.imageboss.me/height/100/https://mywebsite.com/images/img01.jpg
|
35
38
|
```
|
36
39
|
|
37
40
|
### Example `Image Resizing With Extra Options`
|
38
41
|
```ruby
|
39
|
-
client = ImageBoss::Client.new('https://mywebsite.com')
|
42
|
+
client = ImageBoss::Client.new(domain: 'https://mywebsite.com')
|
40
43
|
|
41
44
|
image_url = client.path('/images/img01.jpg')
|
42
45
|
.operation(:width, width: 100, options: { grayscale: true })
|
43
|
-
|
46
|
+
|
47
|
+
#=> https://service.imageboss.me/width/100/grayscale:true/https://mywebsite.com/images/img01.jpg
|
44
48
|
```
|
45
49
|
### All operations and options for Image Resizing
|
46
50
|
It's all available on our [Official Docs](https://imageboss.me/docs).
|
47
51
|
|
52
|
+
### Disabling URL generation
|
53
|
+
If you are coding on `test`, `development` environments and don't want to send any image to ImageBoss
|
54
|
+
you can always disable the URL generation and the client will just fallback to the original path provided.
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
client = ImageBoss::Client.new(domain: 'https://mywebsite.com', disabled: true)
|
58
|
+
|
59
|
+
image_url = client.path('/images/img01.jpg')
|
60
|
+
.operation(:width, width: 100, options: { grayscale: true })
|
61
|
+
|
62
|
+
#=> /images/img01.jpg
|
63
|
+
```
|
64
|
+
This will give you the ability to see your image without adding extra code to handle this situation.
|
65
|
+
|
48
66
|
## Tested on
|
49
67
|
Ruby
|
50
68
|
- 2.5.1
|
data/lib/imageboss/client.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module ImageBoss
|
2
2
|
class Client
|
3
|
-
def initialize(domain:)
|
4
|
-
@
|
3
|
+
def initialize(domain:, enabled: true)
|
4
|
+
@options = {
|
5
|
+
domain: domain,
|
6
|
+
enabled: enabled
|
7
|
+
}
|
5
8
|
end
|
6
9
|
|
7
10
|
def path(asset_path)
|
8
|
-
Path.new(@
|
11
|
+
Path.new(@options, asset_path)
|
9
12
|
end
|
10
13
|
end
|
11
14
|
end
|
data/lib/imageboss/path.rb
CHANGED
@@ -12,12 +12,15 @@ module ImageBoss
|
|
12
12
|
cdn: { recipe: '/:operation/:options/', required: [] }
|
13
13
|
}.freeze
|
14
14
|
|
15
|
-
def initialize(
|
16
|
-
@
|
15
|
+
def initialize(client_options, asset_path)
|
16
|
+
@client_options = client_options
|
17
|
+
@domain = client_options[:domain].chomp('/')
|
17
18
|
@asset_path = asset_path
|
18
19
|
end
|
19
20
|
|
20
21
|
def operation(name, options = {})
|
22
|
+
return @asset_path unless @client_options[:enabled]
|
23
|
+
|
21
24
|
@operation_name = name.to_sym
|
22
25
|
@options = options
|
23
26
|
@extra_options = parse_options(options[:options])
|
data/lib/imageboss/version.rb
CHANGED
@@ -11,7 +11,11 @@ describe ImageBoss::Client do
|
|
11
11
|
subject { described_class.new(**client_args) }
|
12
12
|
|
13
13
|
context 'initialize' do
|
14
|
-
it { expect(subject.instance_variable_get(:@
|
14
|
+
it { expect(subject.instance_variable_get(:@options)).to eq({
|
15
|
+
domain: client_args[:domain],
|
16
|
+
enabled: true
|
17
|
+
})
|
18
|
+
}
|
15
19
|
end
|
16
20
|
|
17
21
|
context 'path' do
|
@@ -56,5 +60,15 @@ describe ImageBoss::Client do
|
|
56
60
|
let(:operation_args) { [:cdn] }
|
57
61
|
it { expect(image_url).to eq "#{service}/cdn/https://myassets.com/assets/img01.jpg" }
|
58
62
|
end
|
63
|
+
|
64
|
+
fcontext 'disabled client' do
|
65
|
+
let(:client_args) {{
|
66
|
+
domain: 'https://myassets.com',
|
67
|
+
enabled: false
|
68
|
+
}}
|
69
|
+
|
70
|
+
let(:operation_args) { [:height, height: 200 ] }
|
71
|
+
it { expect(image_url).to eq '/assets/img01.jpg' }
|
72
|
+
end
|
59
73
|
end
|
60
74
|
end
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Escobar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|