hiya 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b279b12e548dd0cc7eeb79b66afb6c6c48d75f781f82cb25d9a6db775f1c5b51
4
+ data.tar.gz: 7268d2bb561427b50ba1669feadb1265c499269cff32ca72473265c7273930c2
5
+ SHA512:
6
+ metadata.gz: 33994b80856953bfe8c54d4a8a49d1ec1cc9ba5e6da344d3829a130ea0f548bb260e595454f14a98f07c26ae55ae228978751e589ef7a55ed31b2a17dde5ac50
7
+ data.tar.gz: f760071ced6ac65cf6d61080e04ef986d3abd90fec57b06d6a2e929131732e61780d5e121145d264e1c4b5332baf9eac59d29630f68f54bac3e5bfeb85d69b94
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,227 @@
1
+ require:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+ - rubocop-capybara
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.6
8
+
9
+ # Style/StringLiterals:
10
+ # Enabled: true
11
+ # EnforcedStyle: double_quotes
12
+
13
+ # Style/StringLiteralsInInterpolation:
14
+ # Enabled: true
15
+ # EnforcedStyle: double_quotes
16
+
17
+ Layout/LineLength:
18
+ Max: 120
19
+ Style/Documentation:
20
+ Enabled: false
21
+
22
+ Gemspec/DeprecatedAttributeAssignment: # new in 1.30
23
+ Enabled: true
24
+ Gemspec/RequireMFA: # new in 1.23
25
+ Enabled: true
26
+ Layout/LineContinuationLeadingSpace: # new in 1.31
27
+ Enabled: true
28
+ Layout/LineContinuationSpacing: # new in 1.31
29
+ Enabled: true
30
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
31
+ Enabled: true
32
+ Layout/SpaceBeforeBrackets: # new in 1.7
33
+ Enabled: true
34
+ Lint/AmbiguousAssignment: # new in 1.7
35
+ Enabled: true
36
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
37
+ Enabled: true
38
+ Lint/AmbiguousRange: # new in 1.19
39
+ Enabled: true
40
+ Lint/ConstantOverwrittenInRescue: # new in 1.31
41
+ Enabled: true
42
+ Lint/DeprecatedConstants: # new in 1.8
43
+ Enabled: true
44
+ Lint/DuplicateBranch: # new in 1.3
45
+ Enabled: true
46
+ Lint/DuplicateMagicComment: # new in 1.37
47
+ Enabled: true
48
+ Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
49
+ Enabled: true
50
+ Lint/EmptyBlock: # new in 1.1
51
+ Enabled: true
52
+ Lint/EmptyClass: # new in 1.3
53
+ Enabled: true
54
+ Lint/EmptyInPattern: # new in 1.16
55
+ Enabled: true
56
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
57
+ Enabled: true
58
+ Lint/LambdaWithoutLiteralBlock: # new in 1.8
59
+ Enabled: true
60
+ Lint/NoReturnInBeginEndBlocks: # new in 1.2
61
+ Enabled: true
62
+ Lint/NonAtomicFileOperation: # new in 1.31
63
+ Enabled: true
64
+ Lint/NumberedParameterAssignment: # new in 1.9
65
+ Enabled: true
66
+ Lint/OrAssignmentToConstant: # new in 1.9
67
+ Enabled: true
68
+ Lint/RedundantDirGlobSort: # new in 1.8
69
+ Enabled: true
70
+ Lint/RefinementImportMethods: # new in 1.27
71
+ Enabled: true
72
+ Lint/RequireRangeParentheses: # new in 1.32
73
+ Enabled: true
74
+ Lint/RequireRelativeSelfPath: # new in 1.22
75
+ Enabled: true
76
+ Lint/SymbolConversion: # new in 1.9
77
+ Enabled: true
78
+ Lint/ToEnumArguments: # new in 1.1
79
+ Enabled: true
80
+ Lint/TripleQuotes: # new in 1.9
81
+ Enabled: true
82
+ Lint/UnexpectedBlockArity: # new in 1.5
83
+ Enabled: true
84
+ Lint/UnmodifiedReduceAccumulator: # new in 1.1
85
+ Enabled: true
86
+ Lint/UselessRescue: # new in 1.43
87
+ Enabled: true
88
+ Lint/UselessRuby2Keywords: # new in 1.23
89
+ Enabled: true
90
+ Naming/BlockForwarding: # new in 1.24
91
+ Enabled: true
92
+ Security/CompoundHash: # new in 1.28
93
+ Enabled: true
94
+ Security/IoMethods: # new in 1.22
95
+ Enabled: true
96
+ Style/ArgumentsForwarding: # new in 1.1
97
+ Enabled: true
98
+ Style/ArrayIntersect: # new in 1.40
99
+ Enabled: true
100
+ Style/CollectionCompact: # new in 1.2
101
+ Enabled: true
102
+ Style/ConcatArrayLiterals: # new in 1.41
103
+ Enabled: true
104
+ Style/DocumentDynamicEvalDefinition: # new in 1.1
105
+ Enabled: true
106
+ Style/EmptyHeredoc: # new in 1.32
107
+ Enabled: true
108
+ Style/EndlessMethod: # new in 1.8
109
+ Enabled: true
110
+ Style/EnvHome: # new in 1.29
111
+ Enabled: true
112
+ Style/FetchEnvVar: # new in 1.28
113
+ Enabled: true
114
+ Style/FileRead: # new in 1.24
115
+ Enabled: true
116
+ Style/FileWrite: # new in 1.24
117
+ Enabled: true
118
+ Style/HashConversion: # new in 1.10
119
+ Enabled: true
120
+ Style/HashExcept: # new in 1.7
121
+ Enabled: true
122
+ Style/IfWithBooleanLiteralBranches: # new in 1.9
123
+ Enabled: true
124
+ Style/InPatternThen: # new in 1.16
125
+ Enabled: true
126
+ Style/MagicCommentFormat: # new in 1.35
127
+ Enabled: true
128
+ Style/MapCompactWithConditionalBlock: # new in 1.30
129
+ Enabled: true
130
+ Style/MapToHash: # new in 1.24
131
+ Enabled: true
132
+ Style/MapToSet: # new in 1.42
133
+ Enabled: true
134
+ Style/MinMaxComparison: # new in 1.42
135
+ Enabled: true
136
+ Style/MultilineInPatternThen: # new in 1.16
137
+ Enabled: true
138
+ Style/NegatedIfElseCondition: # new in 1.2
139
+ Enabled: true
140
+ Style/NestedFileDirname: # new in 1.26
141
+ Enabled: true
142
+ Style/NilLambda: # new in 1.3
143
+ Enabled: true
144
+ Style/NumberedParameters: # new in 1.22
145
+ Enabled: true
146
+ Style/NumberedParametersLimit: # new in 1.22
147
+ Enabled: true
148
+ Style/ObjectThen: # new in 1.28
149
+ Enabled: true
150
+ Style/OpenStructUse: # new in 1.23
151
+ Enabled: true
152
+ Style/OperatorMethodCall: # new in 1.37
153
+ Enabled: true
154
+ Style/QuotedSymbols: # new in 1.16
155
+ Enabled: true
156
+ Style/RedundantArgument: # new in 1.4
157
+ Enabled: true
158
+ Style/RedundantConstantBase: # new in 1.40
159
+ Enabled: true
160
+ Style/RedundantDoubleSplatHashBraces: # new in 1.41
161
+ Enabled: true
162
+ Style/RedundantEach: # new in 1.38
163
+ Enabled: true
164
+ Style/RedundantInitialize: # new in 1.27
165
+ Enabled: true
166
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
167
+ Enabled: true
168
+ Style/RedundantStringEscape: # new in 1.37
169
+ Enabled: true
170
+ Style/SelectByRegexp: # new in 1.22
171
+ Enabled: true
172
+ Style/StringChars: # new in 1.12
173
+ Enabled: true
174
+ Style/SwapValues: # new in 1.1
175
+ Enabled: true
176
+ Capybara/MatchStyle: # new in <<next>>
177
+ Enabled: true
178
+ Capybara/NegationMatcher: # new in 2.14
179
+ Enabled: true
180
+ Capybara/SpecificActions: # new in 2.14
181
+ Enabled: true
182
+ Capybara/SpecificFinders: # new in 2.13
183
+ Enabled: true
184
+ Capybara/SpecificMatcher: # new in 2.12
185
+ Enabled: true
186
+ RSpec/BeEq: # new in 2.9.0
187
+ Enabled: true
188
+ RSpec/BeNil: # new in 2.9.0
189
+ Enabled: true
190
+ RSpec/ChangeByZero: # new in 2.11
191
+ Enabled: true
192
+ RSpec/ClassCheck: # new in 2.13
193
+ Enabled: true
194
+ RSpec/DuplicatedMetadata: # new in 2.16
195
+ Enabled: true
196
+ RSpec/ExcessiveDocstringSpacing: # new in 2.5
197
+ Enabled: true
198
+ RSpec/IdenticalEqualityAssertion: # new in 2.4
199
+ Enabled: true
200
+ RSpec/NoExpectationExample: # new in 2.13
201
+ Enabled: true
202
+ RSpec/PendingWithoutReason: # new in 2.16
203
+ Enabled: true
204
+ RSpec/SortMetadata: # new in 2.14
205
+ Enabled: true
206
+ RSpec/SubjectDeclaration: # new in 2.5
207
+ Enabled: true
208
+ RSpec/VerifiedDoubleReference: # new in 2.10.0
209
+ Enabled: true
210
+ RSpec/FactoryBot/ConsistentParenthesesStyle: # new in 2.14
211
+ Enabled: true
212
+ RSpec/FactoryBot/FactoryNameStyle: # new in 2.16
213
+ Enabled: true
214
+ RSpec/FactoryBot/SyntaxMethods: # new in 2.7
215
+ Enabled: true
216
+ RSpec/Rails/AvoidSetupHook: # new in 2.4
217
+ Enabled: true
218
+ RSpec/Rails/HaveHttpStatus: # new in 2.12
219
+ Enabled: true
220
+ RSpec/Rails/InferredSpecType: # new in 2.14
221
+ Enabled: true
222
+ RSpec/Rails/MinitestAssertions: # new in 2.17
223
+ Enabled: true
224
+ Gemspec/DevelopmentDependencies: # new in 1.44
225
+ Enabled: true
226
+ Style/ComparableClamp: # new in 1.44
227
+ Enabled: true
@@ -0,0 +1,3 @@
1
+ {
2
+ "ruby.rubocop.executePath": "/Users/jiunjiun/.rvm/gems/ruby-3.2.0/wrappers/",
3
+ }
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in hiya.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ gem 'rspec', '~> 3.0'
11
+
12
+ gem 'rubocop', '~> 1.21'
13
+
14
+ group :development, :test do
15
+ gem 'rubocop-rake', require: false
16
+ gem 'rubocop-rspec', require: false
17
+ end
18
+
19
+ gem 'faraday', '~> 2.0'
20
+ gem 'faraday-multipart'
data/Gemfile.lock ADDED
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hiya (0.1.0)
5
+ faraday (~> 2.0)
6
+ faraday-multipart
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ diff-lcs (1.5.0)
13
+ faraday (2.7.2)
14
+ faraday-net_http (>= 2.0, < 3.1)
15
+ ruby2_keywords (>= 0.0.4)
16
+ faraday-multipart (1.0.4)
17
+ multipart-post (~> 2)
18
+ faraday-net_http (3.0.2)
19
+ json (2.6.3)
20
+ multipart-post (2.3.0)
21
+ parallel (1.22.1)
22
+ parser (3.2.0.0)
23
+ ast (~> 2.4.1)
24
+ rainbow (3.1.1)
25
+ rake (13.0.6)
26
+ regexp_parser (2.6.2)
27
+ rexml (3.2.5)
28
+ rspec (3.12.0)
29
+ rspec-core (~> 3.12.0)
30
+ rspec-expectations (~> 3.12.0)
31
+ rspec-mocks (~> 3.12.0)
32
+ rspec-core (3.12.0)
33
+ rspec-support (~> 3.12.0)
34
+ rspec-expectations (3.12.2)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.12.0)
37
+ rspec-mocks (3.12.3)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.12.0)
40
+ rspec-support (3.12.0)
41
+ rubocop (1.44.1)
42
+ json (~> 2.3)
43
+ parallel (~> 1.10)
44
+ parser (>= 3.2.0.0)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.8, < 3.0)
47
+ rexml (>= 3.2.5, < 4.0)
48
+ rubocop-ast (>= 1.24.1, < 2.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 2.4.0, < 3.0)
51
+ rubocop-ast (1.24.1)
52
+ parser (>= 3.1.1.0)
53
+ rubocop-capybara (2.17.0)
54
+ rubocop (~> 1.41)
55
+ rubocop-rake (0.6.0)
56
+ rubocop (~> 1.0)
57
+ rubocop-rspec (2.18.1)
58
+ rubocop (~> 1.33)
59
+ rubocop-capybara (~> 2.17)
60
+ ruby-progressbar (1.11.0)
61
+ ruby2_keywords (0.0.5)
62
+ unicode-display_width (2.4.2)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ faraday (~> 2.0)
69
+ faraday-multipart
70
+ hiya!
71
+ rake (~> 13.0)
72
+ rspec (~> 3.0)
73
+ rubocop (~> 1.21)
74
+ rubocop-rake
75
+ rubocop-rspec
76
+
77
+ BUNDLED WITH
78
+ 2.4.4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 iiil-io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # Hiya
2
+
3
+ iiil.io SDK
4
+
5
+ ## Installation
6
+
7
+ You can add it to your Gemfile with:
8
+
9
+ $ gem install hiya
10
+
11
+ ## Configure
12
+
13
+ Override any of these defaults in `config/initializers/clearance.rb`:
14
+
15
+ ```ruby
16
+ Hiya.configure do |config|
17
+ config.api_url = 'https://api.iiil.io/v1'
18
+
19
+ # source: only support api/line/telegram/messenger
20
+ config.source = 'api'
21
+ end
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### URL - create URL short link
27
+
28
+ ``` ruby
29
+ links = [
30
+ { url: 'https://www.google.coom', weight: 1 }
31
+ ]
32
+ Hiya::Url.new.create(links)
33
+ ```
34
+
35
+ ### Image - create images short link
36
+
37
+ ``` ruby
38
+ paths = [
39
+ '/Users/username/Desktop/aaa.jpg',
40
+ '/Users/username/Desktop/bbb.png',
41
+ '/Users/username/Desktop/ccc.gif'
42
+ ]
43
+ Hiya::Image.new.create(paths, {
44
+ attach: { password: '1234', password_note: 'today', expired_num: 300, view_count_limit: 100 },
45
+ post: { content: "haha\nhttps://www.google.com" }
46
+ })
47
+ ```
48
+
49
+ ### Video - create videos short link
50
+
51
+ ``` ruby
52
+ paths = [
53
+ '/Users/username/Desktop/aaa.mp4',
54
+ '/Users/username/Desktop/bbb.mp4'
55
+ ]
56
+ Hiya::Video.new.create(paths, {
57
+ attach: { password: '1234', password_note: 'today', expired_num: 300, view_count_limit: 100 },
58
+ post: { content: "yoyo\nhttps://www.google.com" }
59
+ })
60
+ ```
61
+
62
+ ### Audio - create audios short link
63
+
64
+ ``` ruby
65
+ paths = [
66
+ '/Users/username/Desktop/aaa.mp3',
67
+ '/Users/username/Desktop/bbb.mp3',
68
+ '/Users/username/Desktop/ccc.mp3'
69
+ ]
70
+ Hiya::Audio.new.create(paths, {
71
+ attach: { password: '1234', password_note: 'today', expired_num: 300, view_count_limit: 100 },
72
+ post: { content: "yoyo\nhttps://www.google.com" }
73
+ })
74
+ ```
75
+
76
+ ## Development
77
+
78
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
79
+
80
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
81
+
82
+ ## Contributing
83
+
84
+ Bug reports and pull requests are welcome on GitHub at https://github.com/iiil-io/hiya.
85
+
86
+ ## License
87
+
88
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday/multipart'
4
+
5
+ module Hiya
6
+ class AttachBase < Base
7
+ # files: Array[String]: ['/path/to/file1', '/path/to/file2', ...]
8
+ # opts: Hash: {
9
+ # attach: Hash: {
10
+ # password: String: '1234'
11
+ # password_note: String: 'today'
12
+ # expired_num: Integer: 3600
13
+ # view_count_limit: Integer: 100
14
+ # }
15
+ # post: Hash: {
16
+ # content: String: 'This is post content'
17
+ # }
18
+ # }
19
+ def create(files, opts = {})
20
+ return unless files.is_a?(Array)
21
+
22
+ @files = files
23
+ @opts = opts
24
+
25
+ response = conn.post(url) do |req|
26
+ req.body = create_params
27
+ end
28
+ Oj.load(response.body, symbol_keys: true)
29
+ rescue StandardError => _e
30
+ {}
31
+ end
32
+
33
+ def conn
34
+ @conn ||= Faraday.new(api_url) do |f|
35
+ f.request :authorization, 'Bearer', -> { token }
36
+ f.request :multipart
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ attr_reader :files, :opts, :params
43
+
44
+ def setup
45
+ super
46
+
47
+ @params = { attach: {}, source: source }
48
+ end
49
+
50
+ def create_params
51
+ params.merge!(opts)
52
+ params[:attach][:files] = make_files
53
+ params
54
+ end
55
+
56
+ def make_files
57
+ files.map do |file|
58
+ Faraday::Multipart::FilePart.new(make_io(file), 'application/octet-stream')
59
+ end
60
+ end
61
+
62
+ def make_io(path_or_io)
63
+ if path_or_io.is_a?(String)
64
+ ::File.open(path_or_io, binmode: true)
65
+ elsif defined?(Pathname) && path_or_io.is_a?(Pathname)
66
+ path_or_io.open(binmode: true)
67
+ else
68
+ path_or_io
69
+ end
70
+ end
71
+ end
72
+ end
data/lib/hiya/audio.rb ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hiya
4
+ class Audio < AttachBase
5
+ # files: Array[String]: ['/path/to/file1', '/path/to/file2', ...]
6
+ # opts: Hash: {
7
+ # attach: Hash: {
8
+ # password: String: '1234'
9
+ # password_note: String: 'today'
10
+ # expired_num: Integer: 3600
11
+ # view_count_limit: Integer: 100
12
+ # }
13
+ # post: Hash: {
14
+ # content: String: 'This is post content'
15
+ # }
16
+ # }
17
+ def create(files, opts = {})
18
+ super(files, opts)
19
+ end
20
+ end
21
+ end
data/lib/hiya/base.rb ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # require_relative 'url'
4
+
5
+ module Hiya
6
+ class Base
7
+ def initialize(token = nil)
8
+ @token = token
9
+
10
+ setup
11
+ end
12
+
13
+ attr_reader :source, :api_url, :token
14
+
15
+ private
16
+
17
+ def setup
18
+ @api_url = Hiya.configuration.api_url
19
+ @source = Hiya.configuration.source
20
+ end
21
+
22
+ def url
23
+ "/v1/links/#{api_url_name}"
24
+ end
25
+
26
+ # url/image/video/audio
27
+ def api_url_name
28
+ self.class.name.split('::').last.downcase
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hiya
4
+ class Configuration
5
+ # API URL
6
+ attr_accessor :api_url
7
+
8
+ # Source from API/Line/Telegram
9
+ attr_accessor :source
10
+
11
+ def initialize
12
+ @api_url = 'https://api.iiil.io/v1'
13
+ @source = 'api'
14
+ end
15
+ end
16
+
17
+ # @return [Hiya::Configuration] Hiya's current configuration
18
+ def self.configuration
19
+ @configuration ||= Configuration.new
20
+ end
21
+
22
+ # Set Hiya's configuration
23
+ # @param config [Hiya::Configuration]
24
+ def self.configuration=(config)
25
+ @configuration = config
26
+ end
27
+
28
+ # Modify Hiya's current configuration
29
+ # @yield [Hiya::Configuration] config current Hiya config
30
+ # ```
31
+ # Hiya.configure do |config|
32
+ # config.routes = false
33
+ # end
34
+ # ```
35
+ def self.configure
36
+ yield configuration
37
+ end
38
+ end
data/lib/hiya/image.rb ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hiya
4
+ class Image < AttachBase
5
+ # files: Array[String]: ['/path/to/file1', '/path/to/file2', ...]
6
+ # opts: Hash: {
7
+ # attach: Hash: {
8
+ # password: String: '1234'
9
+ # password_note: String: 'today'
10
+ # expired_num: Integer: 3600
11
+ # view_count_limit: Integer: 100
12
+ # }
13
+ # post: Hash: {
14
+ # content: String: 'This is post content'
15
+ # }
16
+ # }
17
+ def create(files, opts = {})
18
+ super(files, opts)
19
+ end
20
+ end
21
+ end
data/lib/hiya/url.rb ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hiya
4
+ class Url < Base
5
+ # links: Array[Hash]: [{ url: 'https://google.com', weight: 1 }, ...]
6
+ def create(links)
7
+ params = { links: links, source: source }
8
+
9
+ response = conn.post(url) do |req|
10
+ req.body = params.to_json
11
+ end
12
+ Oj.load(response.body, symbol_keys: true)
13
+ rescue StandardError => _e
14
+ {}
15
+ end
16
+
17
+ private
18
+
19
+ def conn
20
+ @conn ||= Faraday.new(api_url) do |f|
21
+ f.request :authorization, 'Bearer', -> { token }
22
+ f.request :json
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hiya
4
+ VERSION = '0.1.0'
5
+ end
data/lib/hiya/video.rb ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hiya
4
+ class Video < AttachBase
5
+ # files: Array[String]: ['/path/to/file1', '/path/to/file2', ...]
6
+ # opts: Hash: {
7
+ # attach: Hash: {
8
+ # password: String: '1234'
9
+ # password_note: String: 'today'
10
+ # expired_num: Integer: 3600
11
+ # view_count_limit: Integer: 100
12
+ # }
13
+ # post: Hash: {
14
+ # content: String: 'This is post content'
15
+ # }
16
+ # }
17
+ def create(files, opts = {})
18
+ super(files, opts)
19
+ end
20
+ end
21
+ end
data/lib/hiya.rb ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'hiya/version'
4
+ require_relative 'hiya/configuration'
5
+ require_relative 'hiya/base'
6
+ require_relative 'hiya/attach_base'
7
+ require_relative 'hiya/url'
8
+ require_relative 'hiya/image'
9
+ require_relative 'hiya/video'
10
+ require_relative 'hiya/audio'
11
+
12
+ module Hiya
13
+ class Error < StandardError; end
14
+ # Your code goes here...
15
+ end
data/sig/hiya.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Hiya
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hiya
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-03-26 00:00:00.000000000 Z
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: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday-multipart
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Simple, Fast, Safe, Private URL Shortener
42
+ email:
43
+ - service@iiil.io
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rspec"
49
+ - ".rubocop.yml"
50
+ - ".vscode/settings.json"
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE
54
+ - README.md
55
+ - Rakefile
56
+ - lib/hiya.rb
57
+ - lib/hiya/attach_base.rb
58
+ - lib/hiya/audio.rb
59
+ - lib/hiya/base.rb
60
+ - lib/hiya/configuration.rb
61
+ - lib/hiya/image.rb
62
+ - lib/hiya/url.rb
63
+ - lib/hiya/version.rb
64
+ - lib/hiya/video.rb
65
+ - sig/hiya.rbs
66
+ homepage: https://github.com/iiil-io/hiya
67
+ licenses:
68
+ - MIT
69
+ metadata:
70
+ homepage_uri: https://github.com/iiil-io/hiya
71
+ source_code_uri: https://github.com/iiil-io/hiya
72
+ changelog_uri: https://github.com/iiil-io/hiya
73
+ rubygems_mfa_required: 'true'
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 2.6.0
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubygems_version: 3.3.7
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: URL Shortener
93
+ test_files: []