line_gundam 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -6
- data/Gemfile.lock +77 -0
- data/lib/line_gundam/client.rb +25 -0
- data/lib/line_gundam/version.rb +1 -1
- data/lib/line_gundam.rb +13 -7
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 174d667b1086d6039540c6774530cd46307b1d6b23317c1024b5cb94b421ade5
|
4
|
+
data.tar.gz: a1867481c70c11e3294c5d6365f695cd997d948cdece997ee21d3c8cd7329d13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c4c6c027d28567362c415649e155c35fc1d089b63c4f92a40dc990c4889939edd8df6c5ecef43a7da663e175d60b2976ebe5fb182695d867fbea6a8e5f760f4
|
7
|
+
data.tar.gz: 032614fe28f529e138be743377eb14efac2ab11b19efb8ca7264a8f9f46db53ea0ece5fa3ef2839572ceb2501e5bd17ad0de327125c29d719401806438249513
|
data/Gemfile
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in line_gundam.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
9
|
-
|
10
|
-
gem
|
11
|
-
|
12
|
-
gem "rubocop", "~> 1.21"
|
8
|
+
gem 'rake', '~> 13.0'
|
9
|
+
gem 'rspec', '~> 3.0'
|
10
|
+
gem 'rubocop', '~> 1.21'
|
11
|
+
gem 'faraday'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
line_gundam (0.1.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
diff-lcs (1.4.4)
|
11
|
+
faraday (1.8.0)
|
12
|
+
faraday-em_http (~> 1.0)
|
13
|
+
faraday-em_synchrony (~> 1.0)
|
14
|
+
faraday-excon (~> 1.1)
|
15
|
+
faraday-httpclient (~> 1.0.1)
|
16
|
+
faraday-net_http (~> 1.0)
|
17
|
+
faraday-net_http_persistent (~> 1.1)
|
18
|
+
faraday-patron (~> 1.0)
|
19
|
+
faraday-rack (~> 1.0)
|
20
|
+
multipart-post (>= 1.2, < 3)
|
21
|
+
ruby2_keywords (>= 0.0.4)
|
22
|
+
faraday-em_http (1.0.0)
|
23
|
+
faraday-em_synchrony (1.0.0)
|
24
|
+
faraday-excon (1.1.0)
|
25
|
+
faraday-httpclient (1.0.1)
|
26
|
+
faraday-net_http (1.0.1)
|
27
|
+
faraday-net_http_persistent (1.2.0)
|
28
|
+
faraday-patron (1.0.0)
|
29
|
+
faraday-rack (1.0.0)
|
30
|
+
multipart-post (2.1.1)
|
31
|
+
parallel (1.21.0)
|
32
|
+
parser (3.0.3.0)
|
33
|
+
ast (~> 2.4.1)
|
34
|
+
rainbow (3.0.0)
|
35
|
+
rake (13.0.6)
|
36
|
+
regexp_parser (2.1.1)
|
37
|
+
rexml (3.2.5)
|
38
|
+
rspec (3.10.0)
|
39
|
+
rspec-core (~> 3.10.0)
|
40
|
+
rspec-expectations (~> 3.10.0)
|
41
|
+
rspec-mocks (~> 3.10.0)
|
42
|
+
rspec-core (3.10.1)
|
43
|
+
rspec-support (~> 3.10.0)
|
44
|
+
rspec-expectations (3.10.1)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.10.0)
|
47
|
+
rspec-mocks (3.10.2)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.10.0)
|
50
|
+
rspec-support (3.10.3)
|
51
|
+
rubocop (1.23.0)
|
52
|
+
parallel (~> 1.10)
|
53
|
+
parser (>= 3.0.0.0)
|
54
|
+
rainbow (>= 2.2.2, < 4.0)
|
55
|
+
regexp_parser (>= 1.8, < 3.0)
|
56
|
+
rexml
|
57
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
58
|
+
ruby-progressbar (~> 1.7)
|
59
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
60
|
+
rubocop-ast (1.13.0)
|
61
|
+
parser (>= 3.0.1.1)
|
62
|
+
ruby-progressbar (1.11.0)
|
63
|
+
ruby2_keywords (0.0.5)
|
64
|
+
unicode-display_width (2.1.0)
|
65
|
+
|
66
|
+
PLATFORMS
|
67
|
+
x86_64-darwin-20
|
68
|
+
|
69
|
+
DEPENDENCIES
|
70
|
+
faraday
|
71
|
+
line_gundam!
|
72
|
+
rake (~> 13.0)
|
73
|
+
rspec (~> 3.0)
|
74
|
+
rubocop (~> 1.21)
|
75
|
+
|
76
|
+
BUNDLED WITH
|
77
|
+
2.2.32
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LineGundam
|
4
|
+
class Client
|
5
|
+
class << self
|
6
|
+
def send_message(type: 'text', text: [])
|
7
|
+
client = Faraday.new
|
8
|
+
client.post(LineGundam.configure.broadcast_url, payload(type, text), headers)
|
9
|
+
end
|
10
|
+
|
11
|
+
def payload(type, text)
|
12
|
+
{
|
13
|
+
messages: text.map { |txt| { type: type, text: txt } }
|
14
|
+
}.to_json
|
15
|
+
end
|
16
|
+
|
17
|
+
def headers
|
18
|
+
{
|
19
|
+
'Authorization' => "Bearer #{LineGundam.configure.access_token}",
|
20
|
+
'Content-Type' => 'application/json'
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/line_gundam/version.rb
CHANGED
data/lib/line_gundam.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'line_gundam/version'
|
4
|
+
require 'json'
|
5
|
+
require 'faraday'
|
6
|
+
|
7
|
+
Faraday.default_adapter = :net_http
|
4
8
|
|
5
9
|
module LineGundam
|
10
|
+
autoload :Client, 'line_gundam/client'
|
11
|
+
|
6
12
|
class Configuration
|
7
13
|
BROADCAST_URL = 'https://api.line.me/v2/bot/message/broadcast'
|
8
14
|
|
9
|
-
attr_accessor :access_token
|
10
|
-
attr_accessor :broadcast_url
|
15
|
+
attr_accessor :access_token, :broadcast_url
|
11
16
|
|
12
17
|
def initialize
|
13
18
|
@access_token = ''
|
@@ -16,15 +21,16 @@ module LineGundam
|
|
16
21
|
end
|
17
22
|
|
18
23
|
class << self
|
19
|
-
def configuration
|
20
|
-
@configuration ||= Configuration.new
|
21
|
-
end
|
22
|
-
|
23
24
|
def configure
|
24
25
|
block_given? ? yield(configuration) : configuration
|
25
26
|
end
|
26
|
-
end
|
27
27
|
|
28
|
+
private
|
29
|
+
|
30
|
+
def configuration
|
31
|
+
@configuration ||= Configuration.new
|
32
|
+
end
|
33
|
+
end
|
28
34
|
|
29
35
|
class Error < StandardError; end
|
30
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: line_gundam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Cheng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Line message api client
|
14
14
|
email:
|
@@ -22,12 +22,14 @@ files:
|
|
22
22
|
- CHANGELOG.md
|
23
23
|
- CODE_OF_CONDUCT.md
|
24
24
|
- Gemfile
|
25
|
+
- Gemfile.lock
|
25
26
|
- LICENSE.txt
|
26
27
|
- README.md
|
27
28
|
- Rakefile
|
28
29
|
- bin/console
|
29
30
|
- bin/setup
|
30
31
|
- lib/line_gundam.rb
|
32
|
+
- lib/line_gundam/client.rb
|
31
33
|
- lib/line_gundam/version.rb
|
32
34
|
homepage: https://github.com/ericcheng1108/line_gundam
|
33
35
|
licenses:
|