ires 0.1.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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +111 -0
  4. data/Rakefile +30 -0
  5. data/ext/Gopkg.lock +21 -0
  6. data/ext/Gopkg.toml +30 -0
  7. data/ext/main.go +90 -0
  8. data/ext/operate/image.go +139 -0
  9. data/ext/util/uri/uri.go +96 -0
  10. data/ext/vendor/github.com/nfnt/resize/LICENSE +13 -0
  11. data/ext/vendor/github.com/nfnt/resize/README.md +149 -0
  12. data/ext/vendor/github.com/nfnt/resize/converter.go +438 -0
  13. data/ext/vendor/github.com/nfnt/resize/converter_test.go +43 -0
  14. data/ext/vendor/github.com/nfnt/resize/filters.go +143 -0
  15. data/ext/vendor/github.com/nfnt/resize/nearest.go +318 -0
  16. data/ext/vendor/github.com/nfnt/resize/nearest_test.go +57 -0
  17. data/ext/vendor/github.com/nfnt/resize/resize.go +614 -0
  18. data/ext/vendor/github.com/nfnt/resize/resize_test.go +330 -0
  19. data/ext/vendor/github.com/nfnt/resize/thumbnail.go +55 -0
  20. data/ext/vendor/github.com/nfnt/resize/thumbnail_test.go +47 -0
  21. data/ext/vendor/github.com/nfnt/resize/ycc.go +227 -0
  22. data/ext/vendor/github.com/nfnt/resize/ycc_test.go +214 -0
  23. data/ext/vendor/github.com/oliamb/cutter/LICENSE +20 -0
  24. data/ext/vendor/github.com/oliamb/cutter/README.md +88 -0
  25. data/ext/vendor/github.com/oliamb/cutter/benchmark_test.go +54 -0
  26. data/ext/vendor/github.com/oliamb/cutter/cutter.go +183 -0
  27. data/ext/vendor/github.com/oliamb/cutter/cutter/main.go +68 -0
  28. data/ext/vendor/github.com/oliamb/cutter/cutter_test.go +267 -0
  29. data/ext/vendor/github.com/oliamb/cutter/example_test.go +35 -0
  30. data/ext/vendor/github.com/oliamb/cutter/fixtures/gopher.jpg +0 -0
  31. data/lib/ires.rb +4 -0
  32. data/lib/ires/engine.rb +7 -0
  33. data/lib/ires/service.rb +19 -0
  34. data/lib/ires/util.rb +39 -0
  35. data/lib/ires/version.rb +3 -0
  36. data/lib/ires/view_helper.rb +42 -0
  37. data/lib/tasks/ires.rake +11 -0
  38. data/shared/darwin/ires.h +64 -0
  39. data/shared/darwin/ires.so +0 -0
  40. data/shared/linux/ires.h +64 -0
  41. data/shared/linux/ires.so +0 -0
  42. metadata +154 -0
@@ -0,0 +1,3 @@
1
+ module Ires
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,42 @@
1
+ module Ires
2
+ module ViewHelper
3
+
4
+ # Image resize
5
+ # return [image_tag]
6
+ def ires_tag(path:, width:, height:, mode: "resize", **option)
7
+ full_path = image_full_path(path.to_s)
8
+
9
+ # Reszie image
10
+ case mode
11
+ when "resize"
12
+ @image = Ires::Service.resizeImage(full_path, width, height, image_dir)
13
+ when "crop"
14
+ @image = Ires::Service.cropImage(full_path, width, height, image_dir)
15
+ when "resize_to_crop"
16
+ @image = Ires::Service.resizeToCropImage(full_path, width, height, image_dir)
17
+ end
18
+
19
+ return nil if @image.nil?
20
+
21
+ # Set image_tag
22
+ image_tag(@image, option)
23
+ end
24
+
25
+ private
26
+ # Reszie image directory
27
+ # return [String]
28
+ def image_dir
29
+ @image_dir ||= Pathname.new(Rails.root).join("public").to_s
30
+ end
31
+
32
+ def image_full_path(path)
33
+ root = Rails.root.to_s
34
+ if path.include?(root) || path.include?("http")
35
+ return path
36
+ else
37
+ return File.join(image_dir, path)
38
+ end
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,11 @@
1
+ require 'rbconfig'
2
+ require 'ires/util'
3
+
4
+ desc "Build shared object"
5
+ namespace :ires do
6
+ task :build do
7
+ os = Ires::Util.current_os
8
+ return if os.nil?
9
+ exec "CGO_ENABLED=1 GOOS=\"#{os}\" go build -v -buildmode=c-shared -o shared/\"#{os}\"/ires.so ext/main.go"
10
+ end
11
+ end
@@ -0,0 +1,64 @@
1
+ /* Created by "go tool cgo" - DO NOT EDIT. */
2
+
3
+ /* package command-line-arguments */
4
+
5
+ /* Start of preamble from import "C" comments. */
6
+
7
+
8
+
9
+
10
+ /* End of preamble from import "C" comments. */
11
+
12
+
13
+ /* Start of boilerplate cgo prologue. */
14
+ #line 1 "cgo-gcc-export-header-prolog"
15
+
16
+ #ifndef GO_CGO_PROLOGUE_H
17
+ #define GO_CGO_PROLOGUE_H
18
+
19
+ typedef signed char GoInt8;
20
+ typedef unsigned char GoUint8;
21
+ typedef short GoInt16;
22
+ typedef unsigned short GoUint16;
23
+ typedef int GoInt32;
24
+ typedef unsigned int GoUint32;
25
+ typedef long long GoInt64;
26
+ typedef unsigned long long GoUint64;
27
+ typedef GoInt64 GoInt;
28
+ typedef GoUint64 GoUint;
29
+ typedef __SIZE_TYPE__ GoUintptr;
30
+ typedef float GoFloat32;
31
+ typedef double GoFloat64;
32
+ typedef float _Complex GoComplex64;
33
+ typedef double _Complex GoComplex128;
34
+
35
+ /*
36
+ static assertion to make sure the file is being used on architecture
37
+ at least with matching size of GoInt.
38
+ */
39
+ typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
40
+
41
+ typedef struct { const char *p; GoInt n; } GoString;
42
+ typedef void *GoMap;
43
+ typedef void *GoChan;
44
+ typedef struct { void *t; void *v; } GoInterface;
45
+ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
46
+
47
+ #endif
48
+
49
+ /* End of boilerplate cgo prologue. */
50
+
51
+ #ifdef __cplusplus
52
+ extern "C" {
53
+ #endif
54
+
55
+
56
+ extern char* resizeImage(char* p0, GoInt p1, GoInt p2, char* p3);
57
+
58
+ extern char* cropImage(char* p0, GoInt p1, GoInt p2, char* p3);
59
+
60
+ extern char* resizeToCropImage(char* p0, GoInt p1, GoInt p2, char* p3);
61
+
62
+ #ifdef __cplusplus
63
+ }
64
+ #endif
Binary file
@@ -0,0 +1,64 @@
1
+ /* Created by "go tool cgo" - DO NOT EDIT. */
2
+
3
+ /* package command-line-arguments */
4
+
5
+ /* Start of preamble from import "C" comments. */
6
+
7
+
8
+
9
+
10
+ /* End of preamble from import "C" comments. */
11
+
12
+
13
+ /* Start of boilerplate cgo prologue. */
14
+ #line 1 "cgo-gcc-export-header-prolog"
15
+
16
+ #ifndef GO_CGO_PROLOGUE_H
17
+ #define GO_CGO_PROLOGUE_H
18
+
19
+ typedef signed char GoInt8;
20
+ typedef unsigned char GoUint8;
21
+ typedef short GoInt16;
22
+ typedef unsigned short GoUint16;
23
+ typedef int GoInt32;
24
+ typedef unsigned int GoUint32;
25
+ typedef long long GoInt64;
26
+ typedef unsigned long long GoUint64;
27
+ typedef GoInt64 GoInt;
28
+ typedef GoUint64 GoUint;
29
+ typedef __SIZE_TYPE__ GoUintptr;
30
+ typedef float GoFloat32;
31
+ typedef double GoFloat64;
32
+ typedef float _Complex GoComplex64;
33
+ typedef double _Complex GoComplex128;
34
+
35
+ /*
36
+ static assertion to make sure the file is being used on architecture
37
+ at least with matching size of GoInt.
38
+ */
39
+ typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
40
+
41
+ typedef struct { const char *p; GoInt n; } GoString;
42
+ typedef void *GoMap;
43
+ typedef void *GoChan;
44
+ typedef struct { void *t; void *v; } GoInterface;
45
+ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
46
+
47
+ #endif
48
+
49
+ /* End of boilerplate cgo prologue. */
50
+
51
+ #ifdef __cplusplus
52
+ extern "C" {
53
+ #endif
54
+
55
+
56
+ extern char* resizeImage(char* p0, GoInt p1, GoInt p2, char* p3);
57
+
58
+ extern char* cropImage(char* p0, GoInt p1, GoInt p2, char* p3);
59
+
60
+ extern char* resizeToCropImage(char* p0, GoInt p1, GoInt p2, char* p3);
61
+
62
+ #ifdef __cplusplus
63
+ }
64
+ #endif
Binary file
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ires
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - enta0701
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 5.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 5.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake-compiler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Ires is image resizer gem.
84
+ email:
85
+ - endo.takuya.0701@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - LICENSE
91
+ - README.md
92
+ - Rakefile
93
+ - ext/Gopkg.lock
94
+ - ext/Gopkg.toml
95
+ - ext/main.go
96
+ - ext/operate/image.go
97
+ - ext/util/uri/uri.go
98
+ - ext/vendor/github.com/nfnt/resize/LICENSE
99
+ - ext/vendor/github.com/nfnt/resize/README.md
100
+ - ext/vendor/github.com/nfnt/resize/converter.go
101
+ - ext/vendor/github.com/nfnt/resize/converter_test.go
102
+ - ext/vendor/github.com/nfnt/resize/filters.go
103
+ - ext/vendor/github.com/nfnt/resize/nearest.go
104
+ - ext/vendor/github.com/nfnt/resize/nearest_test.go
105
+ - ext/vendor/github.com/nfnt/resize/resize.go
106
+ - ext/vendor/github.com/nfnt/resize/resize_test.go
107
+ - ext/vendor/github.com/nfnt/resize/thumbnail.go
108
+ - ext/vendor/github.com/nfnt/resize/thumbnail_test.go
109
+ - ext/vendor/github.com/nfnt/resize/ycc.go
110
+ - ext/vendor/github.com/nfnt/resize/ycc_test.go
111
+ - ext/vendor/github.com/oliamb/cutter/LICENSE
112
+ - ext/vendor/github.com/oliamb/cutter/README.md
113
+ - ext/vendor/github.com/oliamb/cutter/benchmark_test.go
114
+ - ext/vendor/github.com/oliamb/cutter/cutter.go
115
+ - ext/vendor/github.com/oliamb/cutter/cutter/main.go
116
+ - ext/vendor/github.com/oliamb/cutter/cutter_test.go
117
+ - ext/vendor/github.com/oliamb/cutter/example_test.go
118
+ - ext/vendor/github.com/oliamb/cutter/fixtures/gopher.jpg
119
+ - lib/ires.rb
120
+ - lib/ires/engine.rb
121
+ - lib/ires/service.rb
122
+ - lib/ires/util.rb
123
+ - lib/ires/version.rb
124
+ - lib/ires/view_helper.rb
125
+ - lib/tasks/ires.rake
126
+ - shared/darwin/ires.h
127
+ - shared/darwin/ires.so
128
+ - shared/linux/ires.h
129
+ - shared/linux/ires.so
130
+ homepage: https://github.com/endotakuya/ires
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.6.8
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Ires is image resizer gem.
154
+ test_files: []