liff_selector 0.4.3 → 1.0.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
- SHA1:
3
- metadata.gz: 82ae8cb9d90a8038ac4e7a7db1a457bac9a2c969
4
- data.tar.gz: 78b970d3a9211d73e201d42669a89e8f21c66da7
2
+ SHA256:
3
+ metadata.gz: 3c42b61e5b658792800dfb4e2bdcd7303ea1a9122e2be3e7bf83663c7cab9fcb
4
+ data.tar.gz: 748ad413ce3643772a4161ba62149eb5b49db19a102f31e01a2500eeb76428cd
5
5
  SHA512:
6
- metadata.gz: e375fb649f76a14301d245334c6c00b255f20a9835ce18942db822d2728b3e118511b14e770ec57778bd075987aa2bb1b6eb15612fd7fe069b0200516eb6cb15
7
- data.tar.gz: 87f07fd01d56a5f9cb684841a9c0d0cc7418d5572f28e134756878bb1f50888d32ed96815d599c8ddd0ef8c729e3a4ee87f3ff44e106a241f88dcbf9f4571d4b
6
+ metadata.gz: 8e1f15d470b3553df37663374292c052690f2ee81cd3f0ecbc185c8dfe264b285e9499204e262e6c9c53104eefa766b25e2f01905a6ad1606074ed7cc7afe19b
7
+ data.tar.gz: f1dfacfbb58658d770160914e86ce59218051733f159867181ae47f3af1a0d94c4af3fd6858a512c0f0f7fde94dfbae14f1d9a31862ce7f829ad03f4b067da03
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile CHANGED
@@ -5,4 +5,10 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5
5
  # Specify your gem's dependencies in liff_selector.gemspec
6
6
  gemspec
7
7
  gem 'rest-client'
8
- gem 'dotenv'
8
+ gem 'dotenv'
9
+
10
+ group :test do
11
+ # HTTP requests用のモックアップを作ってくれる
12
+ gem 'rspec'
13
+ gem 'webmock'
14
+ end
data/Gemfile.lock CHANGED
@@ -1,23 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- liff_selector (0.2.0)
4
+ liff_selector (1.0.0)
5
5
  dotenv
6
6
  rest-client
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
+ addressable (2.5.2)
12
+ public_suffix (>= 2.0.2, < 4.0)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
11
15
  diff-lcs (1.3)
12
16
  domain_name (0.5.20180417)
13
17
  unf (>= 0.0.5, < 1.0.0)
14
18
  dotenv (2.4.0)
19
+ hashdiff (0.3.7)
15
20
  http-cookie (1.0.3)
16
21
  domain_name (~> 0.5)
17
22
  mime-types (3.1)
18
23
  mime-types-data (~> 3.2015)
19
24
  mime-types-data (3.2016.0521)
20
25
  netrc (0.11.0)
26
+ public_suffix (3.0.2)
21
27
  rake (10.5.0)
22
28
  rest-client (2.0.2)
23
29
  http-cookie (>= 1.0.2, < 2.0)
@@ -36,9 +42,14 @@ GEM
36
42
  diff-lcs (>= 1.2.0, < 2.0)
37
43
  rspec-support (~> 3.7.0)
38
44
  rspec-support (3.7.1)
45
+ safe_yaml (1.0.4)
39
46
  unf (0.1.4)
40
47
  unf_ext
41
48
  unf_ext (0.0.7.5)
49
+ webmock (3.4.2)
50
+ addressable (>= 2.3.6)
51
+ crack (>= 0.3.2)
52
+ hashdiff
42
53
 
43
54
  PLATFORMS
44
55
  ruby
@@ -49,7 +60,8 @@ DEPENDENCIES
49
60
  liff_selector!
50
61
  rake (~> 10.0)
51
62
  rest-client
52
- rspec (~> 3.0)
63
+ rspec
64
+ webmock
53
65
 
54
66
  BUNDLED WITH
55
- 1.16.0
67
+ 1.16.4
@@ -1,3 +1,3 @@
1
1
  module LiffSelector
2
- VERSION = "0.4.3"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/liff_selector.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "liff_selector/version"
2
2
  require 'json'
3
3
  require 'rest-client'
4
+ require 'dotenv/load'
4
5
 
5
6
  module LiffSelector
6
7
  @token = ENV['LINE_TOKEN']
@@ -34,7 +35,7 @@ module LiffSelector
34
35
  def self.show
35
36
  puts "id liffId\t\ttype\turl"
36
37
  all_apps.each_with_index do |app, i|
37
- puts "#{i+1}. #{app['liffId']}\t#{app['view']['type']}\t#{app['view']['url']}"
38
+ puts "#{i+1}. #{app["liffId"]}\t#{app["view"]["type"]}\t#{app["view"]["url"]}"
38
39
  end
39
40
  end
40
41
 
@@ -59,7 +60,6 @@ module LiffSelector
59
60
  end
60
61
 
61
62
  def self.upload(type:, url:)
62
- raise ArgumentError, 'not correct uri' unless correct_url?(url)
63
63
  raise ArgumentError, 'not correct type please choose [compact, tall, full]' unless ["compact", "tall", "full"].include?(type)
64
64
  puts '> make liff app'
65
65
 
@@ -67,7 +67,7 @@ module LiffSelector
67
67
  response = RestClient.post(@request_url, {view: {type: type, url: url } }.to_json, {:Authorization => "bearer #{@token}", :content_type => :json})
68
68
  result = JSON.parse(response)
69
69
 
70
- puts '> [SUCESS] make app'
70
+ puts '> [SUCCESS] make app'
71
71
  puts "> app uri : line://app/#{result['liffId']}"
72
72
  end
73
73
 
@@ -97,13 +97,14 @@ liff_select clean : delete same url and type apps
97
97
  liff_select upload _TYPE_ _URL_ : upload new apps with type and url.
98
98
  : type is <type:compact|tall:|full>
99
99
  liff_select delete _LIFF_ID_ : delete app _LIFF_ID_ is referenced show number.
100
- liff_select help : liff_select helps
100
+ liff_select help : commands helps
101
101
  liff_select new _html_name_ : make liff sample html
102
102
  EOS
103
103
  puts help
104
104
  end
105
105
 
106
106
  def self.delete(liff_id:)
107
+ # [TODO] undefined liff_id
107
108
  app = all_apps[liff_id.to_i-1]
108
109
  puts "#{liff_id}. #{app['liffId']}\t#{app['view']['type']}\t#{app['view']['url']}"
109
110
 
@@ -114,11 +115,8 @@ EOS
114
115
 
115
116
  # http request
116
117
  def self.all_apps
117
- res = JSON.parse(RestClient.get @request_url, { :Authorization => "bearer #{@token}" })['apps']
118
- end
119
-
120
- def self.correct_url?(url)
121
- uri = URI.parse(url)
122
- status_code = RestClient.get(url)
118
+ JSON.parse(RestClient.get @request_url, { :Authorization => "bearer #{@token}" })['apps']
119
+ rescue => e
120
+ []
123
121
  end
124
122
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liff_selector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 4geru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-23 00:00:00.000000000 Z
11
+ date: 2018-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -89,6 +89,7 @@ extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
91
  - ".gitignore"
92
+ - ".rspec"
92
93
  - CODE_OF_CONDUCT.md
93
94
  - Gemfile
94
95
  - Gemfile.lock
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  version: '0'
124
125
  requirements: []
125
126
  rubyforge_project:
126
- rubygems_version: 2.6.8
127
+ rubygems_version: 2.7.7
127
128
  signing_key:
128
129
  specification_version: 4
129
130
  summary: Write a short summary, because RubyGems requires one.