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
6c384388
Commit
6c384388
authored
Aug 20, 2013
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
75237d5b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
lib/deck_sync.rb
lib/deck_sync.rb
+21
-16
No files found.
lib/deck_sync.rb
View file @
6c384388
...
@@ -38,10 +38,7 @@ module Deck_Sync
...
@@ -38,10 +38,7 @@ module Deck_Sync
}
rescue
$log
.
error
(
'卡组下载'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
}
rescue
$log
.
error
(
'卡组下载'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
Thread
.
new
{
watch
}
unless
@watching
Thread
.
new
{
watch
}
unless
@watching
@watching
=
true
@watching
=
true
Dir
.
foreach
(
File
.
join
(
File
.
dirname
(
Ygocore
.
ygocore_path
),
'deck'
))
{
|
deck
|
Dir
.
glob
(
"
#{
File
.
dirname
(
Ygocore
.
ygocore_path
)
}
/deck/*.ydk"
).
each
{
|
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
next
if
just_updated
.
include?
deck
update
(
deck
)
update
(
deck
)
}
}
...
@@ -51,28 +48,36 @@ module Deck_Sync
...
@@ -51,28 +48,36 @@ module Deck_Sync
def
watch
def
watch
require
'fssm'
require
'fssm'
FSSM
.
monitor
(
File
.
join
(
File
.
dirname
(
Ygocore
.
ygocore_path
),
'deck'
)
,
'*.ydk'
)
do
FSSM
.
monitor
(
"
#{
File
.
dirname
(
Ygocore
.
ygocore_path
)
}
/deck"
,
'*.ydk'
)
do
update
{
|
base
,
relative
|
Deck_Sync
.
update
File
.
join
base
,
relative
}
update
{
|
base
,
relative
|
Deck_Sync
.
update
"
#{
base
}
/
#{
relative
}
"
}
delete
{
|
base
,
relative
|
Deck_Sync
.
delete
File
.
join
base
,
relative
}
delete
{
|
base
,
relative
|
Deck_Sync
.
delete
"
#{
base
}
/
#{
relative
}
"
}
create
{
|
base
,
relative
|
Deck_Sync
.
update
File
.
join
base
,
relative
}
create
{
|
base
,
relative
|
Deck_Sync
.
update
"
#{
base
}
/
#{
relative
}
"
}
end
end
end
end
def
update
(
deck
)
def
update
(
deck
)
Update
.
status
=
"正在同步卡组:
#{
File
.
basename
(
deck
,
".ydk"
)
}
"
Update
.
status
=
"正在同步卡组:
#{
File
.
basename
(
deck
,
".ydk"
)
}
"
begin
path
=
"/decks/?
#{
Deck
.
ygopro_deck_to_url_param
(
deck
)
}
&user=
#{
URI
.
escape
$game
.
user
.
id
.
bare
.
to_s
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
&updated_at=
#{
URI
.
escape
DateTime
.
now
.
iso8601
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
"
path
=
"/decks/?
#{
Deck
.
ygopro_deck_to_url_param
(
deck
)
}
&user=
#{
URI
.
escape
$game
.
user
.
id
.
bare
.
to_s
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
&updated_at=
#{
URI
.
escape
DateTime
.
now
.
iso8601
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
"
$log
.
info
(
"卡组上传"
)
{
path
}
$log
.
info
(
"卡组上传"
)
{
path
}
req
=
Net
::
HTTP
::
Put
.
new
path
req
=
Net
::
HTTP
::
Put
.
new
path
response
=
Net
::
HTTP
.
start
(
'my-card.in'
,
443
,
use_ssl:
true
)
{
|
http
|
http
.
request
(
req
)
}
response
=
Net
::
HTTP
.
start
(
'my-card.in'
,
443
,
use_ssl:
true
)
{
|
http
|
http
.
request
(
req
)
}
rescue
$log
.
error
(
'卡组上传'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
end
Update
.
status
=
nil
Update
.
status
=
nil
end
end
def
delete
(
deck
)
def
delete
(
deck
)
Update
.
status
=
"正在同步卡组:
#{
File
.
basename
(
deck
,
".ydk"
)
}
"
Update
.
status
=
"正在同步卡组:
#{
File
.
basename
(
deck
,
".ydk"
)
}
"
begin
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
}
]"
)
}
"
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
}
]"
)
}
"
$log
.
info
(
"卡组删除"
)
{
path
}
$log
.
info
(
"卡组删除"
)
{
path
}
req
=
Net
::
HTTP
::
Delete
.
new
path
req
=
Net
::
HTTP
::
Delete
.
new
path
response
=
Net
::
HTTP
.
start
(
'my-card.in'
,
443
,
use_ssl:
true
)
{
|
http
|
http
.
request
(
req
)
}
response
=
Net
::
HTTP
.
start
(
'my-card.in'
,
443
,
use_ssl:
true
)
{
|
http
|
http
.
request
(
req
)
}
rescue
$log
.
error
(
'卡组删除'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
end
Update
.
status
=
nil
Update
.
status
=
nil
end
end
end
end
...
...
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