episopass 0.1.3

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.
data/exe/episopass ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'webrick'
4
+ require "episopass"
5
+
6
+ opencmd = "open"
7
+ opencmd = "xdg-open" if File.exist?("/usr/bin/xdg-open")
8
+
9
+ server = WEBrick::HTTPServer.new( # サーバを立てる
10
+ :Port => 8000,
11
+ :HTTPVersion => WEBrick::HTTPVersion.new('1.1'),
12
+ :AccessLog => [[open(IO::NULL, 'w'), '']], # アクセスログを出力しない
13
+ :Logger => WEBrick::Log.new("/dev/null")
14
+ )
15
+
16
+ # パスワード計算後に/EpisoPassResultに移動
17
+ server.mount_proc('/EpisoPassCall') do |req, res|
18
+ # body = File.read(File.expand_path('~/Passwords/EpisoPassCLI.html')) # パスワード計算するHTML
19
+
20
+ body = File.read("#{__dir__}/../data/EpisoPassCLI.html")
21
+
22
+ res.status = 200
23
+ res['Content-Type'] = 'text/html'
24
+ res.body = body
25
+ end
26
+
27
+ # /EpisoPassResult?qwerty のような形式でパスワードを返す
28
+ server.mount_proc('/EpisoPassResult') do |req, res|
29
+ password = URI.decode(req.query_string)
30
+ puts password # 結果を標準出力
31
+
32
+ server.shutdown
33
+ end
34
+
35
+ # ブラウザで /EpisoPassCall にアクセスしてパスワード計算画面を開く
36
+ system "#{opencmd} http://localhost:8000/EpisoPassCall"
37
+
38
+ Signal.trap('INT'){server.shutdown}
39
+ server.start
40
+
data/lib/episopass.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "episopass/version"
4
+
5
+ module Episopass
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Episopass
4
+ VERSION = "0.1.3"
5
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: episopass
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Toshiyuki Masui
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-02-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Run EpisoPass from CLI
14
+ email:
15
+ - masui@pitecan.com
16
+ executables:
17
+ - episopass
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - data/EpisoPassCLI.html
22
+ - exe/episopass
23
+ - lib/episopass.rb
24
+ - lib/episopass/version.rb
25
+ homepage: http://EpisoPass.com
26
+ licenses:
27
+ - MIT
28
+ metadata:
29
+ homepage_uri: http://EpisoPass.com
30
+ source_code_uri: https://github.com/masui/EpisoPass-ruby
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 2.4.0
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 2.7.6.2
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Run EpisoPass from CLI
51
+ test_files: []