posmoni 0.0.5

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 (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +42 -0
  6. data/INSTALL.md +7 -0
  7. data/README.md +184 -0
  8. data/Rakefile +12 -0
  9. data/lib/generators/posmoni/install_generator.rb +18 -0
  10. data/lib/generators/templates/posmoni_api.rb +7 -0
  11. data/lib/posmoni.rb +26 -0
  12. data/lib/posmoni/connector.rb +107 -0
  13. data/lib/posmoni/error.rb +15 -0
  14. data/lib/posmoni/interface.rb +22 -0
  15. data/lib/posmoni/moderation.rb +13 -0
  16. data/lib/posmoni/response.rb +40 -0
  17. data/lib/posmoni/version.rb +3 -0
  18. data/posmoni.gemspec +25 -0
  19. data/test/fixtures/image_choice/all.json +27 -0
  20. data/test/fixtures/image_choice/create.json +25 -0
  21. data/test/fixtures/image_closed_question/all.json +21 -0
  22. data/test/fixtures/image_closed_question/create.json +19 -0
  23. data/test/fixtures/image_document_verification/all.json +143 -0
  24. data/test/fixtures/image_document_verification/create.json +27 -0
  25. data/test/fixtures/image_message/all.json +22 -0
  26. data/test/fixtures/image_message/create.json +20 -0
  27. data/test/fixtures/image_photo_tag/all.json +22 -0
  28. data/test/fixtures/image_photo_tag/create.json +20 -0
  29. data/test/fixtures/moderation/all.json +68 -0
  30. data/test/fixtures/moderation/create.json +26 -0
  31. data/test/fixtures/moderation/find_by.json +26 -0
  32. data/test/fixtures/nanameue_human/all.json +25 -0
  33. data/test/fixtures/nanameue_human/create.json +21 -0
  34. data/test/fixtures/prediction/all.json +21 -0
  35. data/test/fixtures/prediction/create.json +19 -0
  36. data/test/fixtures/text_category/all.json +34 -0
  37. data/test/fixtures/text_category/create.json +27 -0
  38. data/test/fixtures/text_closed_question/all.json +27 -0
  39. data/test/fixtures/text_closed_question/create.json +20 -0
  40. data/test/fixtures/text_conversation/all.json +33 -0
  41. data/test/fixtures/text_conversation/create.json +26 -0
  42. data/test/fixtures/text_ja/all.json +35 -0
  43. data/test/fixtures/text_ja/create.json +28 -0
  44. data/test/fixtures/video_classification/all.json +21 -0
  45. data/test/fixtures/video_classification/create.json +19 -0
  46. data/test/helper/file_reader.rb +11 -0
  47. data/test/posmoni/moderation_test.rb +46 -0
  48. data/test/posmoni_test.rb +14 -0
  49. data/test/test_helper.rb +25 -0
  50. metadata +174 -0
@@ -0,0 +1,28 @@
1
+ {
2
+ "data": {
3
+ "id": "5c2eb38f0df256348de69a1f",
4
+ "created_at": "2019-01-04T08:14:55.372+07:00",
5
+ "custom_id": null,
6
+ "data": "foobar",
7
+ "processed_at": "2019-01-04T08:14:55.371+07:00",
8
+ "project_id": 202,
9
+ "results": {
10
+ "declined": 0.001,
11
+ "developing_model": {
12
+ "approved": 0.9909,
13
+ "pros-sexual": 0.0046,
14
+ "sns": 0.045
15
+ },
16
+ "pros_fasttext": 0.001,
17
+ "sexual_fasttext": 0.001,
18
+ "sexual_fasttext_romanji": 0.001,
19
+ "sns_fasttext": 0.001
20
+ },
21
+ "staff_id": 999998,
22
+ "status": "done"
23
+ },
24
+ "meta": {
25
+ "code": 201,
26
+ "message": "success"
27
+ }
28
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "data": {
3
+ "video": [
4
+ {
5
+ "id": "5a44671ab3957c2ab5c33326",
6
+ "answer": "declined",
7
+ "credit_charged": 1,
8
+ "custom_id": null,
9
+ "data": "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
10
+ "postback_url": "https://9333bbac.ngrok.io/callbacks",
11
+ "processed_at": "2017-12-28T10:40:30.462+07:00",
12
+ "project_id": 102,
13
+ "status": "processed"
14
+ }
15
+ ]
16
+ },
17
+ "meta": {
18
+ "code": 200,
19
+ "message": "success"
20
+ }
21
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "data": {
3
+ "video": {
4
+ "id": "5a44671ab3957c2ab5c33326",
5
+ "answer": "declined",
6
+ "credit_charged": 1,
7
+ "custom_id": null,
8
+ "data": "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
9
+ "postback_url": "https://9333bbac.ngrok.io/callbacks",
10
+ "processed_at": "2017-12-28T10:40:30.462+07:00",
11
+ "project_id": 102,
12
+ "status": "processed"
13
+ }
14
+ },
15
+ "meta": {
16
+ "code": 200,
17
+ "message": "success"
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ class FileReader
2
+ attr_reader :file
3
+
4
+ def initialize(file)
5
+ @file = file
6
+ end
7
+
8
+ def read_json
9
+ JSON.parse(File.read(file))
10
+ end
11
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module Posmoni
6
+ class ModerationTest < TestBase
7
+ def test_all
8
+ stub_request(:get, MODERATION_URL)
9
+ .to_return(body: JSON.generate(@moderation_all), status: 200)
10
+ response = model.all
11
+
12
+ assert_instance_of(Response, response)
13
+ assert_equal(200, response.status)
14
+ refute_nil(response.data)
15
+ refute_nil(response.meta)
16
+ end
17
+
18
+ def test_create
19
+ stub_request(:post, MODERATION_URL)
20
+ .to_return(body: JSON.generate(@moderation_create), status: 201)
21
+ response = model.create({ data: 'data' })
22
+
23
+ assert_instance_of(Response, response)
24
+ assert_equal(201, response.status)
25
+ refute_nil(response.data)
26
+ refute_nil(response.meta)
27
+ end
28
+
29
+ def test_find_by
30
+ stub_request(:get, "#{MODERATION_URL}?id=test&query=test")
31
+ .to_return(body: JSON.generate(@moderation_find_by), status: 200)
32
+ response = model.find_by(id: 'test')
33
+
34
+ assert_instance_of(Response, response)
35
+ assert_equal(200, response.status)
36
+ refute_nil(response.data)
37
+ refute_nil(response.meta)
38
+ end
39
+
40
+ private
41
+
42
+ def model
43
+ @model ||= Moderation.new('test')
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ module Posmoni
4
+ class PosmoniTest < Minitest::Test
5
+ def test_setup
6
+ Posmoni.setup { |config| }
7
+ end
8
+
9
+ def test_moderation
10
+ moderation = Posmoni.moderation
11
+ refute_nil(moderation)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
4
+ require 'simplecov'
5
+
6
+ SimpleCov.start
7
+
8
+ require 'posmoni'
9
+ require 'helper/file_reader'
10
+ require 'minitest/autorun'
11
+ require 'webmock/minitest'
12
+
13
+ class TestBase < Minitest::Test
14
+
15
+ MODERATION_URL = 'https://api.posmoni.com/api/v1/moderations'
16
+
17
+ def setup
18
+ @moderation_all = FileReader.new('test/fixtures/moderation/all.json').read_json
19
+ @moderation_create = FileReader.new('test/fixtures/moderation/create.json').read_json
20
+ @moderation_find_by = FileReader.new('test/fixtures/moderation/find_by.json').read_json
21
+ @options = {
22
+ token: 'project token'
23
+ }
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: posmoni
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Jesdakorn Samittiauttakorn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.11'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 5.11.3
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '5.11'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 5.11.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '12.3'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '12.3'
61
+ - !ruby/object:Gem::Dependency
62
+ name: simplecov
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 0.15.1
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 0.15.1
75
+ - !ruby/object:Gem::Dependency
76
+ name: webmock
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.3'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.3'
89
+ description: Posmoni suite
90
+ email: ton@nanameue.jp
91
+ executables: []
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - ".gitignore"
96
+ - ".ruby-version"
97
+ - Gemfile
98
+ - Gemfile.lock
99
+ - INSTALL.md
100
+ - README.md
101
+ - Rakefile
102
+ - lib/generators/posmoni/install_generator.rb
103
+ - lib/generators/templates/posmoni_api.rb
104
+ - lib/posmoni.rb
105
+ - lib/posmoni/connector.rb
106
+ - lib/posmoni/error.rb
107
+ - lib/posmoni/interface.rb
108
+ - lib/posmoni/moderation.rb
109
+ - lib/posmoni/response.rb
110
+ - lib/posmoni/version.rb
111
+ - posmoni.gemspec
112
+ - test/fixtures/image_choice/all.json
113
+ - test/fixtures/image_choice/create.json
114
+ - test/fixtures/image_closed_question/all.json
115
+ - test/fixtures/image_closed_question/create.json
116
+ - test/fixtures/image_document_verification/all.json
117
+ - test/fixtures/image_document_verification/create.json
118
+ - test/fixtures/image_message/all.json
119
+ - test/fixtures/image_message/create.json
120
+ - test/fixtures/image_photo_tag/all.json
121
+ - test/fixtures/image_photo_tag/create.json
122
+ - test/fixtures/moderation/all.json
123
+ - test/fixtures/moderation/create.json
124
+ - test/fixtures/moderation/find_by.json
125
+ - test/fixtures/nanameue_human/all.json
126
+ - test/fixtures/nanameue_human/create.json
127
+ - test/fixtures/prediction/all.json
128
+ - test/fixtures/prediction/create.json
129
+ - test/fixtures/text_category/all.json
130
+ - test/fixtures/text_category/create.json
131
+ - test/fixtures/text_closed_question/all.json
132
+ - test/fixtures/text_closed_question/create.json
133
+ - test/fixtures/text_conversation/all.json
134
+ - test/fixtures/text_conversation/create.json
135
+ - test/fixtures/text_ja/all.json
136
+ - test/fixtures/text_ja/create.json
137
+ - test/fixtures/video_classification/all.json
138
+ - test/fixtures/video_classification/create.json
139
+ - test/helper/file_reader.rb
140
+ - test/posmoni/moderation_test.rb
141
+ - test/posmoni_test.rb
142
+ - test/test_helper.rb
143
+ homepage: https://datawow.io
144
+ licenses:
145
+ - MIT
146
+ metadata: {}
147
+ post_install_message: |
148
+ After install CM
149
+
150
+ Run the generator
151
+
152
+ rails generate cm:install
153
+
154
+ This will install an initializer which describes ALL of CM's configuration options.
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 2.7.6
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: HTTP RESTFul for calling Posmoni APIs
174
+ test_files: []