twicas_stream 1.2.2 → 1.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec2e828a4cfe3400f1695a66f7c1242450d23a909de2533d8fde24959532ee04
4
- data.tar.gz: c8a32e0c9345277ce27591f9ea72db9d4fddc38e02ad7da9f045c6231d724cdf
3
+ metadata.gz: f264f6618752379927f999963a8e6e685faadd33697794b0fcffea3b720148b8
4
+ data.tar.gz: 7f979f21409dbdeb049b397682ae5237f9d2a535e529bb30cb087321b1e74fe1
5
5
  SHA512:
6
- metadata.gz: 5eafb58aeee996d5b74c5ca904f70d13e1d34773ac1c0b31a385cf8ebec849c0d75295c5985238924f6f0e871deb0fcd021863686896d540d108237fb3d5be80
7
- data.tar.gz: e9005499b49eb8a77a5d2a0eb02fa65772dc81237bc109472b35dc30a3f9d8d637d56aa5902090bade9135aacf78b2e4bb5639ae702010194b0c26f4ff2febd7
6
+ metadata.gz: 77241d501ba6b4e45987a496972d4f62bb338fafcfabaac1d906fb051f37f580826f3cee2c5240835e95872249509dc2d97f7dd85379a571232d64f8e31853c4
7
+ data.tar.gz: 4c1905d59d5355701fcd570403b0c4d1855b9e68a6e48e4a415bd948d57ddfa8c462b9b6715264175c2a42c169929a0c1d230b81a81dd3cc67779c1d0cf54149
data/.gitignore CHANGED
@@ -1,5 +1,5 @@
1
1
  # It must be ignored
2
- config/access_token.txt
3
- pkg
2
+ /config/access_token.txt
3
+ /pkg
4
4
  .rspec_status
5
5
  Gemfile.lock
data/CHANGELOG.md CHANGED
@@ -1,10 +1,19 @@
1
+ ## v1.3.0
2
+ [full changelog](http://github.com/ysato5654/twicas_stream/compare/v1.2.2...v1.3.0)
3
+
4
+ * support some requests
5
+ * Movie
6
+ - Get Movies by User
7
+ - Get Current Live
8
+ * improve reliability
9
+
1
10
  ## v1.2.2
2
- [full changelog](http://github.com/ysato5654/twicas_stream/compare/v1.2.2...v1.2.1)
11
+ [full changelog](http://github.com/ysato5654/twicas_stream/compare/v1.2.1...v1.2.2)
3
12
 
4
13
  * improve reliability
5
14
 
6
15
  ## v1.2.1
7
- [full changelog](http://github.com/ysato5654/twicas_stream/compare/v1.2.1...v1.2.0)
16
+ [full changelog](http://github.com/ysato5654/twicas_stream/compare/v1.2.0...v1.2.1)
8
17
 
9
18
  * improve reliability
10
19
 
@@ -25,8 +34,8 @@
25
34
  ## v1.1.1
26
35
  [full changelog](http://github.com/ysato5654/twicas_stream/compare/v1.1.0...v1.1.1)
27
36
 
28
- * Add changelog
29
- * Add github badge
37
+ * add changelog
38
+ * add github badge
30
39
  - RubyGems.org
31
40
  - Travis CI
32
41
  - Coveralls
@@ -34,7 +43,7 @@
34
43
  ## v1.1.0
35
44
  [full changelog](http://github.com/ysato5654/twicas_stream/compare/v1.0.0...v1.1.0)
36
45
 
37
- * Support some requests
46
+ * support some requests
38
47
  * Live Thumbnail
39
48
  - Get Live Thumbnail Image
40
49
  * Supporter
@@ -40,6 +40,8 @@ module TwicasStream
40
40
 
41
41
  DEFAULT_OFFSET = 0
42
42
 
43
+ LOWER_OFFSET = 0
44
+
43
45
  DEFAULT_LIMIT = 10
44
46
 
45
47
  LOWER_LIMIT = 1
@@ -54,13 +56,17 @@ module TwicasStream
54
56
  @response = Hash.new
55
57
  param = Hash.new
56
58
 
59
+ if offset < LOWER_OFFSET
60
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. offset range should be over #{LOWER_OFFSET}."
61
+ end
62
+
57
63
  unless limit >= LOWER_LIMIT and limit <= UPPER_LIMIT
58
- STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limitation range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}."
64
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limit range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}."
59
65
  end
60
66
 
61
67
  if slice_id.kind_of?(Integer)
62
68
  if slice_id < LOWER_SLICE_ID
63
- STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. slice id (comment id) should be over than #{LOWER_SLICE_ID}."
69
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. slice id (comment id) should be over #{LOWER_SLICE_ID}."
64
70
  end
65
71
  else
66
72
  unless slice_id == DEFAULT_SLICE_ID
@@ -61,9 +61,78 @@ module TwicasStream
61
61
  end
62
62
 
63
63
  class GetMoviesbyUser
64
+ attr_reader :response
65
+
66
+ PREFIX_URL = 'users'
67
+
68
+ SUFFIX_URL = 'movies'
69
+
70
+ DEFAULT_OFFSET = 0
71
+
72
+ LOWER_OFFSET = 0
73
+
74
+ UPPER_OFFSET = 1000
75
+
76
+ DEFAULT_LIMIT = 20
77
+
78
+ LOWER_LIMIT = 1
79
+
80
+ UPPER_LIMIT = 50
81
+
82
+ DEFAULT_SLICE_ID = 'none'
83
+
84
+ LOWER_SLICE_ID = 1
85
+
86
+ def initialize user_id, offset = DEFAULT_OFFSET, limit = DEFAULT_LIMIT, slice_id = DEFAULT_SLICE_ID
87
+ @response = Hash.new
88
+ param = Hash.new
89
+
90
+ unless offset >= LOWER_OFFSET and offset <= UPPER_OFFSET
91
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. offset range is #{LOWER_OFFSET} ~ #{UPPER_OFFSET}."
92
+ end
93
+
94
+ unless limit >= LOWER_LIMIT and limit <= UPPER_LIMIT
95
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limit range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}."
96
+ end
97
+
98
+ if slice_id.kind_of?(Integer)
99
+ if slice_id < LOWER_SLICE_ID
100
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. slice id (comment id) should be over #{LOWER_SLICE_ID}."
101
+ end
102
+ else
103
+ unless slice_id == DEFAULT_SLICE_ID
104
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Error: invalid parameter. default is '#{DEFAULT_SLICE_ID}'."
105
+ end
106
+ end
107
+
108
+ param['offset'] = offset
109
+ param['limit'] = limit
110
+ param['slice_id'] = slice_id unless slice_id == DEFAULT_SLICE_ID
111
+
112
+ url = [BASE_URL, PREFIX_URL, user_id, SUFFIX_URL].join('/') + TwicasStream.make_query_string(param)
113
+ #url = BASE_URL + '/' + PREFIX_URL + '/' + user_id + '/' + SUFFIX_URL + TwicasStream.make_query_string(param)
114
+ # => 'https://apiv2.twitcasting.tv/users/:user_id/movies?offset=0&limit=20'
115
+
116
+ @response = TwicasStream.parse(TwicasStream.get(url))
117
+ end
64
118
  end
65
119
 
66
120
  class GetCurrentLive
121
+ attr_reader :response
122
+
123
+ PREFIX_URL = 'users'
124
+
125
+ SUFFIX_URL = 'current_live'
126
+
127
+ def initialize user_id
128
+ @response = Hash.new
129
+
130
+ #url = [BASE_URL, PREFIX_URL, user_id, SUFFIX_URL].join('/')
131
+ url = BASE_URL + '/' + PREFIX_URL + '/' + user_id + '/' + SUFFIX_URL
132
+ # => 'https://apiv2.twitcasting.tv/users/:user_id/current_live'
133
+
134
+ @response = TwicasStream.parse(TwicasStream.get(url))
135
+ end
67
136
  end
68
137
  end
69
138
  end
@@ -62,7 +62,7 @@ module TwicasStream
62
62
  end
63
63
 
64
64
  unless limit >= LOWER_LIMIT and limit <= UPPER_LIMIT
65
- STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limitation range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}."
65
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limit range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}."
66
66
  end
67
67
 
68
68
  unless LANG_LIMITATION.include?(lang)
@@ -144,7 +144,7 @@ module TwicasStream
144
144
  param = Hash.new
145
145
 
146
146
  unless limit >= LOWER_LIMIT and limit <= UPPER_LIMIT
147
- STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limitation range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}"
147
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limit range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}"
148
148
  end
149
149
 
150
150
  unless TYPE_LIMITATION.include?(type)
@@ -54,11 +54,11 @@ module TwicasStream
54
54
  param = Hash.new
55
55
 
56
56
  if offset < LOWER_OFFSET
57
- STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. offset should be over than #{LOWER_OFFSET}."
57
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. offset should be over #{LOWER_OFFSET}."
58
58
  end
59
59
 
60
60
  unless limit >= LOWER_LIMIT and limit <= UPPER_LIMIT
61
- STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limitation range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}."
61
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limit range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}."
62
62
  end
63
63
 
64
64
  param['offset'] = offset
@@ -95,11 +95,11 @@ module TwicasStream
95
95
  param = Hash.new
96
96
 
97
97
  if offset < LOWER_OFFSET
98
- STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. offset should be over than #{LOWER_OFFSET}."
98
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. offset should be over #{LOWER_OFFSET}."
99
99
  end
100
100
 
101
101
  unless limit >= LOWER_LIMIT and limit <= UPPER_LIMIT
102
- STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limitation range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}."
102
+ STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limit range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}."
103
103
  end
104
104
 
105
105
  unless SORT_LIMITATION.include?(sort)
@@ -2,5 +2,5 @@
2
2
  # coding: utf-8
3
3
 
4
4
  module TwicasStream
5
- VERSION = '1.2.2'
5
+ VERSION = '1.3.0'
6
6
  end
data/lib/twicas_stream.rb CHANGED
@@ -33,32 +33,38 @@ module TwicasStream
33
33
  header = header(result)
34
34
 
35
35
  body.each{ |key, value|
36
- # here is the plural form of TwicasStream
37
- if (key != key.singularize) and is_TwicasApiObject?(key)
38
- if key == 'movies'
39
- array = Array.new
40
- value.each{ |e|
41
- tmp = Hash.new
42
-
43
- e.each{ |child_key, child_value|
44
- tmp[child_key.to_sym] = parse_deep(child_key, child_value)
45
- }
46
-
47
- array.push tmp
36
+ # special if statement for the key into following method
37
+ # * 'movies' key of 'SearchLiveMovies' method
38
+ # * 'movies' key of 'GetMoviesbyUser' method
39
+ if key == 'movies'
40
+ # 'SearchLiveMovies'
41
+ if is_TwicasApiObject?(value.first.keys.first)
42
+ response[key.to_sym] = value.map{ |i|
43
+ child_response = Hash.new
44
+
45
+ i.each{ |child_key, child_value| child_response[child_key.to_sym] = parse_deep(child_key, child_value) }
46
+
47
+ child_response
48
48
  }
49
-
50
- response[key.to_sym] = array
51
-
49
+ # 'GetMoviesbyUser'
52
50
  else
53
51
  response[key.to_sym] = value.map{ |i| parse_deep(key, i) }
54
-
55
52
  end
56
- # following keys is actually TwicasApiObject as 'SupporterUser', but is_TwicasApiObject?(key) = false
57
- # so, we prepare special support as below
53
+
54
+ # special if statement for 'SupporterUser' as TwicasApiObject into 'SupportingList' and 'SupporterList' method, because these keys are is_TwicasApiObject?(key) = false
55
+ # * 'supporting' key of 'SupportingList' method
56
+ # * 'supporters' key of 'SupporterList' method
58
57
  elsif key == 'supporting' or key == 'supporters'
59
58
  response[key.to_sym] = value.map{ |i| parse_deep('SupporterUser', i) }
60
59
 
61
- # here is a singular form of TwicasApiObject, also others are here
60
+ # plural form
61
+ # * 'users' key of 'SearchUsers' method
62
+ # * 'categories' key of 'GetCategories' method
63
+ # * 'comments' key of 'GetComments' method
64
+ elsif (key != key.singularize) and is_TwicasApiObject?(key)
65
+ response[key.to_sym] = value.map{ |i| parse_deep(key, i) }
66
+
67
+ # singular form, and others
62
68
  else
63
69
  response[key.to_sym] = parse_deep(key, value)
64
70
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twicas_stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuya Sato
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-15 00:00:00.000000000 Z
11
+ date: 2018-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport