episopass 0.1.5 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 621909b87d7a4b339319627fa93befce9c2e8e26c8f56b5cff194b487faced20
4
- data.tar.gz: 369bc28612bdab465479080a949ab464c94f53c16fa6f403fd97c6002d8232ba
3
+ metadata.gz: 84f4a312a4e679bd3ec6de04ed968dadc344799083943370d670c230d97cc7ff
4
+ data.tar.gz: 820c09522dba34702b012332afb010573b21510f03652fb3c47c42013c2efdce
5
5
  SHA512:
6
- metadata.gz: 664d34162eb36915333317dbd479bf7a08f680057840438c2e497ceabd101d9c2d56348017db0f103590d5f74893b094196f5f1d09603a299e9d38a52b7f25f1
7
- data.tar.gz: c254fbfddf9357815902ac47cf64aabf6092fbe5435a6ffd920db891d7ee01f7a7915632c937f709190fd76bab1c265ae40cc975082ad3e119401e8c9cf0321e
6
+ metadata.gz: fdedb95e684847f4f4003fbdc803b8cd6af7d87b992aec6625d8d9fc01d5716a1117112353ed3ffb67a4a92de6fcee1eb113fb12e3e4ceb3ddf164893ee81e0c
7
+ data.tar.gz: 1c2b05f9e1ee63eea15139c664a9daa4eb93b7321c49230ad005b579de9d2000e0f9d4a63c50f2b777a1362f2ff8d303a8e31e431705179d8c19312f2bb0c0a6
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,63 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # % episozip [-P episopassのHTML] out.episopass file1 file2
4
+ #
5
+
6
+ path = "#{__dir__}/../data/sample.html" # gemのファイル指定する方法は?
7
+ localpath = File.expand_path("~/.episopass.html")
8
+ path = localpath if File.exist?(localpath)
9
+
10
+ if ARGV[0] == "-P"
11
+ path = ARGV[1]
12
+ ARGV.shift 2
13
+ end
14
+
15
+ html = ''
16
+ if path =~ /^http/
17
+ html = Net::HTTP.get(URI.parse(arg))
18
+ elsif File.exist?(path)
19
+ html = File.read(path)
20
+ end
21
+
22
+ if html == ''
23
+ STDERR.puts "EpisoPass問題(#{path})がみつかりません"
24
+ exit
25
+ end
26
+
27
+ dir = "/tmp/EpisoPassDir#{$$}"
28
+ if File.exist?(dir)
29
+ STDERR.puts "もう一度試してください"
30
+ exit
31
+ end
32
+
33
+ system "mkdir #{dir}"
34
+
35
+ File.open("#{dir}/episopass.html","w"){ |f|
36
+ f.print html
37
+ }
38
+
39
+ zipfile = ARGV.shift
40
+ if !zipfile
41
+ STDERR.puts "出力ファイル名を指定してください"
42
+ system "/bin/rm -r #{dir}"
43
+ exit
44
+ end
45
+ if zipfile !~ /\.episopass$/
46
+ STDERR.puts "出力ファイルの拡張子は.episopassにしてください"
47
+ system "/bin/rm -r #{dir}"
48
+ exit
49
+ end
50
+ if File.exist?(zipfile)
51
+ STDERR.puts "#{zipfile}が既に存在します"
52
+ system "/bin/rm -r #{dir}"
53
+ exit
54
+ end
55
+
56
+ system "zip -e -P `episopass #{dir}/episopass.html` #{dir}/episopass.zip #{ARGV.join(' ')}"
57
+ system "pushd #{dir} > /dev/null; zip #{zipfile} episopass.zip episopass.html; popd > /dev/null"
58
+ system "/bin/mv #{dir}/#{zipfile} ."
59
+ system "/bin/rm -r #{dir}"
60
+
61
+
62
+
63
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EpisoPass
4
- VERSION = "0.1.5"
4
+ VERSION = "0.2.2" # 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.5
4
+ version: 0.2.2
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