ires 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 023001af021142239fda30dfb1e8175965e7d88c
4
- data.tar.gz: b7680a40d6a9a75cdc543db2e74e5a3a3f87d483
3
+ metadata.gz: a0565bf2a942fa52271a911d75f8eff2472eaa57
4
+ data.tar.gz: 792f9f8516dcd41ac657c60e30de84a924f4f692
5
5
  SHA512:
6
- metadata.gz: 7a87de597b8b366c7351030ed3cd902f1b1b8f9fe9f0f62bbd6bf8a7868dbd543f31451b6b0727c1a7abf836688faa8788df5314bb700d3c251ae599ce0b180b
7
- data.tar.gz: 5b09fde65eb7f157cdc29a0f92722c279c04684995fa9c5e4c18de609582ba029ffd9a45dd669e2cf328828ba00d8ddec2f5869b1fda27be9a86b8d7e2ad4d3c
6
+ metadata.gz: dc68f28de50c7e0ce82667540c6133453b9085085146781af6f3eb7a680ecd3906ebff4060d93fa08dcfd8c8c02b5adcf3123e50731f864bec2481d88b81908d
7
+ data.tar.gz: ba4c5bd6e0fea9b8d716793f4df0df790d8e8fed2bd00ad1775db891e781cf3d2afa274c0703b4b25a09e701b8fb72fd1fac77900cb2ead58242f8368057d2f9
@@ -1,4 +1,6 @@
1
- require 'ires/engine'
2
1
  require 'ires/service'
3
2
  require 'ires/view_helper'
4
- require 'ires/util'
3
+ require 'ires/util'
4
+ ActiveSupport.on_load(:action_view) do
5
+ include Ires::ViewHelper
6
+ end
@@ -6,11 +6,11 @@ module Ires
6
6
  # Reszie image directory
7
7
  # return [none(ffi)]
8
8
  def current_os
9
- if ["darwin", "linux"].include?(os)
10
- return os
9
+ if ['darwin', 'linux'].include?(os)
10
+ os
11
11
  else
12
12
  logger.fatal "Ires is not supported by this #{os}"
13
- return nil
13
+ nil
14
14
  end
15
15
  end
16
16
 
@@ -21,15 +21,15 @@ module Ires
21
21
  host_os = RbConfig::CONFIG['host_os']
22
22
  case host_os
23
23
  when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
24
- "windows"
24
+ 'windows'
25
25
  when /darwin|mac os/
26
- "darwin"
26
+ 'darwin'
27
27
  when /linux/
28
- "linux"
28
+ 'linux'
29
29
  when /solaris|bsd/
30
- "unix"
30
+ 'unix'
31
31
  else
32
- "unknown"
32
+ 'unknown'
33
33
  end
34
34
  )
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module Ires
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -1,11 +1,12 @@
1
1
  require 'net/http'
2
+ require 'action_view/helpers'
2
3
 
3
4
  module Ires
4
5
  module ViewHelper
5
6
 
6
7
  # Image resize
7
8
  # return [image_tag]
8
- def ires_tag(path:, width:, height:, mode: "resize", expire: 30.days, **option)
9
+ def ires_tag(path:, width:, height:, mode: 'resize', expire: 30.days, **option)
9
10
  full_path = image_full_path(path.to_s)
10
11
 
11
12
  # if no image or could not find file path then perform the same action as 'image_tag'
@@ -13,25 +14,25 @@ module Ires
13
14
 
14
15
  # Expiration date (default: 7.days)
15
16
  # ex. "20170101"
16
- expiration_date = (Date.today + expire).strftime("%Y%m%d")
17
+ expiration_date = (Date.today + expire).strftime('%Y%m%d')
17
18
 
18
19
  # Reszie image
19
20
  case mode
20
- when "resize"
21
+ when 'resize'
21
22
  @image = Ires::Service.resizeImage(
22
23
  full_path,
23
24
  width,
24
25
  height,
25
26
  image_dir,
26
27
  expiration_date)
27
- when "crop"
28
+ when 'crop'
28
29
  @image = Ires::Service.cropImage(
29
30
  full_path,
30
31
  width,
31
32
  height,
32
33
  image_dir,
33
34
  expiration_date)
34
- when "resize_to_crop"
35
+ when 'resize_to_crop'
35
36
  @image = Ires::Service.resizeToCropImage(
36
37
  full_path,
37
38
  width,
@@ -50,15 +51,15 @@ module Ires
50
51
  # Reszie image directory
51
52
  # return [String]
52
53
  def image_dir
53
- @image_dir ||= Pathname.new(Rails.root).join("public").to_s
54
+ @image_dir ||= Pathname.new(Rails.root).join('public').to_s
54
55
  end
55
56
 
56
57
  def image_full_path(path)
57
58
  root = Rails.root.to_s
58
- if path.include?(root) || path.include?("http")
59
- return path
59
+ if path.include?(root) || path.include?('http')
60
+ path
60
61
  else
61
- return File.join(image_dir, path)
62
+ File.join(image_dir, path)
62
63
  end
63
64
  end
64
65
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ires
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - enta0701
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-28 00:00:00.000000000 Z
11
+ date: 2017-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 4.1.8
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 4.1.8
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -117,7 +117,6 @@ files:
117
117
  - ext/vendor/github.com/oliamb/cutter/example_test.go
118
118
  - ext/vendor/github.com/oliamb/cutter/fixtures/gopher.jpg
119
119
  - lib/ires.rb
120
- - lib/ires/engine.rb
121
120
  - lib/ires/service.rb
122
121
  - lib/ires/util.rb
123
122
  - lib/ires/version.rb
@@ -1,7 +0,0 @@
1
- module Ires
2
- class Engine < ::Rails::Engine
3
- ActiveSupport.on_load :action_view do
4
- ActionView::Base.send(:include, Ires::ViewHelper)
5
- end
6
- end
7
- end