Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ config/settings.local.yml
config/settings/*.local.yml
config/environments/*.local.yml

./redis/appendonly.aof
# ignore redis temp files
appendonly.aof
/redis/appendonly.aof
# ignore uploaded package files
/app/public/*
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'mock_redis' # Redis のモック。テスト実行時に使用。
gem 'config' # 環境ごとに yml の設定ファイルを作成可能。
gem 'config' # 環境ごとに yml の設定ファイルを作成可能。
gem 'rubyzip' # パッケージファイルを解凍して中のJsonをいじるために使うRailsでZipファイルを扱えるようにするGem。2009年の記事に載ってたGemなのにいま現役なのすごい。感動。
179 changes: 91 additions & 88 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.4.1)
actionpack (= 6.0.4.1)
actioncable (6.0.4.7)
actionpack (= 6.0.4.7)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.4.1)
actionpack (= 6.0.4.1)
activejob (= 6.0.4.1)
activerecord (= 6.0.4.1)
activestorage (= 6.0.4.1)
activesupport (= 6.0.4.1)
actionmailbox (6.0.4.7)
actionpack (= 6.0.4.7)
activejob (= 6.0.4.7)
activerecord (= 6.0.4.7)
activestorage (= 6.0.4.7)
activesupport (= 6.0.4.7)
mail (>= 2.7.1)
actionmailer (6.0.4.1)
actionpack (= 6.0.4.1)
actionview (= 6.0.4.1)
activejob (= 6.0.4.1)
actionmailer (6.0.4.7)
actionpack (= 6.0.4.7)
actionview (= 6.0.4.7)
activejob (= 6.0.4.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.4.1)
actionview (= 6.0.4.1)
activesupport (= 6.0.4.1)
actionpack (6.0.4.7)
actionview (= 6.0.4.7)
activesupport (= 6.0.4.7)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.4.1)
actionpack (= 6.0.4.1)
activerecord (= 6.0.4.1)
activestorage (= 6.0.4.1)
activesupport (= 6.0.4.1)
actiontext (6.0.4.7)
actionpack (= 6.0.4.7)
activerecord (= 6.0.4.7)
activestorage (= 6.0.4.7)
activesupport (= 6.0.4.7)
nokogiri (>= 1.8.5)
actionview (6.0.4.1)
activesupport (= 6.0.4.1)
actionview (6.0.4.7)
activesupport (= 6.0.4.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.4.1)
activesupport (= 6.0.4.1)
activejob (6.0.4.7)
activesupport (= 6.0.4.7)
globalid (>= 0.3.6)
activemodel (6.0.4.1)
activesupport (= 6.0.4.1)
activerecord (6.0.4.1)
activemodel (= 6.0.4.1)
activesupport (= 6.0.4.1)
activestorage (6.0.4.1)
actionpack (= 6.0.4.1)
activejob (= 6.0.4.1)
activerecord (= 6.0.4.1)
activemodel (6.0.4.7)
activesupport (= 6.0.4.7)
activerecord (6.0.4.7)
activemodel (= 6.0.4.7)
activesupport (= 6.0.4.7)
activestorage (6.0.4.7)
actionpack (= 6.0.4.7)
activejob (= 6.0.4.7)
activerecord (= 6.0.4.7)
marcel (~> 1.0.0)
activesupport (6.0.4.1)
activesupport (6.0.4.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
bcrypt (3.1.16)
bootsnap (1.9.1)
msgpack (~> 1.0)
bcrypt (3.1.17)
bootsnap (1.11.1)
msgpack (~> 1.2)
builder (3.2.4)
byebug (11.1.3)
cancancan (3.3.0)
coderay (1.1.3)
concurrent-ruby (1.1.9)
config (3.1.0)
concurrent-ruby (1.1.10)
config (4.0.0)
deep_merge (~> 1.2, >= 1.2.1)
dry-validation (~> 1.0, >= 1.0.0)
crass (1.0.6)
debase (0.2.4.1)
debase-ruby_core_source (>= 0.10.2)
debase-ruby_core_source (0.10.12)
deep_merge (1.2.1)
dry-configurable (0.13.0)
debase-ruby_core_source (0.10.14)
deep_merge (1.2.2)
dry-configurable (0.14.0)
concurrent-ruby (~> 1.0)
dry-core (~> 0.6)
dry-container (0.9.0)
Expand All @@ -81,11 +81,11 @@ GEM
dry-core (0.7.1)
concurrent-ruby (~> 1.0)
dry-inflector (0.2.1)
dry-initializer (3.0.4)
dry-initializer (3.1.1)
dry-logic (1.2.0)
concurrent-ruby (~> 1.0)
dry-core (~> 0.5, >= 0.5)
dry-schema (1.8.0)
dry-schema (1.9.1)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.13, >= 0.13.0)
dry-core (~> 0.5, >= 0.5)
Expand All @@ -98,117 +98,119 @@ GEM
dry-core (~> 0.5, >= 0.5)
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 1.0, >= 1.0.2)
dry-validation (1.7.0)
dry-validation (1.8.0)
concurrent-ruby (~> 1.0)
dry-container (~> 0.7, >= 0.7.1)
dry-core (~> 0.5, >= 0.5)
dry-initializer (~> 3.0)
dry-schema (~> 1.8, >= 1.8.0)
dry-schema (~> 1.9, >= 1.9.1)
erubi (1.10.0)
ffi (1.15.4)
globalid (0.5.2)
ffi (1.15.5)
globalid (1.0.0)
activesupport (>= 5.0)
i18n (1.8.10)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
jbuilder (2.11.2)
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.12.0)
loofah (2.16.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.1)
mini_portile2 (2.6.1)
minitest (5.14.4)
mock_redis (0.29.0)
mini_mime (1.1.2)
mini_portile2 (2.8.0)
minitest (5.15.0)
mock_redis (0.30.0)
ruby2_keywords
msgpack (1.4.2)
msgpack (1.4.5)
mysql2 (0.5.3)
nio4r (2.5.8)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
nokogiri (1.13.3)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
byebug (~> 11.0)
pry (~> 0.13.0)
puma (5.5.0)
puma (5.6.4)
nio4r (~> 2.0)
racc (1.5.2)
racc (1.6.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.4.1)
actioncable (= 6.0.4.1)
actionmailbox (= 6.0.4.1)
actionmailer (= 6.0.4.1)
actionpack (= 6.0.4.1)
actiontext (= 6.0.4.1)
actionview (= 6.0.4.1)
activejob (= 6.0.4.1)
activemodel (= 6.0.4.1)
activerecord (= 6.0.4.1)
activestorage (= 6.0.4.1)
activesupport (= 6.0.4.1)
rails (6.0.4.7)
actioncable (= 6.0.4.7)
actionmailbox (= 6.0.4.7)
actionmailer (= 6.0.4.7)
actionpack (= 6.0.4.7)
actiontext (= 6.0.4.7)
actionview (= 6.0.4.7)
activejob (= 6.0.4.7)
activemodel (= 6.0.4.7)
activerecord (= 6.0.4.7)
activestorage (= 6.0.4.7)
activesupport (= 6.0.4.7)
bundler (>= 1.3.0)
railties (= 6.0.4.1)
railties (= 6.0.4.7)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
railties (6.0.4.1)
actionpack (= 6.0.4.1)
activesupport (= 6.0.4.1)
railties (6.0.4.7)
actionpack (= 6.0.4.7)
activesupport (= 6.0.4.7)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (13.0.6)
rb-fsevent (0.11.0)
rb-fsevent (0.11.1)
rb-inotify (0.10.1)
ffi (~> 1.0)
redis (4.4.0)
redis-actionpack (5.2.0)
actionpack (>= 5, < 7)
redis (4.6.0)
redis-actionpack (5.3.0)
actionpack (>= 5, < 8)
redis-rack (>= 2.1.0, < 3)
redis-store (>= 1.1.0, < 2)
redis-rack (2.1.3)
redis-rack (2.1.4)
rack (>= 2.0.8, < 3)
redis-store (>= 1.2, < 2)
redis-store (1.9.0)
redis-store (1.9.1)
redis (>= 4, < 5)
ruby-debug-ide (0.7.3)
rake (>= 0.8.1)
ruby2_keywords (0.0.5)
ruby_dep (1.5.0)
rubyzip (2.3.2)
spring (2.1.1)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (4.0.2)
sprockets (4.0.3)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
thor (1.1.0)
thor (1.2.1)
thread_safe (0.3.6)
tzinfo (1.2.9)
thread_safe (~> 0.1)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.4.2)
zeitwerk (2.5.4)

PLATFORMS
ruby
Expand All @@ -230,6 +232,7 @@ DEPENDENCIES
rails (~> 6.0.2)
redis-actionpack
ruby-debug-ide
rubyzip
spring
spring-watcher-listen (~> 2.0.0)
tzinfo-data
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
![License](https://img.shields.io/github/license/b-editor/BackendBEditor?style=for-the-badge&logo=appveyor)
![Size](https://img.shields.io/github/repo-size/b-editor/BackendBEditor?style=for-the-badge&logo=appveyor)
## 📖 ABOUT
BEditorの拡張機能ストア用バックエンドWebAPIです
BEditorの拡張機能ストア用バックエンドWebAPIです
開発中のためまだ使用できません

## 🌟 Feature
Expand Down
32 changes: 32 additions & 0 deletions app/controllers/concerns/zipper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'zip'
#アップロードされたパッケージファイルを解凍、パッケージ情報を読み取る
module Zipper
def self.unzipping(path, output)
entries = []
new_directory = File.join(output, "tmp")
Dir.mkdir(new_directory) unless Dir.exist?(new_directory)
Zip::InputStream.open(path) do |input|
# get_next_entryするとinputのoffset(ポインタ)が動く
while (entry = input.get_next_entry)
# 書き出し先を作る
save_path = File.join(new_directory, entry.name)
# 確認したいのはPACKAGEINFOだけなのでそれだけ解凍。
if entry.name == "PACKAGEINFO"
File.open(save_path, "w") do |wf|
# get_next_entryでポインタが動いているので、毎回input.readでOK
wf.puts(sjisfix(input.read.to_s).force_encoding('utf-8'))
end
end
entries << save_path
end
end
# 解凍されたファイルたちを返却する
entries
end

# 強制的にS-JISにエンコードを切り替える
def self.sjisfix(str)
str.gsub(/([\x83-\xFB])\//n, "\\1\\".force_encoding('utf-8'))
end
end

Loading