imageboss-rails 1.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0d05888e20d6047a9dd79f40f544ff87c3e27fbc
4
+ data.tar.gz: a24f3d72df1ddb7caa346b32db7a7e0f532ed0fd
5
+ SHA512:
6
+ metadata.gz: 2afa504604727ea5664085039dbd8ea59d3c8ea41c3c21ecd9683e3577ec5d9ea055204199f441896a7a066b4870e5afa480577fa41cdc81fcd6b109cb696839
7
+ data.tar.gz: 571c0b6995f0f1220817f779fff2a19d8f946885965727fdfa4033ac78eab63d5612665a14f42896067d91971f2a58ca93697bd3705f29e7b8720467c4dd6926
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Igor Escobar
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,127 @@
1
+ [![ImageBoss logo](https://service.imageboss.me/width/180/https://imageboss.me/emails/logo-2@2x.png)](https://imageboss.me)
2
+
3
+ # ImageBoss Helper for Ruby On Rails
4
+ [![Build Status](https://travis-ci.org/imageboss/imageboss-rails.svg?branch=master)](https://travis-ci.org/imageboss/imageboss-rails) [![Gem Version](https://badge.fury.io/rb/imageboss-rails.svg)](https://badge.fury.io/rb/imageboss-rails)
5
+
6
+ Official Gem for generating ImageBoss URLs with Ruby On Rails. It's built on top of [imageboss-rb](https://github.com/imageboss/imageboss-rails)
7
+ to offer rails specific features.
8
+
9
+ [ImageBoss](https://imageboss.me/) is a service designed to handle on-demand image processing with content aware recognition, progressive scans, compression, CDN and more.
10
+
11
+ We recommend using something like [Paperclip](https://github.com/thoughtbot/paperclip), [Refile](https://github.com/refile/refile), [Carrierwave](https://github.com/carrierwaveuploader/carrierwave), or [s3_direct_upload](https://github.com/waynehoover/s3_direct_upload) to handle uploads and make them available. After they've been uploaded, you can then serve them using this gem or you can't disable ImageBoss for spacific environments. Read on.
12
+
13
+ **Table of Contents**
14
+ - [ImageBoss Helper for Ruby On Rails](#imageboss-helper-for-ruby-on-rails)
15
+ - [Installation](#installation)
16
+ - [Usage](#usage)
17
+ - [Configuration](#configuration)
18
+ - [Same configuration across all environemnts](#same-configuration-across-all-environemnts)
19
+ - [imageboss_tag](#imageboss_tag)
20
+ - [Native Rails image_tag options](#native-rails-image_tag-options)
21
+ - [imageboss_url](#imageboss_url)
22
+ - [Usage in Sprockets](#usage-in-sprockets)
23
+ - [Disable ImageBoss URL on specific environments](#disable-imageboss-url-on-specific-environments)
24
+ - [Compatibility](#compatibility)
25
+
26
+ ## Installation
27
+ Just run the following:
28
+ ```bash
29
+ $ bundle add imageboss-rails
30
+ ```
31
+
32
+ Or install it yourself as:
33
+ ```bash
34
+ $ gem install imageboss-rails
35
+ ```
36
+
37
+ ## Usage
38
+ `imageboss-rails` provide you a few helpers to make the integration easier. To know all operations and options available please read the [ImageBoss Docs](https://imageboss.me/docs).
39
+
40
+ ### Configuration
41
+ #### Same configuration across all environemnts
42
+ Just add the following to `app/config/application.rb`:
43
+
44
+ ```ruby
45
+ Rails.application.configure do
46
+ config.imageboss.source = "https://assets.mywebsite.com"
47
+ end
48
+ ```
49
+
50
+ ### imageboss_tag
51
+ Just like the Rails' [image_tag](https://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_tag) it will generate an `<img>` tag for you - but wrapped by the ImageBoss gem adding some more functionalities. The syntax is the following:
52
+ ```ruby
53
+ <%= imageboss_tag('my-nice-image', :cover, { width: 100, height: 100 }) %>
54
+ ```
55
+ Will output the following:
56
+ ```html
57
+ <img
58
+ alt="my-nice-image"
59
+ src="https://service.imageboss.me/cover/100x100/https://assets.mywebsite.com/assets/my-nice-image.jpg"
60
+ />
61
+ ```
62
+
63
+ ### Native Rails image_tag options
64
+ If you want to provide native `image_url` helper options just add them to the end of the helper:
65
+ ```ruby
66
+ <%= imageboss_tag('my-nice-image', :cover, { width: 100, height: 100 }, alt: "Sunny Lisbon!") %>
67
+ ```
68
+ Will output the following:
69
+ ```html
70
+ <img
71
+ alt="Sunny Lisbon!"
72
+ src="https://service.imageboss.me/cover/100x100/https://assets.mywebsite.com/assets/my-nice-image.jpg"
73
+ />
74
+ ```
75
+
76
+ ### imageboss_url
77
+ Just like Rails' [asset_url](https://apidock.com/rails/ActionView/Helpers/AssetUrlHelper/asset_url) but it will output your `path` with a fully valid ImageBoss URL.
78
+ ```ruby
79
+ <%= imageboss_url('my-nice-image', :width, { width: 100 }) %>
80
+ ```
81
+ Will output the following:
82
+ ```
83
+ https://service.imageboss.me/width/100/https://assets.mywebsite.com/assets/my-nice-image.jpg
84
+ ```
85
+
86
+ ### Usage in Sprockets
87
+
88
+ `imageboss_url` is also pulled in as a Sprockets helper, so you can generate ImageBoss URLs in your asset pipeline files. For example, here's how it would work inside an `.scss.erb` file:
89
+
90
+ ```scss
91
+ .user-profile {
92
+ background-image: url(<%= imageboss_url('a-nice-profile.svg', :cover, { width: 400, height: 300 }) %>);
93
+ }
94
+ ```
95
+
96
+ ### Disable ImageBoss URL on specific environments
97
+ If on `development` or `test` environment you are not sending images to the cloud you can disable the generation of ImageBoss URLs for thos environment. For example, if you want to disable on `development`, just add the following to your `config/environments/development.rb` file.
98
+
99
+ ```ruby
100
+ config.imageboss.enabled = false
101
+ ```
102
+ With this configured in all places you call `imageboss_url` or `imageboss_tag` the `src` or the `url` generated will fallback straight to your localhost images. For example instead of generating this URL:
103
+ ```
104
+ https://service.imageboss.me/cover/100x100/https://assets.mywebsite.com/assets/my-nice-image.jpg
105
+ ```
106
+ it will output this:
107
+ ```
108
+ http://localhost:3000/assets/my-nice-image.jpg
109
+ ```
110
+ This is nice because you won't need to add any extra code to handle this yourself.
111
+
112
+ ## Compatibility
113
+ Rails
114
+ - 5
115
+ - 4
116
+
117
+ Ruby
118
+ - 2.4.x
119
+ - 2.3.x
120
+ - 2.2.x
121
+ - 2.1.x
122
+
123
+ jRuby
124
+ - jruby-9.0.5.x
125
+
126
+ Rubinius
127
+ - rbx-3.x
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'bundler/gem_tasks'
8
+ require 'rake/testtask'
9
+
10
+ Rake::TestTask.new(:test) do |t|
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ task default: :test
@@ -0,0 +1,24 @@
1
+ module ImageBoss
2
+ module Rails
3
+ module UrlHelper
4
+ include ActionView::Helpers
5
+
6
+ def imageboss_url(path, operation, options)
7
+ imageboss_client
8
+ .path(image_path(path))
9
+ .operation(operation, options)
10
+ .html_safe
11
+ end
12
+
13
+ private
14
+
15
+ def imageboss_client
16
+ config = ::ImageBoss::Rails.config.imageboss || {}
17
+ client_options = {}
18
+ client_options[:domain] = config[:asset_host]
19
+ client_options[:enabled] = config[:enabled] unless config[:enabled].nil?
20
+ @imageboss_client = ::ImageBoss::Client.new(**client_options)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ module ImageBoss
2
+ module Rails
3
+ VERSION = '1.0.2'
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ module ImageBoss
2
+ module Rails
3
+ module ViewHelper
4
+ include ActionView::Helpers
5
+ include ImageBoss::Rails::UrlHelper
6
+
7
+ def imageboss_tag(path, operation, options, image_opts = {})
8
+ image_url = imageboss_url(asset_path(path), operation.to_sym, options)
9
+ image_tag(image_url, image_opts)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ require 'imageboss'
2
+ require 'imageboss/railtie' if defined? Rails::Railtie
3
+
4
+ module ImageBoss
5
+ module Rails
6
+ class Config < ::ActiveSupport::OrderedOptions; end
7
+
8
+ def self.config
9
+ @config ||= Config.new
10
+ end
11
+
12
+ def self.configure
13
+ yield config
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ require 'rails'
2
+ require 'rails/railtie'
3
+ require 'imageboss/rails'
4
+ require 'imageboss/rails/url_helper'
5
+ require 'imageboss/rails/view_helper'
6
+
7
+ module ImageBoss
8
+ module Rails
9
+ class Railtie < ::Rails::Railtie
10
+ config.imageboss = ActiveSupport::OrderedOptions.new
11
+
12
+ initializer 'imageboss-rails.view_helper' do |app|
13
+ ImageBoss::Rails.configure do |config|
14
+ config.imageboss = app.config.imageboss
15
+ end
16
+
17
+ ActionView::Base.send :include, ViewHelper
18
+ Sprockets::Context.send :include, UrlHelper if defined? Sprockets
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :imageboss_rails do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: imageboss-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Igor Escobar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.1.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.1.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: imageboss-rb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Official Ruby On Rails gem for generating ImageBoss URLs
56
+ email:
57
+ - igor@imageboss.me
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - lib/imageboss/rails.rb
66
+ - lib/imageboss/rails/url_helper.rb
67
+ - lib/imageboss/rails/version.rb
68
+ - lib/imageboss/rails/view_helper.rb
69
+ - lib/imageboss/railtie.rb
70
+ - lib/tasks/imageboss/rails_tasks.rake
71
+ homepage: https://imageboss.me
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.5.1
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Generate ImageBoss URLs with Ruby on Rails
95
+ test_files: []