episopass 0.1.4 → 0.2.1

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
2
  SHA256:
3
- metadata.gz: 6cb4e8275603f1054968fcfa6a54b3dcd68e5d0df233d12a740bbb28ba54f489
4
- data.tar.gz: 5e1ef16007c5ef572cb1c65445dd113978501bbcd502d950c86840a5879a48ea
3
+ metadata.gz: 3dba637310d7aa47252abb24738dee405a01acf5a919bd966b3b37c182da6bd4
4
+ data.tar.gz: d6acd418f315888401a2007009a415e6437d031a357f9cfebccf5e4f69e37a81
5
5
  SHA512:
6
- metadata.gz: c605d9823d5f3c3bae03de2cd750def929f9e74237ca309086bce8723685fca528c3f59b6971a63bb9278ebb2378eb3e92c037d8e19fd48e8ea2716c18cb779c
7
- data.tar.gz: f2276c2841069ed8e8ebead1dded1e76bac3e41d188ee73be36a92fda09d900bd800fa88ed0751e81af6c9daf49d511fe5b8fbdcd674da0708773fcae8521768
6
+ metadata.gz: c857f952721210ede586918266842f2b9d5a61f52a549712a5b68354b77920f9e35f065deca21475a781b311ca52c5148e08690b3ec8be148ecd4189f88ba7fe
7
+ data.tar.gz: cd1cb278c1bd3261902b528c92483ce3c05ae740fe2572d3931fe52a517f0179ac81ec822f786d6a5364628e55a21851f6f3ac2f6c575180d47914e1de3459c0
File without changes
data/exe/episopass CHANGED
@@ -1,8 +1,29 @@
1
1
  #!/usr/bin/env ruby
2
+ #
3
+ # コマンドラインからEpisoPassを開いてパスワード文字列を得る
4
+ #
2
5
 
6
+ require 'net/http'
7
+ require 'uri'
3
8
  require 'webrick'
4
9
  require "episopass"
5
10
 
11
+ html = ''
12
+ arg = ARGV[0]
13
+ if arg
14
+ if arg =~ /^http/
15
+ html = Net::HTTP.get(URI.parse(arg))
16
+ elsif File.exist?(arg)
17
+ html = File.read(arg)
18
+ end
19
+ else
20
+ path = "#{__dir__}/../data/sample.html" # gemのファイル指定する方法は?
21
+ localpath = File.expand_path("~/.episopass.html")
22
+ path = localpath if File.exist?(localpath)
23
+
24
+ html = File.read(path)
25
+ end
26
+
6
27
  opencmd = "open"
7
28
  opencmd = "xdg-open" if File.exist?("/usr/bin/xdg-open")
8
29
 
@@ -15,11 +36,10 @@ server = WEBrick::HTTPServer.new( # サーバを立てる
15
36
 
16
37
  # パスワード計算後に/EpisoPassResultに移動
17
38
  server.mount_proc('/EpisoPassCall') do |req, res|
18
- body = File.read("#{__dir__}/../data/EpisoPassCLI.html") # gemのファイル指定する方法は?
19
39
 
20
40
  res.status = 200
21
41
  res['Content-Type'] = 'text/html'
22
- res.body = body
42
+ res.body = html
23
43
  end
24
44
 
25
45
  # /EpisoPassResult?qwerty のような形式でパスワードを返す
data/exe/episounzip ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # % epunzip out.episopass
4
+ #
5
+
6
+ epfile = ARGV[0]
7
+ if !epfile || !File.exist?(epfile)
8
+ STDERR.puts "% epunzip file.episopass"
9
+ exit
10
+ end
11
+
12
+ dir = "/tmp/EpisoPassDir#{$$}"
13
+ if File.exist?(dir)
14
+ STDERR.puts "もう一度実行してください"
15
+ exit
16
+ end
17
+ Dir.mkdir(dir)
18
+
19
+ path = File.expand_path(epfile)
20
+ system "pushd #{dir} > /dev/null; unzip #{path} ; unzip -P `episopass episopass.html` episopass.zip; rm episopass.zip episopass.html ; popd > /dev/null"
21
+
22
+ system "/bin/mv #{dir}/* ."
23
+ system "/bin/rm -r #{dir}"
24
+
25
+
26
+
27
+
28
+
data/exe/episozip ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # % episozip [-P episopassのHTML] out.episopass file1 file2
4
+ #
5
+
6
+ path = File.expand_path("~/.episopass.html")
7
+ if ARGV[0] == "-P"
8
+ path = ARGV[1]
9
+ ARGV.shift 2
10
+ end
11
+
12
+ html = ''
13
+ if path =~ /^http/
14
+ html = Net::HTTP.get(URI.parse(arg))
15
+ elsif File.exist?(path)
16
+ html = File.read(path)
17
+ end
18
+
19
+ if html == ''
20
+ STDERR.puts "EpisoPass問題(#{path})がみつかりません"
21
+ exit
22
+ end
23
+
24
+ dir = "/tmp/EpisoPassDir#{$$}"
25
+ if File.exist?(dir)
26
+ STDERR.puts "もう一度試してください"
27
+ exit
28
+ end
29
+
30
+ system "mkdir #{dir}"
31
+
32
+ File.open("#{dir}/episopass.html","w"){ |f|
33
+ f.print html
34
+ }
35
+
36
+ zipfile = ARGV.shift
37
+ if !zipfile
38
+ STDERR.puts "出力ファイル名を指定してください"
39
+ system "/bin/rm -r #{dir}"
40
+ exit
41
+ end
42
+ if zipfile !~ /\.episopass$/
43
+ STDERR.puts "出力ファイルの拡張子は.episopassにしてください"
44
+ system "/bin/rm -r #{dir}"
45
+ exit
46
+ end
47
+ if File.exist?(zipfile)
48
+ STDERR.puts "#{zipfile}が既に存在します"
49
+ system "/bin/rm -r #{dir}"
50
+ exit
51
+ end
52
+
53
+ system "zip -e -P `episopass #{dir}/episopass.html` #{dir}/episopass.zip #{ARGV.join(' ')}"
54
+ system "pushd #{dir} > /dev/null; zip #{zipfile} episopass.zip episopass.html; popd > /dev/null"
55
+ system "/bin/mv #{dir}/#{zipfile} ."
56
+ system "/bin/rm -r #{dir}"
57
+
58
+
59
+
60
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Episopass
4
- VERSION = "0.1.4"
3
+ module EpisoPass
4
+ VERSION = "0.2.1" # episozip追加
5
5
  end
metadata CHANGED
@@ -1,25 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: episopass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshiyuki Masui
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-08 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Run EpisoPass from CLI
14
14
  email:
15
15
  - masui@pitecan.com
16
16
  executables:
17
17
  - episopass
18
+ - episounzip
19
+ - episozip
18
20
  extensions: []
19
21
  extra_rdoc_files: []
20
22
  files:
21
- - data/EpisoPassCLI.html
23
+ - data/sample.html
22
24
  - exe/episopass
25
+ - exe/episounzip
26
+ - exe/episozip
23
27
  - lib/episopass.rb
24
28
  - lib/episopass/version.rb
25
29
  homepage: http://EpisoPass.com
@@ -43,8 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
47
  - !ruby/object:Gem::Version
44
48
  version: '0'
45
49
  requirements: []
46
- rubyforge_project:
47
- rubygems_version: 2.7.6.2
50
+ rubygems_version: 3.0.3
48
51
  signing_key:
49
52
  specification_version: 4
50
53
  summary: Run EpisoPass from CLI