comike_catalog_parser 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +2 -0
- data/comike_catalog_parser.gemspec +24 -0
- data/lib/comike_catalog_parser/catalog_checklist.rb +126 -0
- data/lib/comike_catalog_parser/circle_cut.rb +66 -0
- data/lib/comike_catalog_parser/circle_map.rb +95 -0
- data/lib/comike_catalog_parser/version.rb +3 -0
- data/lib/comike_catalog_parser.rb +8 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9bc84a77beab403317c31e1a20125017d3f4d737
|
4
|
+
data.tar.gz: a1690ca041879e36035a110c2c2dc649838155bd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 24f6f8e8960c7b6194411cfb7167db74ad186eb4c748b23135ffc4fb1c74c470df1b9bcf93f4a8fe5706946e60bb825131b93bc482529c8b5c4e9d1584811a0b
|
7
|
+
data.tar.gz: 48c83d7953a0410d95d4f31c220e93a45a010b3c4c4f84ed14ec6a2e89912ce741b8a3a97a040db9701f6c63a8434edcd0531ba1d864ac228e1f91ad7abcae07
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 AKB428
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# ComikeCatalogParser
|
2
|
+
|
3
|
+
コミックマーケットカタログ(ROM版)のパーサーです
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'comike_catalog_parser'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install comike_catalog_parser
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
|
24
|
+
' CircleCut.new("/Users/cocoa/PDATA/1093.PNG").individual_cut("32")'
|
25
|
+
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/[my-github-username]/comike_catalog_parser/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'comike_catalog_parser/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "comike_catalog_parser"
|
8
|
+
spec.version = ComikeCatalogParser::VERSION
|
9
|
+
spec.authors = ["AKB428"]
|
10
|
+
spec.email = ["otoraru@gmail.com"]
|
11
|
+
spec.summary = %q{comic market catalog rom data parser}
|
12
|
+
spec.description = %q{comic market catalog rom data csv and circle cut parser}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'rmagick'
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'csv'
|
2
|
+
require './lib/comike/circle_map'
|
3
|
+
require './lib/comike/circle_cut.rb'
|
4
|
+
require 'pathname'
|
5
|
+
module ComikeCatalogParser
|
6
|
+
|
7
|
+
class CatalogChecklist
|
8
|
+
|
9
|
+
ENCODE_CONVERT_DIRECTORY = "./convertUTF8/"
|
10
|
+
|
11
|
+
def initialize(csv_file_path, circle_cut_path = nil)
|
12
|
+
csv_file_path = csv_file_path
|
13
|
+
|
14
|
+
original_data = File.read(csv_file_path, encoding: 'cp932')
|
15
|
+
convert_data = original_data.encode('UTF-8', 'cp932')
|
16
|
+
convert_file_path = ENCODE_CONVERT_DIRECTORY + "convert.csv"
|
17
|
+
|
18
|
+
File.open convert_file_path, 'w' do |f|
|
19
|
+
f.write convert_data
|
20
|
+
end
|
21
|
+
|
22
|
+
@csv_data = CSV.read(convert_file_path)
|
23
|
+
@circle_cut_path = circle_cut_path
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# コミケのチェックリストのデータを以下の最大9個のボードにわける(曜日はC86)
|
28
|
+
# trello_data
|
29
|
+
# C86/金-東123
|
30
|
+
# C86/金-東456
|
31
|
+
# C86/金-西12
|
32
|
+
#
|
33
|
+
# C86/土-東123
|
34
|
+
# C86/土-東456
|
35
|
+
# C86/土-西12
|
36
|
+
#
|
37
|
+
# C86/日-東123
|
38
|
+
# C86/日-東456
|
39
|
+
# C86/日-西12
|
40
|
+
#
|
41
|
+
def csv2trello_data()
|
42
|
+
#p @csv_data
|
43
|
+
trello_data = {}
|
44
|
+
|
45
|
+
comike_number_string = "C" + extract_comike_number
|
46
|
+
|
47
|
+
circle_data = extract_circle_data
|
48
|
+
|
49
|
+
circle_data.each do |circle|
|
50
|
+
#開催曜日
|
51
|
+
day_of_the_week = circle[5]
|
52
|
+
|
53
|
+
#東 or 西
|
54
|
+
east_or_west = circle[6]
|
55
|
+
|
56
|
+
# アとかシとかAとか
|
57
|
+
position_id = circle[7]
|
58
|
+
|
59
|
+
# position_id内の番号
|
60
|
+
position_number = circle[8]
|
61
|
+
|
62
|
+
circle_name = circle[10] || ''
|
63
|
+
circle_author = circle[12] || ''
|
64
|
+
sell_title = circle[13] || ''
|
65
|
+
circle_url = circle[14] || ''
|
66
|
+
title_desc = circle[16] || ''
|
67
|
+
circle_ms_url = circle[23] || ''
|
68
|
+
section_a_or_b = circle[4].to_i % 2 == 0 ? 'b' : 'a'
|
69
|
+
circle_position = east_or_west + position_id + position_number + section_a_or_b
|
70
|
+
|
71
|
+
detail = CircleMap.new(east_or_west, position_id).position_detail
|
72
|
+
|
73
|
+
board_name = comike_number_string + "/" + day_of_the_week + "-" + detail["group_name"]
|
74
|
+
list_name = detail["position"]
|
75
|
+
|
76
|
+
card_model = {}
|
77
|
+
card_model["name"] = circle_position + " " + circle_name
|
78
|
+
card_model["desc"] = circle_author + "\n=====================\n" +
|
79
|
+
sell_title + "\n--------------------------\n" +
|
80
|
+
circle_url + "\n" + title_desc + "\n" + circle_ms_url
|
81
|
+
|
82
|
+
#サークルカット処理
|
83
|
+
if(!@circle_cut_path.nil?)
|
84
|
+
circle_cut_page = Pathname(@circle_cut_path).join(sprintf("%04d", circle[3]) + ".PNG")
|
85
|
+
|
86
|
+
inv_image_path = CircleCut.new(circle_cut_page).individual_cut(circle[4])
|
87
|
+
card_model["attachment"] = inv_image_path
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
if(trello_data[board_name].blank?)
|
92
|
+
trello_data[board_name] = {}
|
93
|
+
end
|
94
|
+
if (trello_data[board_name][list_name].blank?)
|
95
|
+
trello_data[board_name][list_name] = []
|
96
|
+
end
|
97
|
+
|
98
|
+
trello_data[board_name][list_name].push(card_model)
|
99
|
+
end
|
100
|
+
|
101
|
+
trello_data
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
# csvデータからコミケ開催番号(数字文字列)を抽出する
|
107
|
+
def extract_comike_number()
|
108
|
+
#ComicMarket86->86
|
109
|
+
@csv_data[0][2].scan(/[\d]+/)[0]
|
110
|
+
end
|
111
|
+
|
112
|
+
# csvデータからヘッダと色情報の行を削除し、サークル情報のみを抽出する
|
113
|
+
def extract_circle_data()
|
114
|
+
circle_data = []
|
115
|
+
|
116
|
+
@csv_data.each do |csv|
|
117
|
+
if csv[0] == "Circle"
|
118
|
+
circle_data.push(csv)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
circle_data
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'RMagick'
|
4
|
+
module ComikeCatalogParser
|
5
|
+
class CircleCut
|
6
|
+
|
7
|
+
WORK_FOLDER_NAME = "./circle_cut"
|
8
|
+
|
9
|
+
CIRCLE_CUT_SIZE_WIDTH = 165
|
10
|
+
CIRCLE_CUT_SIZE_HEIGHT = 241
|
11
|
+
|
12
|
+
#とりあえず計算せずMAPで持つ 1ページ 6x6=36カット
|
13
|
+
H1 = 70
|
14
|
+
H2 = 323
|
15
|
+
H3 = 575
|
16
|
+
H4 = 828
|
17
|
+
H5 = 1081
|
18
|
+
H6 = 1333
|
19
|
+
|
20
|
+
W1 = 15
|
21
|
+
W2 = 192
|
22
|
+
W3 = 369
|
23
|
+
W4 = 547
|
24
|
+
W5 = 724
|
25
|
+
W6 = 903
|
26
|
+
|
27
|
+
|
28
|
+
CIRCLE_CUT_MAP =
|
29
|
+
[
|
30
|
+
[W1,H1],[W2,H1],[W3,H1], [W4,H1],[W5,H1],[W6,H1],
|
31
|
+
[W1,H2],[W2,H2],[W3,H2], [W4,H2],[W5,H2],[W6,H2],
|
32
|
+
[W1,H3],[W2,H3],[W3,H3], [W4,H3],[W5,H3],[W6,H3],
|
33
|
+
[W1,H4],[W2,H4],[W3,H4], [W4,H4],[W5,H4],[W6,H4],
|
34
|
+
[W1,H5],[W2,H5],[W3,H5], [W4,H5],[W5,H5],[W6,H5],
|
35
|
+
[W1,H6],[W2,H6],[W3,H6], [W4,H6],[W5,H6],[W6,H6],
|
36
|
+
]
|
37
|
+
|
38
|
+
|
39
|
+
def initialize(circle_cut_page_file_path)
|
40
|
+
@circle_cut_page_file_path = circle_cut_page_file_path
|
41
|
+
end
|
42
|
+
|
43
|
+
#対象のサークルカットPNGから1サークルのカットを切り取りファイルパスを返却する
|
44
|
+
#すでに切り取っていたらそれを使う
|
45
|
+
def individual_cut(position_id)
|
46
|
+
|
47
|
+
circle_cut_page_file_name = Pathname(@circle_cut_page_file_path).basename.to_s
|
48
|
+
circle_cut_page_file_name.gsub!("\.PNG", "")
|
49
|
+
page_folder_name = Pathname.new(WORK_FOLDER_NAME).join(circle_cut_page_file_name).to_s
|
50
|
+
FileUtils.mkdir_p(page_folder_name) unless File.exist?(page_folder_name)
|
51
|
+
|
52
|
+
write_file_path_name = Pathname.new(page_folder_name).join(position_id + ".png").to_s
|
53
|
+
|
54
|
+
#ファイルをすでにカットしていたら処理せず終了
|
55
|
+
return write_file_path_name if File.exist?(write_file_path_name)
|
56
|
+
|
57
|
+
image = Magick::Image.read(@circle_cut_page_file_path).first
|
58
|
+
image.crop(CIRCLE_CUT_MAP[position_id.to_i - 1][0], CIRCLE_CUT_MAP[position_id.to_i - 1][1], CIRCLE_CUT_SIZE_WIDTH, CIRCLE_CUT_SIZE_HEIGHT).write(write_file_path_name)
|
59
|
+
|
60
|
+
|
61
|
+
puts "create " + write_file_path_name
|
62
|
+
write_file_path_name
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module ComikeCatalogParser
|
2
|
+
|
3
|
+
class CircleMap
|
4
|
+
EAST123 = '東123'
|
5
|
+
EAST456 = '東456'
|
6
|
+
WEST12 = '西12'
|
7
|
+
|
8
|
+
#アルファベットは全角なので注意
|
9
|
+
EAST = {
|
10
|
+
"壁サークル-東123" => {
|
11
|
+
"group_name" => EAST123,
|
12
|
+
"range" => ["A"]
|
13
|
+
},
|
14
|
+
"東1" => {
|
15
|
+
"group_name" => EAST123,
|
16
|
+
"range" => ["B","C","D","E","F","G","H","I","J","K","L"]
|
17
|
+
},
|
18
|
+
"東2" => {
|
19
|
+
"group_name" => EAST123,
|
20
|
+
"range" => ["M","N","O","P","Q","R","S","T"]
|
21
|
+
},
|
22
|
+
"東3" => {
|
23
|
+
"group_name" => EAST123,
|
24
|
+
"range" => ["U","V","W","X","Y","Z","ア","イ","ウ","エ","オ","カ","キ","ク","ケ","コ","サ"]
|
25
|
+
},
|
26
|
+
"壁サークル-東456" => {
|
27
|
+
"group_name" => EAST456,
|
28
|
+
"range" => ["シ"]
|
29
|
+
},
|
30
|
+
"東4" => {
|
31
|
+
"group_name" => EAST456,
|
32
|
+
"range" => ["ム","メ","モ","ヤ","ユ","ヨ","ラ","リ","ル","レ","ロ"]
|
33
|
+
},
|
34
|
+
"東5" => {
|
35
|
+
"group_name" => EAST456,
|
36
|
+
"range" => ["ハ","パ","匕","ピ","フ","プ","へ","ぺ","ホ","ポ","マ","ミ"]
|
37
|
+
},
|
38
|
+
"東6" => {
|
39
|
+
"group_name" => EAST456,
|
40
|
+
"range" => ["ス","セ","ソ","タ","チ","ツ","テ","ト","ナ","ニ","ヌ","ネ","ノ"]
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
WEST = {
|
45
|
+
"壁サークル-西1" => {
|
46
|
+
"group_name" => WEST12,
|
47
|
+
"range" => ["あ"]
|
48
|
+
},
|
49
|
+
"西1" => {
|
50
|
+
"group_name" => WEST12,
|
51
|
+
"range" => ["い","う","え","お","か","き","く","け","こ","さ","し","す","せ","そ","た","ち","つ","て","と","な"]
|
52
|
+
},
|
53
|
+
"壁サークル-西2" => {
|
54
|
+
"group_name" => WEST12,
|
55
|
+
"range" => ["れ"]
|
56
|
+
},
|
57
|
+
"西2" => {
|
58
|
+
"group_name" => WEST12,
|
59
|
+
"range" => ["に","ぬ","ね","の","は","ひ","ふ","へ","ほ","ま","み","む","め","も","や","ゆ","よ","ら","り","る"]
|
60
|
+
},
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
def initialize(west_or_east, position_id)
|
65
|
+
@west_or_east = west_or_east
|
66
|
+
@position_id = position_id
|
67
|
+
end
|
68
|
+
|
69
|
+
#サークル位置に関する詳細情報を取得する
|
70
|
+
def position_detail()
|
71
|
+
position = ""
|
72
|
+
group_name = ""
|
73
|
+
|
74
|
+
target = nil
|
75
|
+
if @west_or_east == "東"
|
76
|
+
target = EAST
|
77
|
+
else
|
78
|
+
target = WEST
|
79
|
+
end
|
80
|
+
|
81
|
+
target.each do | position_key, group|
|
82
|
+
if(group["range"].index(@position_id))
|
83
|
+
position = position_key
|
84
|
+
group_name = group["group_name"]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
{
|
89
|
+
'position' => position,
|
90
|
+
'group_name' => group_name
|
91
|
+
}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: comike_catalog_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- AKB428
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rmagick
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: comic market catalog rom data csv and circle cut parser
|
56
|
+
email:
|
57
|
+
- otoraru@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- comike_catalog_parser.gemspec
|
68
|
+
- lib/comike_catalog_parser.rb
|
69
|
+
- lib/comike_catalog_parser/catalog_checklist.rb
|
70
|
+
- lib/comike_catalog_parser/circle_cut.rb
|
71
|
+
- lib/comike_catalog_parser/circle_map.rb
|
72
|
+
- lib/comike_catalog_parser/version.rb
|
73
|
+
homepage: ''
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.1
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: comic market catalog rom data parser
|
97
|
+
test_files: []
|