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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0790841cb7a280c5a75ebf642eac12cf15bb69d4
4
- data.tar.gz: 8cfadd44959a226ea1ebb3e9d71511863c40c20c
2
+ SHA256:
3
+ metadata.gz: ee6455671dc8650560c56a4ee50124f95c249aca5f17ff05df4788f5b02947b1
4
+ data.tar.gz: 7e35f1d19d98e1a2f9a232cc76280d26f7de20828dc9ee765afad7fef597eb20
5
5
  SHA512:
6
- metadata.gz: 4480371854e36b55747cb392068cdb9209d5fc3ce2e837c6179132ee25dc01b5d6d2e76855792b118ccacb3b20a1fbffd8358a53661b6be671641c5871694696
7
- data.tar.gz: 8f113dac07c66db31a4ef1c3a9a5d261e6ba1b72f1e73bb6c2ae28122e342b2d45e9aca591107a30d6dded93a1e447a52ccda112421cbab399dce527758ad236
6
+ metadata.gz: cea525427ac649f445d43ae0032e3fb284bed2430c12ad7cfd5f096513caf99f7eb547170d18e09dfe72d1487a0b1f759a34f072ed3ccb73f1e1174c21994dc4
7
+ data.tar.gz: b1f77be4a61ed57f2f2e79601819daac6eabcb9c3d83cfa9c6e1fdf90ddb22fe0cfd0e46d57865200c785a564111d003d4bf704f6958762c1370955898923a81
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.gem
2
+ Gemfile.lock
2
3
  *.rbc
3
4
  /.config
4
5
  /coverage/
data/.travis.yml CHANGED
@@ -8,10 +8,7 @@ before_install:
8
8
  script:
9
9
  - bundle exec rspec
10
10
  rvm:
11
+ - 2.7.0
12
+ - 2.6.5
11
13
  - 2.5.1
12
- - 2.4.4
13
- - 2.3.7
14
- - 2.2.7
15
- - 2.1.10
16
- - jruby-9.0.5.0
17
- - rbx-3.100
14
+ - jruby
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  # ImageBoss Helper for Ruby
4
4
  [![Build Status](https://travis-ci.org/imageboss/imageboss-rb.svg?branch=master)](https://travis-ci.org/imageboss/imageboss-rb) [![Gem Version](https://badge.fury.io/rb/imageboss-rb.svg)](https://badge.fury.io/rb/imageboss-rb)
5
5
 
6
- Official Gem for generating ImageBoss URLs.
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(domain: 'https://mywebsite.com')
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/https://mywebsite.com/images/img01.jpg
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(domain: 'https://mywebsite.com')
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/https://mywebsite.com/images/img01.jpg
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(domain: 'https://mywebsite.com')
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/https://mywebsite.com/images/img01.jpg
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(domain: 'https://mywebsite.com', disabled: true)
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
@@ -1,8 +1,8 @@
1
1
  module ImageBoss
2
2
  class Client
3
- def initialize(domain:, enabled: true)
3
+ def initialize(source:, enabled: true)
4
4
  @options = {
5
- domain: domain,
5
+ source: source,
6
6
  enabled: enabled
7
7
  }
8
8
  end
@@ -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
- @domain = client_options[:domain].chomp('/')
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
- @domain,
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)
@@ -1,3 +1,3 @@
1
1
  module ImageBoss
2
- VERSION = '1.0.3'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -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
- domain: 'https://myassets.com'
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
- domain: client_args[:domain],
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/https://myassets.com/assets/img01.jpg" }
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/https://myassets.com/assets/img01.jpg" }
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/https://myassets.com/assets/img01.jpg" }
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/https://myassets.com/assets/img01.jpg" }
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/https://myassets.com/assets/img01.jpg" }
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/https://myassets.com/assets/img01.jpg" }
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/https://myassets.com/assets/img01.jpg" }
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/https://myassets.com/assets/img01.jpg" }
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
- domain: 'https://myassets.com',
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: 1.0.3
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: 2018-05-20 00:00:00.000000000 Z
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
- rubyforge_project:
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