KonaLast 0.0.3 → 0.0.4
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 +15 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/KonaLast-0.0.3.gem +0 -0
- data/KonaLast.gemspec +1 -0
- data/README.md +2 -0
- data/checksum/KonaLast-0.0.3.gem.sha512 +1 -0
- data/lib/KonaLast.rb +32 -5
- data/lib/KonaLast/version.rb +1 -1
- metadata +6 -8
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YTYyYTI4MjU3YjJjZjdlYzk2YjcwMDIxYzNiNDQyOWNmODRiOGRlNw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDM2NzBhYTA0NDc2YTg0YWYzZTNlYTI1MjUwNDA3ZjgxNDI1NDBhMQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MjY3YzQ3ZjFiYTFkYzA5ZjQwZmMwN2M2NTY4MmZjMDU5MTFmM2VjZGUyNGRl
|
10
|
+
M2ZlZWM4ZWYxMTgxZDhkOWZlZmRiNGRkZmYwOWQ4YWUyMmNmYjQ2ZWEzZDJi
|
11
|
+
YjZmMmNmNzVjYWMyMzdkOGIyOTEwZjg4NGNiNWM5ZmJiMjQ3MTM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NmJmYTA3Nzk0ZWNjYWViNWM1ODQwOTRjNmQ4OWEyNzdhNTIyZmZmYjQ2ZDJj
|
14
|
+
MDYyODlkZDQ1YThjYmI1OTYwNzVkM2QyNzZjYjg3NDI2MzJkYzI0MDY4Zjg3
|
15
|
+
NTNkMjMxMmNjYjc0MjZjMWI0YjEyZWJkYzA1NDFhMTFlZmUxM2M=
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/KonaLast-0.0.3.gem
ADDED
Binary file
|
data/KonaLast.gemspec
CHANGED
data/README.md
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
1edd99a295ef8bd528f0a67d20d9e55104bc9e2e46b3a23ded009f854b35c98ce060789abb7c35c592f79f2762aa43bcb8b7731efa79a9f56ea9cafc803210d7
|
data/lib/KonaLast.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'net/https'
|
2
3
|
require 'json'
|
3
|
-
|
4
|
+
# require 'slop'
|
5
|
+
# too easy
|
6
|
+
# require 'googl'
|
4
7
|
module KonaLast
|
5
8
|
class Utils
|
9
|
+
|
10
|
+
# return [Hash] with options
|
6
11
|
def options(limit, url='http://konachan.com/post.json')
|
7
12
|
if limit.nil?
|
8
13
|
num = '100'
|
@@ -14,32 +19,54 @@ module KonaLast
|
|
14
19
|
num = limit
|
15
20
|
end
|
16
21
|
end
|
17
|
-
|
18
22
|
{
|
19
23
|
:api => URI(url),
|
20
24
|
:limit => num
|
21
25
|
}
|
22
26
|
end
|
23
27
|
|
28
|
+
# @return [Hash] translated from JSON
|
24
29
|
def translate(json)
|
25
30
|
JSON.parse(json)
|
26
31
|
end
|
27
|
-
|
32
|
+
|
33
|
+
# @return [String] with the """pretty output"""
|
28
34
|
# @todo: prettify the output
|
29
35
|
def print(message)
|
30
36
|
message.each do |image|
|
31
|
-
puts image['file_url']
|
37
|
+
puts shorten(image['file_url'])
|
32
38
|
end
|
39
|
+
end
|
33
40
|
|
41
|
+
# return [String] shorten url with goo.gl
|
42
|
+
def shorten(long_url)
|
43
|
+
uri = URI.parse('https://www.googleapis.com/urlshortener/v1/url')
|
44
|
+
googl_san = Net::HTTP.new(uri.host, uri.port)
|
45
|
+
googl_san.use_ssl = true
|
46
|
+
googl_san.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
47
|
+
|
48
|
+
# rubymine gives me a "String as hash key" warning
|
49
|
+
# fu.
|
50
|
+
initheader = {'Content-Type' =>'application/json'}
|
51
|
+
|
52
|
+
question = Net::HTTP::Post.new(uri.request_uri, initheader)
|
53
|
+
question.body = {longUrl: long_url}.to_json
|
54
|
+
response = googl_san.request(question)
|
55
|
+
translate(response.body)['id']
|
56
|
+
|
57
|
+
# easy way is easy
|
58
|
+
# Googl.shorten(long_url).short_url
|
34
59
|
end
|
35
60
|
end
|
36
61
|
|
37
62
|
class Site
|
38
|
-
|
63
|
+
|
64
|
+
# @return [JSON] if everything is ok
|
39
65
|
# @todo: escape empty response
|
40
66
|
def ask(options)
|
41
67
|
response = Net::HTTP.post_form(options[:api], 'limit' => options[:limit])
|
42
68
|
response.body
|
43
69
|
end
|
70
|
+
|
44
71
|
end
|
45
72
|
end
|
data/lib/KonaLast/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: KonaLast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- zeriyu
|
@@ -41,7 +40,6 @@ dependencies:
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: bundler
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
43
|
requirements:
|
46
44
|
- - ~>
|
47
45
|
- !ruby/object:Gem::Version
|
@@ -49,7 +47,6 @@ dependencies:
|
|
49
47
|
type: :development
|
50
48
|
prerelease: false
|
51
49
|
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
50
|
requirements:
|
54
51
|
- - ~>
|
55
52
|
- !ruby/object:Gem::Version
|
@@ -71,31 +68,32 @@ files:
|
|
71
68
|
- README.md
|
72
69
|
- bin/kona-ask
|
73
70
|
- certs/zeriyu.pem
|
71
|
+
- checksum/KonaLast-0.0.3.gem.sha512
|
74
72
|
- lib/KonaLast.rb
|
75
73
|
- lib/KonaLast/version.rb
|
76
74
|
homepage: http://zeriyu.github.io
|
77
75
|
licenses:
|
78
76
|
- WTFPL
|
77
|
+
metadata: {}
|
79
78
|
post_install_message:
|
80
79
|
rdoc_options: []
|
81
80
|
require_paths:
|
82
81
|
- lib
|
83
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
83
|
requirements:
|
86
84
|
- - ! '>='
|
87
85
|
- !ruby/object:Gem::Version
|
88
86
|
version: '0'
|
89
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
88
|
requirements:
|
92
89
|
- - ! '>='
|
93
90
|
- !ruby/object:Gem::Version
|
94
91
|
version: '0'
|
95
92
|
requirements: []
|
96
93
|
rubyforge_project:
|
97
|
-
rubygems_version:
|
94
|
+
rubygems_version: 2.4.1
|
98
95
|
signing_key:
|
99
|
-
specification_version:
|
96
|
+
specification_version: 4
|
100
97
|
summary: Get last x pictures from konachan
|
101
98
|
test_files: []
|
99
|
+
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|