kanoko 0.0.1 → 0.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 +4 -4
- data/.gitignore +1 -0
- data/lib/kanoko.rb +4 -4
- data/lib/kanoko/configure.rb +8 -8
- data/lib/kanoko/version.rb +1 -1
- data/test/test_configure.rb +8 -8
- data/test/test_kanoko.rb +1 -1
- metadata +2 -3
- data/Gemfile.lock +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2549a6bdda23d33eb4cded2c73a8a4404a5fd017
|
4
|
+
data.tar.gz: 36ecc1c7d224edbf0c3b82ecd3d8967da52ef741
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba78d7bd762e23ad896a6b0559d5c98dc86e13ca8d82508b19341d6c00712fcc176a7b5c4acc9a9217687782199fab70af08d8be3e0c83f2af8f5205393bb61c
|
7
|
+
data.tar.gz: 500b00d0fcda53eba841fd2903bd9038d294c1ba21d8e420470c8f3c0bd80adb72b83a166086a8c42fe949902f88c7392657045fa42b6d811ac6b231a511430e
|
data/.gitignore
CHANGED
data/lib/kanoko.rb
CHANGED
@@ -3,7 +3,7 @@ require 'kanoko/configure'
|
|
3
3
|
|
4
4
|
module Kanoko
|
5
5
|
# example:
|
6
|
-
# Kanoko.configure.
|
6
|
+
# Kanoko.configure.kanoko_host = "http://example.com"
|
7
7
|
# p Kanoko.configure #=> #<Kanoko::Configure ...>
|
8
8
|
def configure
|
9
9
|
@configure ||= Configure.new
|
@@ -15,10 +15,10 @@ module Kanoko
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def url_for(func, args, src)
|
18
|
-
if configure.
|
19
|
-
fail ConfigureError, "`
|
18
|
+
if configure.kanoko_host.nil?
|
19
|
+
fail ConfigureError, "`kanoko_host' must be set"
|
20
20
|
end
|
21
|
-
"#{configure.
|
21
|
+
"#{configure.kanoko_host}#{make_path(func, args, src)}"
|
22
22
|
end
|
23
23
|
module_function :url_for
|
24
24
|
|
data/lib/kanoko/configure.rb
CHANGED
@@ -6,20 +6,20 @@ module Kanoko
|
|
6
6
|
class Configure
|
7
7
|
attr_accessor :digest_func, :secret_key, :hash_proc
|
8
8
|
|
9
|
-
#
|
9
|
+
# kanoko_host expect String
|
10
10
|
# digest_func expect String
|
11
11
|
# secret_key expect String
|
12
12
|
# hash_proc expect Proc
|
13
13
|
#
|
14
14
|
# example:
|
15
15
|
# Kanoko.configure.tap do |c|
|
16
|
-
# c.
|
16
|
+
# c.kanoko_host = "http://example.com"
|
17
17
|
# c.digest_func = "sha1"
|
18
18
|
# c.secret_key = "secret"
|
19
19
|
# end
|
20
20
|
# Kanoko.url_for(:resize, "100x100") #=> "http://example.com/.../.../..."
|
21
21
|
def initialize
|
22
|
-
@
|
22
|
+
@kanoko_host = nil
|
23
23
|
@digest_func = nil
|
24
24
|
@secret_key = nil
|
25
25
|
@hash_proc = ->(*args){
|
@@ -34,12 +34,12 @@ module Kanoko
|
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
@
|
37
|
+
def kanoko_host=(host)
|
38
|
+
@kanoko_host = normalize_url(host)
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
@
|
41
|
+
def kanoko_host
|
42
|
+
@kanoko_host
|
43
43
|
end
|
44
44
|
|
45
45
|
private
|
@@ -53,7 +53,7 @@ module Kanoko
|
|
53
53
|
when %r{\A//}
|
54
54
|
"http:#{host}"
|
55
55
|
else
|
56
|
-
fail ConfigureError, "invalid
|
56
|
+
fail ConfigureError, "invalid kanoko_host `#{host}'"
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
data/lib/kanoko/version.rb
CHANGED
data/test/test_configure.rb
CHANGED
@@ -6,17 +6,17 @@ class TestKanokoConfigure < Minitest::Test
|
|
6
6
|
@config = Kanoko::Configure.new
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
assert_raises(Kanoko::ConfigureError) { @config.
|
9
|
+
def test_kanoko_host
|
10
|
+
assert_raises(Kanoko::ConfigureError) { @config.kanoko_host = "/example.com" }
|
11
11
|
|
12
|
-
@config.
|
13
|
-
assert_equal "http://example.com", @config.
|
12
|
+
@config.kanoko_host = "example.com"
|
13
|
+
assert_equal "http://example.com", @config.kanoko_host
|
14
14
|
|
15
|
-
@config.
|
16
|
-
assert_equal "http://example.com", @config.
|
15
|
+
@config.kanoko_host = "http://example.com"
|
16
|
+
assert_equal "http://example.com", @config.kanoko_host
|
17
17
|
|
18
|
-
@config.
|
19
|
-
assert_equal "https://example.com", @config.
|
18
|
+
@config.kanoko_host = "https://example.com"
|
19
|
+
assert_equal "https://example.com", @config.kanoko_host
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_hash_proc_by_default_error
|
data/test/test_kanoko.rb
CHANGED
@@ -5,7 +5,7 @@ class TestKanoko < Minitest::Test
|
|
5
5
|
def setup
|
6
6
|
Kanoko.configure.digest_func = "sha1"
|
7
7
|
Kanoko.configure.secret_key = "test"
|
8
|
-
Kanoko.configure.
|
8
|
+
Kanoko.configure.kanoko_host = "http://example.com"
|
9
9
|
end
|
10
10
|
|
11
11
|
def change_hash_proc(hash_proc)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanoko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -61,7 +61,6 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
63
|
- Gemfile
|
64
|
-
- Gemfile.lock
|
65
64
|
- LICENSE.txt
|
66
65
|
- Rakefile
|
67
66
|
- kanoko.gemspec
|