k_sequencing 0.1.24 → 0.1.25

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.
Files changed (38) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +4 -0
  3. data/.rubocop.yml +23 -0
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +27 -1
  6. data/README.md +17 -9
  7. data/Rakefile +12 -2
  8. data/docs/documentation.md +32 -35
  9. data/k_sequencing.gemspec +8 -6
  10. data/lib/k_sequencing.rb +0 -4
  11. data/lib/k_sequencing/client.rb +1 -3
  12. data/lib/k_sequencing/client_response.rb +4 -9
  13. data/lib/k_sequencing/connection.rb +24 -16
  14. data/lib/k_sequencing/faraday/raise_http_exception.rb +2 -8
  15. data/lib/k_sequencing/predictions.rb +2 -4
  16. data/lib/k_sequencing/version.rb +1 -1
  17. data/test/fixtures/image_choice/all.json +27 -0
  18. data/test/fixtures/image_choice/create.json +25 -0
  19. data/test/fixtures/image_closed_question/all.json +21 -0
  20. data/test/fixtures/image_closed_question/create.json +19 -0
  21. data/test/fixtures/image_message/all.json +22 -0
  22. data/test/fixtures/image_message/create.json +20 -0
  23. data/test/fixtures/image_photo_tag/all.json +22 -0
  24. data/test/fixtures/image_photo_tag/create.json +20 -0
  25. data/test/fixtures/prediction/all.json +21 -0
  26. data/test/fixtures/prediction/create.json +19 -0
  27. data/test/helper/file_reader.rb +11 -0
  28. data/test/k_sequencing/client_response_test.rb +29 -0
  29. data/test/k_sequencing/client_test.rb +189 -0
  30. data/test/k_sequencing/connection_test.rb +85 -0
  31. data/test/k_sequencing/image_choices_test.rb +38 -0
  32. data/test/k_sequencing/image_closed_questions_test.rb +38 -0
  33. data/test/k_sequencing/image_messages_test.rb +38 -0
  34. data/test/k_sequencing/image_photo_tags_test.rb +38 -0
  35. data/test/k_sequencing/predictions_test.rb +39 -0
  36. data/test/k_sequencing_test.rb +39 -0
  37. data/test/test_helper.rb +41 -0
  38. metadata +101 -17
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ module KSequencing
4
+ class ImagePhotoTagsTest < TestBase
5
+ def test_all
6
+ stub_request(:get, IMAGE_PHOTO_TAGS)
7
+ .with(query: { token: options[:token] })
8
+ .to_return(body: JSON.generate(image_photo_tags), status: 200)
9
+ response = ImagePhotoTag.new.all(options)
10
+ assert_instance_of(Response, response)
11
+ assert_equal(200, response.status)
12
+ refute_nil(response.data)
13
+ refute_nil(response.meta)
14
+ end
15
+
16
+ def test_create
17
+ stub_request(:post, IMAGE_PHOTO_TAGS)
18
+ .with(headers: { Authorization: options[:token] })
19
+ .to_return(body: JSON.generate(image_photo_tags), status: 200)
20
+ response = ImagePhotoTag.new.create(options)
21
+ assert_instance_of(Response, response)
22
+ assert_equal(200, response.status)
23
+ refute_nil(response.data)
24
+ refute_nil(response.meta)
25
+ end
26
+
27
+ def test_find
28
+ stub_request(:get, IMAGE_PHOTO_TAG)
29
+ .with(query: { token: options[:token] })
30
+ .to_return(body: JSON.generate(image_photo_tag), status: 200)
31
+ response = ImagePhotoTag.new.find_by(options)
32
+ assert_instance_of(Response, response)
33
+ assert_equal(200, response.status)
34
+ refute_nil(response.data)
35
+ refute_nil(response.meta)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,39 @@
1
+ require 'test_helper'
2
+
3
+ module KSequencing
4
+ class PredictionTest < TestBase
5
+ def test_all
6
+ stub_request(:get, PREDICTIONS_URL)
7
+ .with(query: { token: options[:token] })
8
+ .to_return(body: JSON.generate(predictions), status: 200)
9
+ response = Prediction.new.all(options)
10
+ assert_instance_of(Response, response)
11
+ assert_equal(200, response.status)
12
+ refute_nil(response.data)
13
+ refute_nil(response.meta)
14
+ end
15
+
16
+ def test_create
17
+ stub_request(:post, PREDICTIONS_URL)
18
+ .with(headers: { Authorization: options[:token] })
19
+ .to_return(body: JSON.generate(prediction), status: 200)
20
+ response = Prediction.new.create(options)
21
+ assert_instance_of(Response, response)
22
+ assert_equal(200, response.status)
23
+ refute_nil(response.data)
24
+ refute_nil(response.meta)
25
+ end
26
+
27
+ def test_find
28
+ mock_id = '1'
29
+ stub_request(:get, PREDICTIONS_URL + '/' + mock_id)
30
+ .with(query: { token: options[:token] })
31
+ .to_return(body: JSON.generate(prediction), status: 200)
32
+ response = Prediction.new.find_by(options.merge(id: mock_id))
33
+ assert_instance_of(Response, response)
34
+ assert_equal(200, response.status)
35
+ refute_nil(response.data)
36
+ refute_nil(response.meta)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ require 'test_helper'
2
+
3
+ module KSequencing
4
+ class KSequencingTest < Minitest::Test
5
+ def test_setup
6
+ KSequencing.setup { |config| }
7
+ end
8
+
9
+ def test_client
10
+ client = KSequencing.client
11
+ refute_nil(client)
12
+ end
13
+
14
+ def test_image_closed_question
15
+ closed_question = KSequencing.image_closed_question
16
+ refute_nil(closed_question)
17
+ end
18
+
19
+ def test_image_photo_tag
20
+ photo_tag = KSequencing.image_photo_tag
21
+ refute_nil(photo_tag)
22
+ end
23
+
24
+ def test_image_choice
25
+ choice = KSequencing.image_choice
26
+ refute_nil(choice)
27
+ end
28
+
29
+ def test_image_message
30
+ message = KSequencing.image_message
31
+ refute_nil(message)
32
+ end
33
+
34
+ def test_prediction
35
+ prediction = KSequencing.prediction
36
+ refute_nil(prediction)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,41 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'simplecov'
3
+
4
+ SimpleCov.start
5
+
6
+ require 'helper/file_reader'
7
+ require 'k_sequencing'
8
+ require 'minitest/autorun'
9
+ require 'webmock/minitest'
10
+
11
+ class TestBase < Minitest::Test
12
+ attr_reader :options, :image_choice, :image_choices, :image_closed_question, :image_closed_questions,
13
+ :image_message, :image_messages, :image_photo_tag, :image_photo_tags, :prediction, :predictions
14
+
15
+ IMAGE_CHOICES_URL = 'https://k-sequencing.datawow.io/api/images/choices'.freeze
16
+ IMAGE_CHOICE_URL = 'https://k-sequencing.datawow.io/api/images/choice'.freeze
17
+ IMAGE_CLOSED_QUESTIONS_URL = 'https://k-sequencing.datawow.io/api/images/closed_questions'.freeze
18
+ IMAGE_CLOSED_QUESTION_URL = 'https://k-sequencing.datawow.io/api/images/closed_question'.freeze
19
+ IMAGE_MESSAGES_URL = 'https://k-sequencing.datawow.io/api/images/messages'.freeze
20
+ IMAGE_MESSAGE_URL = 'https://k-sequencing.datawow.io/api/images/message'.freeze
21
+ IMAGE_PHOTO_TAGS = 'https://k-sequencing.datawow.io/api/images/photo_tags'.freeze
22
+ IMAGE_PHOTO_TAG = 'https://k-sequencing.datawow.io/api/images/photo_tag'.freeze
23
+ PREDICTIONS_URL = 'https://k-sequencing.datawow.io/api/prime/predictions'.freeze
24
+ IMAGE_URL = 'https://k-sequencing.datawow.io/api/projects/images'.freeze
25
+
26
+ def setup
27
+ @image_choices = FileReader.new('test/fixtures/image_choice/all.json').read_json
28
+ @image_choice = FileReader.new('test/fixtures/image_choice/create.json').read_json
29
+ @image_closed_questions = FileReader.new('test/fixtures/image_closed_question/all.json').read_json
30
+ @image_closed_question = FileReader.new('test/fixtures/image_closed_question/create.json').read_json
31
+ @image_messages = FileReader.new('test/fixtures/image_message/all.json').read_json
32
+ @image_message = FileReader.new('test/fixtures/image_message/create.json').read_json
33
+ @image_photo_tags = FileReader.new('test/fixtures/image_photo_tag/all.json').read_json
34
+ @image_photo_tag = FileReader.new('test/fixtures/image_photo_tag/create.json').read_json
35
+ @predictions = FileReader.new('test/fixtures/prediction/all.json').read_json
36
+ @prediction = FileReader.new('test/fixtures/prediction/create.json').read_json
37
+ @options = {
38
+ token: 'project token'
39
+ }
40
+ end
41
+ end
metadata CHANGED
@@ -1,15 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_sequencing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.24
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesdakorn Samittiauttakorn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-27 00:00:00.000000000 Z
11
+ date: 2018-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.1
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.13.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 0.13.1
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.13.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: faraday_middleware
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.12.2
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.12.2
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 0.12.2
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.12.2
13
53
  - !ruby/object:Gem::Dependency
14
54
  name: json
15
55
  requirement: !ruby/object:Gem::Requirement
@@ -31,45 +71,67 @@ dependencies:
31
71
  - !ruby/object:Gem::Version
32
72
  version: 1.8.3
33
73
  - !ruby/object:Gem::Dependency
34
- name: faraday
74
+ name: minitest
35
75
  requirement: !ruby/object:Gem::Requirement
36
76
  requirements:
37
77
  - - "~>"
38
78
  - !ruby/object:Gem::Version
39
- version: 0.13.1
79
+ version: '5.11'
40
80
  - - ">="
41
81
  - !ruby/object:Gem::Version
42
- version: 0.13.1
43
- type: :runtime
82
+ version: 5.11.3
83
+ type: :development
44
84
  prerelease: false
45
85
  version_requirements: !ruby/object:Gem::Requirement
46
86
  requirements:
47
87
  - - "~>"
48
88
  - !ruby/object:Gem::Version
49
- version: 0.13.1
89
+ version: '5.11'
50
90
  - - ">="
51
91
  - !ruby/object:Gem::Version
52
- version: 0.13.1
92
+ version: 5.11.3
53
93
  - !ruby/object:Gem::Dependency
54
- name: faraday_middleware
94
+ name: rake
55
95
  requirement: !ruby/object:Gem::Requirement
56
96
  requirements:
57
97
  - - "~>"
58
98
  - !ruby/object:Gem::Version
59
- version: 0.12.2
60
- - - ">="
99
+ version: '12.3'
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
61
105
  - !ruby/object:Gem::Version
62
- version: 0.12.2
63
- type: :runtime
106
+ version: '12.3'
107
+ - !ruby/object:Gem::Dependency
108
+ name: simplecov
109
+ requirement: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: 0.15.1
114
+ type: :development
64
115
  prerelease: false
65
116
  version_requirements: !ruby/object:Gem::Requirement
66
117
  requirements:
67
118
  - - "~>"
68
119
  - !ruby/object:Gem::Version
69
- version: 0.12.2
70
- - - ">="
120
+ version: 0.15.1
121
+ - !ruby/object:Gem::Dependency
122
+ name: webmock
123
+ requirement: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
71
126
  - !ruby/object:Gem::Version
72
- version: 0.12.2
127
+ version: '3.3'
128
+ type: :development
129
+ prerelease: false
130
+ version_requirements: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - "~>"
133
+ - !ruby/object:Gem::Version
134
+ version: '3.3'
73
135
  description: Moderation suite
74
136
  email: ton@nanameue.jp
75
137
  executables: []
@@ -77,6 +139,7 @@ extensions: []
77
139
  extra_rdoc_files: []
78
140
  files:
79
141
  - ".gitignore"
142
+ - ".rubocop.yml"
80
143
  - Gemfile
81
144
  - Gemfile.lock
82
145
  - INSTALL.md
@@ -98,6 +161,27 @@ files:
98
161
  - lib/k_sequencing/image_photo_tags.rb
99
162
  - lib/k_sequencing/predictions.rb
100
163
  - lib/k_sequencing/version.rb
164
+ - test/fixtures/image_choice/all.json
165
+ - test/fixtures/image_choice/create.json
166
+ - test/fixtures/image_closed_question/all.json
167
+ - test/fixtures/image_closed_question/create.json
168
+ - test/fixtures/image_message/all.json
169
+ - test/fixtures/image_message/create.json
170
+ - test/fixtures/image_photo_tag/all.json
171
+ - test/fixtures/image_photo_tag/create.json
172
+ - test/fixtures/prediction/all.json
173
+ - test/fixtures/prediction/create.json
174
+ - test/helper/file_reader.rb
175
+ - test/k_sequencing/client_response_test.rb
176
+ - test/k_sequencing/client_test.rb
177
+ - test/k_sequencing/connection_test.rb
178
+ - test/k_sequencing/image_choices_test.rb
179
+ - test/k_sequencing/image_closed_questions_test.rb
180
+ - test/k_sequencing/image_messages_test.rb
181
+ - test/k_sequencing/image_photo_tags_test.rb
182
+ - test/k_sequencing/predictions_test.rb
183
+ - test/k_sequencing_test.rb
184
+ - test/test_helper.rb
101
185
  homepage: https://datawow.io
102
186
  licenses:
103
187
  - Commercial
@@ -125,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
209
  version: '0'
126
210
  requirements: []
127
211
  rubyforge_project:
128
- rubygems_version: 2.6.14
212
+ rubygems_version: 2.7.3
129
213
  signing_key:
130
214
  specification_version: 4
131
215
  summary: KSequencing is a moderator service for your online content