Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
syntax_j
mycard
Commits
75237d5b
Commit
75237d5b
authored
Aug 20, 2013
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
e95c0c7e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
72 deletions
+76
-72
Rakefile
Rakefile
+65
-65
lib/deck_sync.rb
lib/deck_sync.rb
+7
-3
lib/update.rb
lib/update.rb
+4
-4
No files found.
Rakefile
View file @
75237d5b
#encoding: UTF-8
require
'rubygems'
require
'rake'
require
'rake/clean'
require
'rubygems/package_task'
require
'rdoc/task'
#require 'rake/testtask'
Windows
=
RUBY_PLATFORM
[
"mingw"
]
||
RUBY_PLATFORM
[
"mswin"
]
#在windows上UTF-8脚本编码环境中 Dir.glob无法列出中文目录下的文件 所以自己写个递归
def
list
(
path
)
result
=
[]
Dir
.
foreach
(
path
)
do
|
file
|
next
if
file
==
"."
or
file
==
".."
result
<<
"
#{
path
}
/
#{
file
}
"
result
.
concat
list
(
result
.
last
)
if
File
.
directory?
result
.
last
end
rescue
p
$!
result
end
spec
=
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
'mycard'
s
.
version
=
'1.
1.3'
s
.
extra_rdoc_files
=
[
'README.txt'
,
'LICENSE.txt'
]
s
.
summary
=
'a card game platform'
s
.
description
=
s
.
summary
s
.
author
=
'zh99998'
s
.
email
=
'zh99998@gmail.com'
s
.
homepage
=
'http://my-card.in/'
# s.executables = ['your_executable_here']
s
.
files
=
%w(LICENSE.txt README.txt replay)
%w{lib audio data locales graphics ygocore}
.
each
{
|
dir
|
s
.
files
.
concat
list
(
dir
)}
if
Windows
s
.
files
+=
%w(mycard.exe)
+
list
(
"ruby"
)
+
list
(
"fonts"
)
else
s
.
files
+=
%w(mycard.sh)
s
.
platform
=
Gem
::
Platform
::
CURRENT
end
s
.
require_path
=
"lib"
#s.bindir = "bin"
end
Gem
::
PackageTask
.
new
(
spec
)
do
|
p
|
p
.
gem_spec
=
spec
if
Windows
p
.
need_zip
=
true
p
.
zip_command
=
'7z a'
def
p
.
zip_file
"
#{
package_name
}
-win32.7z"
end
else
p
.
need_tar_gz
=
true
end
end
Rake
::
RDocTask
.
new
do
|
rdoc
|
files
=
[
'README.txt'
,
'LICENSE.txt'
,
'lib/**/*.rb'
]
rdoc
.
rdoc_files
.
add
(
files
)
rdoc
.
main
=
"README.txt"
# page to start on
rdoc
.
title
=
"Mycard Docs"
rdoc
.
rdoc_dir
=
'doc/rdoc'
# rdoc output folder
rdoc
.
options
<<
'--line-numbers'
end
CLOBBER
.
include
%w(error-程序出错请到论坛反馈.txt log.log profile.log config.yml doc ygocore/pics)
+
list
(
'replay'
)
+
list
(
'ygocore/replay'
)
+
list
(
'.'
).
keep_if
{
|
file
|
File
.
basename
(
file
)
==
"Thumbs.db"
}
+
list
(
"graphics/avatars"
).
reject
{
|
file
|
File
.
basename
(
file
)
=~
/(?:error|loading)_(?:small|middle|large)\.png/
}
+
list
(
"ygocore/deck"
).
keep_if
{
|
file
|
File
.
basename
(
file
)
!=
'sample.ydk'
}
#encoding: UTF-8
require
'rubygems'
require
'rake'
require
'rake/clean'
require
'rubygems/package_task'
require
'rdoc/task'
#require 'rake/testtask'
Windows
=
RUBY_PLATFORM
[
"mingw"
]
||
RUBY_PLATFORM
[
"mswin"
]
#在windows上UTF-8脚本编码环境中 Dir.glob无法列出中文目录下的文件 所以自己写个递归
def
list
(
path
)
result
=
[]
Dir
.
foreach
(
path
)
do
|
file
|
next
if
file
==
"."
or
file
==
".."
result
<<
"
#{
path
}
/
#{
file
}
"
result
.
concat
list
(
result
.
last
)
if
File
.
directory?
result
.
last
end
rescue
p
$!
result
end
spec
=
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
'mycard'
s
.
version
=
'1.
2.0'
s
.
extra_rdoc_files
=
[
'README.txt'
,
'LICENSE.txt'
]
s
.
summary
=
'a card game platform'
s
.
description
=
s
.
summary
s
.
author
=
'zh99998'
s
.
email
=
'zh99998@gmail.com'
s
.
homepage
=
'http://my-card.in/'
# s.executables = ['your_executable_here']
s
.
files
=
%w(LICENSE.txt README.txt replay)
%w{lib audio data locales graphics ygocore}
.
each
{
|
dir
|
s
.
files
.
concat
list
(
dir
)}
if
Windows
s
.
files
+=
%w(mycard.exe)
+
list
(
"ruby"
)
+
list
(
"fonts"
)
else
s
.
files
+=
%w(mycard.sh)
s
.
platform
=
Gem
::
Platform
::
CURRENT
end
s
.
require_path
=
"lib"
#s.bindir = "bin"
end
Gem
::
PackageTask
.
new
(
spec
)
do
|
p
|
p
.
gem_spec
=
spec
if
Windows
p
.
need_zip
=
true
p
.
zip_command
=
'7z a'
def
p
.
zip_file
"
#{
package_name
}
-win32.7z"
end
else
p
.
need_tar_gz
=
true
end
end
Rake
::
RDocTask
.
new
do
|
rdoc
|
files
=
[
'README.txt'
,
'LICENSE.txt'
,
'lib/**/*.rb'
]
rdoc
.
rdoc_files
.
add
(
files
)
rdoc
.
main
=
"README.txt"
# page to start on
rdoc
.
title
=
"Mycard Docs"
rdoc
.
rdoc_dir
=
'doc/rdoc'
# rdoc output folder
rdoc
.
options
<<
'--line-numbers'
end
CLOBBER
.
include
%w(error-程序出错请到论坛反馈.txt log.log profile.log config.yml doc ygocore/pics)
+
list
(
'replay'
)
+
list
(
'ygocore/replay'
)
+
list
(
'.'
).
keep_if
{
|
file
|
File
.
basename
(
file
)
==
"Thumbs.db"
}
+
list
(
"graphics/avatars"
).
reject
{
|
file
|
File
.
basename
(
file
)
=~
/(?:error|loading)_(?:small|middle|large)\.png/
}
+
list
(
"ygocore/deck"
).
keep_if
{
|
file
|
File
.
basename
(
file
)
!=
'sample.ydk'
}
lib/deck_sync.rb
View file @
75237d5b
...
...
@@ -10,7 +10,7 @@ module Deck_Sync
require
'date'
Thread
.
new
{
just_updated
=
[]
$log
.
info
(
'下载卡组'
)
{
"https://my-card.in/decks/?user=
#{
URI
.
escape
$game
.
user
.
id
.
bare
.
to_s
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
"
}
$log
.
info
(
'下载卡组'
)
{
"https://my-card.in/decks/?user=
#{
URI
.
escape
$game
.
user
.
id
.
bare
.
to_s
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
"
}
open
(
"https://my-card.in/decks/?user=
#{
URI
.
escape
$game
.
user
.
id
.
bare
.
to_s
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
"
)
{
|
list
|
JSON
.
parse
(
list
.
read
).
each
{
|
deck
|
file
=
File
.
join
(
File
.
dirname
(
Ygocore
.
ygocore_path
),
'deck'
,
"
#{
deck
[
'name'
]
}
.ydk"
)
...
...
@@ -38,7 +38,10 @@ module Deck_Sync
}
rescue
$log
.
error
(
'卡组下载'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
Thread
.
new
{
watch
}
unless
@watching
@watching
=
true
Dir
.
glob
(
File
.
join
(
File
.
dirname
(
Ygocore
.
ygocore_path
),
'deck'
,
'*.ydk'
))
{
|
deck
|
Dir
.
foreach
(
File
.
join
(
File
.
dirname
(
Ygocore
.
ygocore_path
),
'deck'
))
{
|
deck
|
deck
.
encode!
'UTF-8'
deck
=
File
.
join
(
File
.
dirname
(
Ygocore
.
ygocore_path
),
'deck'
,
deck
)
next
if
File
.
extname
(
deck
)
!=
'.ydk'
next
if
just_updated
.
include?
deck
update
(
deck
)
}
...
...
@@ -63,6 +66,7 @@ module Deck_Sync
response
=
Net
::
HTTP
.
start
(
'my-card.in'
,
443
,
use_ssl:
true
)
{
|
http
|
http
.
request
(
req
)
}
Update
.
status
=
nil
end
def
delete
(
deck
)
Update
.
status
=
"正在同步卡组:
#{
File
.
basename
(
deck
,
".ydk"
)
}
"
path
=
"/decks/?name=
#{
URI
.
escape
File
.
basename
(
deck
,
".ydk"
),
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
&user=
#{
URI
.
escape
$game
.
user
.
id
.
bare
.
to_s
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
"
...
...
@@ -72,4 +76,4 @@ module Deck_Sync
Update
.
status
=
nil
end
end
end
end
\ No newline at end of file
lib/update.rb
View file @
75237d5b
...
...
@@ -47,7 +47,7 @@ module Update
$log
.
info
(
'下载更新-解析后'
)
{
reply
.
inspect
}
reply
.
each
do
|
fil
|
name
=
File
.
basename
fil
@status
.
replace
"正在下载更新
#{
name
}
"
@status
=
"正在下载更新
#{
name
}
"
open
(
fil
,
'rb'
)
do
|
fi
|
$log
.
info
(
'下载完毕'
)
{
name
}
@updated
=
true
...
...
@@ -102,7 +102,7 @@ module Update
dest
=
"ygocore/pics/
#{
number
}
.jpg"
dest_thumb
=
"ygocore/pics/thumbnail/
#{
number
}
.jpg"
if
File
.
file?
(
src
)
@status
.
replace
"检测到存在iDuel卡图 正在导入
#{
id
}
.jpg"
@status
=
"检测到存在iDuel卡图 正在导入
#{
id
}
.jpg"
existed_images
<<
number
if
!
File
.
exist?
(
dest
)
FileUtils
.
copy_file
(
src
,
dest
)
...
...
@@ -148,7 +148,7 @@ module Update
ids
.
replace
@thumbnails
.
pop
(
100
)
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
thumbnail_req
.
gsub
(
':id'
,
id
.
to_s
)
}
http
.
pipeline
reqs
do
|
res
|
@status
.
replace
"正在下载卡图 (剩余: 缩略
#{
@thumbnails_left
}
/ 完整
#{
@images_left
}
#{
"错误:
#{
@error_count
}
"
if
@error_count
>
0
}
)"
@status
=
"正在下载卡图 (剩余: 缩略
#{
@thumbnails_left
}
/ 完整
#{
@images_left
}
#{
"错误:
#{
@error_count
}
"
if
@error_count
>
0
}
)"
@thumbnails_left
-=
1
id
=
ids
.
pop
if
res
.
code
[
0
]
==
'2'
#http 2xx
...
...
@@ -167,7 +167,7 @@ module Update
ids
.
replace
@images
.
pop
(
100
)
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
image_req
.
gsub
(
':id'
,
id
.
to_s
)
}
http
.
pipeline
reqs
do
|
res
|
@status
.
replace
"正在下载卡图 (剩余: 缩略
#{
@thumbnails_left
}
/ 完整
#{
@images_left
}
#{
"错误:
#{
@error_count
}
"
if
@error_count
>
0
}
)"
@status
=
"正在下载卡图 (剩余: 缩略
#{
@thumbnails_left
}
/ 完整
#{
@images_left
}
#{
"错误:
#{
@error_count
}
"
if
@error_count
>
0
}
)"
@images_left
-=
1
id
=
ids
.
pop
if
res
.
code
[
0
]
==
'2'
#http 2xx
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment