shangrila 0.1.0 → 0.1.1

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: 743586030befdeadefa543c1f2d90799e1658282
4
- data.tar.gz: 6022cac914f2ca32da6b6850d667c5613227741a
3
+ metadata.gz: c332f0599b50810652f93716c4f5e2582ce4906d
4
+ data.tar.gz: c24bc942b63376af2b64281ed59bb1186fea7c53
5
5
  SHA512:
6
- metadata.gz: 4bc527c867fb2806309dd8573323496ccf332ddd9aadc97a22d92164801657986dde8faea220845221a8616197ce77b33c989746bbf6a38d55c4ece3b6f66d6f
7
- data.tar.gz: 14daac15063a0757e7df2791ceafd76aecaba2f62a0fa3c55383bee82c27755da3187c77c8bf3147a59370f2259b84005d04f36c78b5fcddb1bf2f8867335141
6
+ metadata.gz: 4c1aeff5adb86b8d23b922f66f96e06099f0f9a5c6842994bd28f252da867fc0b67a9169859eb5bff82805f597d571c7cdb429b6d52563f4448a4ebe6e188f8a
7
+ data.tar.gz: 2da03cd8cf0f6820de9b862e719b5df21ea7939c3e1c0b1cf298a7e9ffdc7854792991643e2a5c0f861952335372f6b441154b9df9d22b894813bad8f92a78f4
data/README.md CHANGED
@@ -8,7 +8,9 @@ or Gemfile
8
8
 
9
9
  ``gem 'shangrila'``
10
10
 
11
- ## anime-api command
11
+ ## Command Usage
12
+
13
+ ### anime-api
12
14
 
13
15
  ```
14
16
  shell$ anime-api -h
@@ -20,7 +22,14 @@ Usage: anime-api [options]
20
22
  shell$ anime-api -y 2016 -c 4 | jq .
21
23
  ```
22
24
 
23
- ## gem Usage
25
+ ### anime-api-twitter
26
+
27
+ ```
28
+ shell$ anime-api-twitter -a usagi_anime
29
+ ```
30
+
31
+
32
+ ## Gem Usage
24
33
 
25
34
  ### Master API
26
35
 
@@ -21,8 +21,12 @@ rescue => exc
21
21
  return
22
22
  end
23
23
 
24
- hostname = nil
24
+ anime_master = nil
25
25
 
26
- hostname = 'api.tv-anime.biz' if standby_server
26
+ if standby_server
27
+ anime_master = Shangrila::Sora.new('api.tv-anime.biz')
28
+ else
29
+ anime_master = Shangrila::Sora.new()
30
+ end
27
31
 
28
- puts Shangrila::Sora.new(hostname).get_master_data_raw(year, cours)
32
+ puts anime_master.get_master_data_raw(year, cours)
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ require 'shangrila'
3
+ require 'optparse'
4
+
5
+ opt = OptionParser.new
6
+
7
+ account = ''
8
+
9
+ Version = '1.0.0'
10
+
11
+ opt.on('-a twitter_account', 'twitter account name') {|v| account = v}
12
+
13
+ begin
14
+ opt.parse!(ARGV)
15
+ rescue => exc
16
+ p exc
17
+ return
18
+ end
19
+
20
+ #TODO sanaは待機系サーバーがない
21
+
22
+ api = Shangrila::Sana.new()
23
+ puts api.follower_history(account, false)
@@ -6,17 +6,17 @@ require 'httpclient'
6
6
  module Shangrila
7
7
 
8
8
  class Sana
9
- URL = 'http://api.moemoe.tokyo/anime/v1/twitter'
10
9
 
11
10
  def initialize(hostname = 'api.moemoe.tokyo')
12
- @url = "http://#{hostname}/anime/v1/master"
11
+ @url = "http://#{hostname}/anime/v1/twitter"
13
12
  end
14
13
 
15
14
  # @param [Array] accounts データ取得対象のアニメTwitter公式アカウント
15
+ # @param [boolean] is_to_json JSONをRubyHashにして返すかどうか
16
16
  # @return [Hash] アカウント群をキーとしたハッシュ
17
- def follower_status(accounts)
18
- response = HTTPClient.get(sprintf('%s/follower/status?accounts=%s', URL, accounts.join(',')))
19
- JSON.load(response.body)
17
+ def follower_status(accounts, is_to_json = true)
18
+ response = HTTPClient.get(sprintf('%s/follower/status?accounts=%s', @url, accounts.join(',')))
19
+ is_to_json ? JSON.load(response.body) : response.body
20
20
  end
21
21
 
22
22
  # @param [String] account データ取得対象のアニメTwitter公式アカウント
@@ -25,9 +25,9 @@ module Shangrila
25
25
  def follower_history(account, end_date = nil)
26
26
  response = nil
27
27
  if end_date.nil?
28
- response = HTTPClient.get(sprintf('%s/follower/history?account=%s', URL, account))
28
+ response = HTTPClient.get(sprintf('%s/follower/history?account=%s', @url, account))
29
29
  else
30
- response = HTTPClient.get(sprintf('%s/follower/history?account=%s&end_date=%d', URL, account, end_date))
30
+ response = HTTPClient.get(sprintf('%s/follower/history?account=%s&end_date=%d', @url, account, end_date))
31
31
  end
32
32
 
33
33
  JSON.load(response.body)
@@ -38,7 +38,7 @@ module Shangrila
38
38
  # @param [int] days 取得日数
39
39
  # @return [Array] フォロワー数と更新日時のハッシュの配列
40
40
  def follower_history_daily(account, days = nil)
41
- response = HTTPClient.get(sprintf('%s/follower/history/daily?account=%s&days=%s', URL, account, days))
41
+ response = HTTPClient.get(sprintf('%s/follower/history/daily?account=%s&days=%s', @url, account, days))
42
42
 
43
43
  JSON.load(response.body)
44
44
  end
@@ -1,3 +1,3 @@
1
1
  module Shangrila
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_runtime_dependency "httpclient"
24
24
  spec.executables << 'anime-api'
25
+ spec.executables << 'anime-api-twitter'
25
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shangrila
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AKB428
@@ -57,6 +57,7 @@ email:
57
57
  - gandara016+1@gmail.com
58
58
  executables:
59
59
  - anime-api
60
+ - anime-api-twitter
60
61
  extensions: []
61
62
  extra_rdoc_files: []
62
63
  files:
@@ -66,6 +67,7 @@ files:
66
67
  - README.md
67
68
  - Rakefile
68
69
  - bin/anime-api
70
+ - bin/anime-api-twitter
69
71
  - lib/shangrila.rb
70
72
  - lib/shangrila/sana.rb
71
73
  - lib/shangrila/sora.rb