kinu 1.0.0.alpha2 → 1.0.0.alpha3

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
2
  SHA1:
3
- metadata.gz: f710fb1988d92057b17d59ab96e5df61267f0f0c
4
- data.tar.gz: 87a017732b59fc113a2ac53c2adbfa6c5d73b856
3
+ metadata.gz: 6f46174555d31b43e3a7082e186965e0284bd092
4
+ data.tar.gz: 621be10284e1dc629701c401412f63e5d23a9c04
5
5
  SHA512:
6
- metadata.gz: d74612519aec8ef309f08d5a78b8bd75e502cafea6e34b171fdb5ae51b4084e25748f11719cc2eaeda770cb3098cfb2c10f58d41859838ffa1f1f81fdc8c9b36
7
- data.tar.gz: e162bebd3f6ef304429ffff2eb9003ccf5411f60fcdda6aec229ad56bb31694ea2e754efc797acf27af7e0cad7d3d962f858aa5a78ed69b68f998fd3edb012e3
6
+ metadata.gz: 4fb44cb947607ad80049c9e3df9be26835c548dc468f963cee3288abcc8ecec468d30f826fb0fe0994b77e26140cf89eda075b4ab64d54ec5a2a1a74f35b3b62
7
+ data.tar.gz: 841bf7d256dece209fe375aaec7028078ad944d2fd249f2f262b35f4cf0bde7d7251c933654ef02f96232b0087fb234afcff53bf2c6bbefc8a179da96033b8dd
data/.gitignore CHANGED
@@ -7,3 +7,87 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /spec/examples.txt
11
+
12
+ ### https://raw.github.com/github/gitignore/58d953f03f9b9eb2ec160fe320f9041141dc8b31/Global/macOS.gitignore
13
+
14
+ *.DS_Store
15
+ .AppleDouble
16
+ .LSOverride
17
+
18
+ # Icon must end with two \r
19
+ Icon
20
+
21
+
22
+ # Thumbnails
23
+ ._*
24
+
25
+ # Files that might appear in the root of a volume
26
+ .DocumentRevisions-V100
27
+ .fseventsd
28
+ .Spotlight-V100
29
+ .TemporaryItems
30
+ .Trashes
31
+ .VolumeIcon.icns
32
+ .com.apple.timemachine.donotpresent
33
+
34
+ # Directories potentially created on remote AFP share
35
+ .AppleDB
36
+ .AppleDesktop
37
+ Network Trash Folder
38
+ Temporary Items
39
+ .apdisk
40
+
41
+
42
+ ### https://raw.github.com/github/gitignore/58d953f03f9b9eb2ec160fe320f9041141dc8b31/ruby.gitignore
43
+
44
+ *.gem
45
+ *.rbc
46
+ /.config
47
+ /coverage/
48
+ /InstalledFiles
49
+ /pkg/
50
+ /spec/reports/
51
+ /spec/examples.txt
52
+ /test/tmp/
53
+ /test/version_tmp/
54
+ /tmp/
55
+
56
+ # Used by dotenv library to load environment variables.
57
+ # .env
58
+
59
+ ## Specific to RubyMotion:
60
+ .dat*
61
+ .repl_history
62
+ build/
63
+ *.bridgesupport
64
+ build-iPhoneOS/
65
+ build-iPhoneSimulator/
66
+
67
+ ## Specific to RubyMotion (use of CocoaPods):
68
+ #
69
+ # We recommend against adding the Pods directory to your .gitignore. However
70
+ # you should judge for yourself, the pros and cons are mentioned at:
71
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
72
+ #
73
+ # vendor/Pods/
74
+
75
+ ## Documentation cache and generated files:
76
+ /.yardoc/
77
+ /_yardoc/
78
+ /doc/
79
+ /rdoc/
80
+
81
+ ## Environment normalization:
82
+ /.bundle/
83
+ /vendor/bundle
84
+ /lib/bundler/man/
85
+
86
+ # for a library or gem, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # Gemfile.lock
89
+ # .ruby-version
90
+ # .ruby-gemset
91
+
92
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
93
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Kinu ruby client
2
2
 
3
- [Kinu](https://github.com/TakatoshiMaeda/kinu) ruby client
3
+ [Kinu](https://github.com/tokubai/kinu) ruby client
4
4
 
5
5
  ## Installation
6
6
 
@@ -16,7 +16,7 @@ And then execute:
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install kinu
19
+ $ gem install kinu --pre
20
20
 
21
21
  ## Usage
22
22
 
@@ -31,10 +31,10 @@ end
31
31
 
32
32
  resource = Kinu::Resource.new(:foods, 1)
33
33
  resource.upload(open('/path/to/image.jpg'))
34
- resource.uri(width: 280, height: 300) # => #<URI::HTTP http://127.0.0.1/images/foods/w=280,h=300/1.jpg>
34
+ resource.uri(width: 280, height: 300) # => #<URI::HTTP https://127.0.0.1/images/foods/w=280,h=300/1.jpg>
35
35
 
36
36
  sandbox = Kinu::Sandbox.upload(open('/path/to/image.jpg'))
37
- sandbox.uri(width: 280, height: 300) # => #<URI::HTTP http://192.168.99.100:5001/images/__sandbox__/w=280,h=300/1abd5e51-2ba4-43e5-a355-c2abee318d3f.jpg>
37
+ sandbox.uri(width: 280, height: 300) # => #<URI::HTTP https://192.168.99.100:5001/images/__sandbox__/w=280,h=300/1abd5e51-2ba4-43e5-a355-c2abee318d3f.jpg>
38
38
  sandbox.attach_to(:foods, 1) # => #<Kinu::Resource:0x007fa4538098b0 @id="1", @name="foods">
39
39
  ```
40
40
 
data/kinu.gemspec CHANGED
@@ -29,4 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "bundler", "~> 1.11"
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
31
  spec.add_development_dependency "pry"
32
+ spec.add_development_dependency "rspec", "~> 3.4"
33
+ spec.add_development_dependency "webmock", "~> 2.3"
32
34
  end
data/lib/kinu.rb CHANGED
@@ -8,8 +8,14 @@ module Kinu
8
8
  USER_AGENT = "KinuRubyClient/#{Kinu::VERSION}".freeze
9
9
 
10
10
  def self.base_uri
11
- raise "Kinu.config.host is not set." if config.host.empty?
12
- URI::HTTP.build(scheme: config.scheme, host: config.host, port: config.port)
11
+ raise "Kinu.config.host is not set." unless config.host
12
+ http_class.build(host: config.host, port: config.port)
13
+ end
14
+
15
+ def self.base_upload_uri
16
+ host = config.upload_host || config.host
17
+ raise "Kinu.config.upload_host and Kinu.config.upload_host is not set. Please set one or the other." unless host
18
+ http_class.build(host: host, port: config.port)
13
19
  end
14
20
 
15
21
  def self.configure
@@ -19,4 +25,10 @@ module Kinu
19
25
  def self.config
20
26
  @config ||= Configuration.new
21
27
  end
28
+
29
+ private
30
+
31
+ def self.http_class
32
+ config.ssl? ? URI::HTTPS : URI::HTTP
33
+ end
22
34
  end
@@ -1,9 +1,13 @@
1
1
  module Kinu
2
2
  class Configuration
3
- attr_writer :host, :port, :ssl
3
+ attr_writer :host, :upload_host, :port, :ssl
4
4
 
5
5
  def host
6
- @host || ""
6
+ @host
7
+ end
8
+
9
+ def upload_host
10
+ @upload_host
7
11
  end
8
12
 
9
13
  def port
data/lib/kinu/geometry.rb CHANGED
@@ -7,18 +7,36 @@ module Kinu
7
7
  crop: :c,
8
8
  original: :o,
9
9
  middle: :m,
10
+ manual_crop: :mc,
11
+ width_offset: :wo,
12
+ height_offset: :ho,
13
+ crop_width: :cw,
14
+ crop_height: :ch,
15
+ assumption_width: :aw,
10
16
  }.freeze
11
17
 
12
18
  def initialize(options)
13
19
  @options = options
20
+ validate
14
21
  end
15
22
 
16
- def empty?
17
- @options.empty?
23
+ def validate
24
+ raise ArgumentError, "required geometry hash." if empty?
25
+
26
+ return if !(@options[:width].nil? && @options[:height].nil?)
27
+ return if @options[:middle] == true
28
+ return if @options[:original] == true
29
+
30
+ raise ArgumentError, <<~EOS
31
+ invalid geometry, geometry must be met least one condition.
32
+ - set width or height any numeric.
33
+ - set middle true.
34
+ - set original true.
35
+ EOS
18
36
  end
19
37
 
20
- def valid?
21
- !(@options[:width].nil? && @options[:height].nil?)
38
+ def empty?
39
+ @options.empty?
22
40
  end
23
41
 
24
42
  def to_s
@@ -3,15 +3,16 @@ require 'kinu/errors'
3
3
 
4
4
  module Kinu
5
5
  class HttpClient
6
- def self.post(path, params)
7
- new(:post, path, params).run
6
+ def self.post(base_uri, path, params)
7
+ new(base_uri, :post, path, params).run
8
8
  end
9
9
 
10
- def self.multipart_post(path, params)
11
- new(:post, path, params, multipart: true).run
10
+ def self.multipart_post(base_uri, path, params)
11
+ new(base_uri, :post, path, params, multipart: true).run
12
12
  end
13
13
 
14
- def initialize(method, path, params, multipart: false)
14
+ def initialize(base_uri, method, path, params, multipart: false)
15
+ @base_uri = base_uri
15
16
  @method = method
16
17
  @path = path
17
18
  @params = params
@@ -40,7 +41,7 @@ module Kinu
40
41
  private
41
42
 
42
43
  def connection
43
- Faraday::Connection.new(Kinu.base_uri) do |builder|
44
+ Faraday::Connection.new(@base_uri) do |builder|
44
45
  builder.request :multipart if @multipart
45
46
  builder.request :url_encoded
46
47
  builder.adapter :net_http
data/lib/kinu/resource.rb CHANGED
@@ -6,6 +6,7 @@ module Kinu
6
6
  class Resource < ResourceBase
7
7
  def upload(file)
8
8
  Kinu::HttpClient.multipart_post(
9
+ Kinu.base_upload_uri,
9
10
  '/upload',
10
11
  {
11
12
  name: @name,
@@ -17,7 +18,7 @@ module Kinu
17
18
  end
18
19
 
19
20
  def attach_from_sandbox(sandbox_id)
20
- Sandbox.attach(@name, @id, sandbox_id)
21
+ Sandbox.attach(Kinu.base_upload_uri, @name, @id, sandbox_id)
21
22
  end
22
23
  end
23
24
  end
@@ -25,8 +25,6 @@ module Kinu
25
25
  private
26
26
 
27
27
  def build_path(geometry, format)
28
- raise ArgumentError, "required geometry hash." if geometry.empty?
29
- raise ArgumentError, "invalid geometry, height or width is required." unless geometry.valid?
30
28
  "/images/#{@name}/#{geometry}/#{@id}.#{format}"
31
29
  end
32
30
 
data/lib/kinu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kinu
2
- VERSION = "1.0.0.alpha2"
2
+ VERSION = "1.0.0.alpha3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kinu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha2
4
+ version: 1.0.0.alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takatoshi Maeda
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-14 00:00:00.000000000 Z
11
+ date: 2017-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.3'
69
97
  description: image server kinu ruby client
70
98
  email:
71
99
  - me@tmd.tw
@@ -74,6 +102,7 @@ extensions: []
74
102
  extra_rdoc_files: []
75
103
  files:
76
104
  - ".gitignore"
105
+ - ".rspec"
77
106
  - ".travis.yml"
78
107
  - Gemfile
79
108
  - README.md
@@ -110,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
139
  version: 1.3.1
111
140
  requirements: []
112
141
  rubyforge_project:
113
- rubygems_version: 2.4.5
142
+ rubygems_version: 2.5.1
114
143
  signing_key:
115
144
  specification_version: 4
116
145
  summary: image server kinu ruby client