zugzwang 0.1.2 → 0.1.3

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: 7df00460ffab7463316f2df42fb45f0a20224b87ab2b803e7eb6192d9e149335
4
- data.tar.gz: fe14f61bff34d14883223560f288c69ffa6a6faed565b54cc244f916d8a0f73d
3
+ metadata.gz: 7c824df5a3a56edd454328beac8fdd7541bb5384587a60575502ba67f0536e61
4
+ data.tar.gz: 78bd8e37e7051981fc78d067e23029015606294fea0548a78859c925e2ef031c
5
5
  SHA512:
6
- metadata.gz: ba14773c23dc599248c36f5dc4d98ae17c0fe18e87a402ece3191384f1009ad03ef1b9aa2296f914a8f8043617bf35bf553ad19dc4c0944efffffb51fc073a80
7
- data.tar.gz: dfa68a49e5b5e84fd47b51a2d304b74319fd87f73a7ee672386f46ee0a8886005acb2f5632e6ae6b4d4e10aceaa0c635e01f70060ee6c760c59208d403e44961
6
+ metadata.gz: 85a6871c5966e70a240028ac7b724d84a30fe8c432fe66f1db89dc92428c07514b58041b67df963d5344c30428c0fc30ce7deb723e2c320d9c8e991fcf339e63
7
+ data.tar.gz: c48fa8aad9589065c587d9a80fae3ceb925129008904ae6507eb494e0bdb99e30f9935d47e0af16394a540c2068bad133044bf3ecee14df21e09ca4bdf59a329
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Zugzwang
5
5
 
6
- Converts the metadata of PGN files from Lichess' game database to a database file, using lazy file enumerators for optimizing the conversion of large PGN files with millions of chess games.
6
+ Lightweight CLI for converting the metadata of PGN files from Lichess' game database to a database file, using lazy file enumerators for optimizing the conversion of large PGN files with millions of chess games.
7
7
 
8
8
  ## PGN files
9
9
 
@@ -162,6 +162,12 @@ $ zugzwang create [DATABASE] *[ITEMS] --extension, --extension=EXTENSION
162
162
  >
163
163
  > - Creates a database file at `games/1.db`, populating it with data from `.pgn` files found from recursively searching the current directory.
164
164
 
165
+ ## TODO
166
+
167
+ - [ ] Add Postgres support
168
+ - [ ] Add multithreaded PGN file parsing
169
+ - [ ] Add specs/testing
170
+
165
171
  ## Development
166
172
 
167
173
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
@@ -3,6 +3,24 @@ require "zugzwang/helpers"
3
3
  require "zugzwang/cli"
4
4
 
5
5
  module Zugzwang
6
- FIELDS = %i[Event Site White Black Result UTCDate UTCTime WhiteElo BlackElo WhiteRatingDiff BlackRatingDiff WhiteTitle ECO Opening TimeControl Termination]
6
+ FIELDS = {
7
+ Event: {type: :string},
8
+ Site: {type: :string, size: 50},
9
+ White: {type: :string, size: 30},
10
+ Black: {type: :string, size: 30},
11
+ Result: {type: :string, size: 10},
12
+ UTCDate: {type: :date, size: 15},
13
+ UTCTime: {type: :time, size: 8},
14
+ WhiteElo: {type: :integer},
15
+ BlackElo: {type: :integer},
16
+ WhiteRatingDiff: {type: :string, size: 5},
17
+ BlackRatingDiff: {type: :string, size: 5},
18
+ WhiteTitle: {type: :string, size: 5},
19
+ ECO: {type: :string, size: 3},
20
+ Opening: {type: :string},
21
+ TimeControl: {type: :string, size: 15},
22
+ Termination: {type: :string, size: 20},
23
+ Variant: {type: :string}
24
+ }
7
25
  EXTENSIONS = %i[sql sqlite sqlite3 db]
8
26
  end
@@ -1,12 +1,18 @@
1
1
  require 'ruby-progressbar'
2
- require 'thor'
3
2
 
4
3
  module Zugzwang
5
4
  module Create
6
5
  def self.[](database_object, database, extension, items)
7
6
  database_object.create_table :games do
8
7
  primary_key :id
9
- FIELDS.each {|field| String field}
8
+ FIELDS.each do |name, options|
9
+ case options[:type]
10
+ when :string then String name, size: (options[:size]||255)
11
+ when :integer then Integer name
12
+ when :date then Date name
13
+ when :time then Time name, only_time: true
14
+ end
15
+ end
10
16
  end
11
17
 
12
18
  files = items.map{|item|
@@ -23,7 +29,7 @@ module Zugzwang
23
29
  progress_bar = ProgressBar.create(:title => 'Progress', total: lines, progress_mark: "\e[1;35m#{?#}\e[0m", remainder_mark: ?., format: "%t: %p%% (Line: %c/%C) %B")
24
30
  File.open(f,'r').each do |line|
25
31
  if prev =~ /\A\[.*\Z/ && line =~ /\A[\n\r].*\Z/
26
- database_object[:games].insert **record
32
+ database_object[:games].insert(**record)
27
33
  record = {}
28
34
  prev = line
29
35
  progress_bar.increment
@@ -42,6 +48,7 @@ module Zugzwang
42
48
  progress_bar.increment
43
49
  end
44
50
  end
51
+
45
52
  puts "\n\e[92mComplete\e[0m: Saved #{extension} database at \e[1m#{database}.#{extension}\e[0m."
46
53
  end
47
54
  end
@@ -1,3 +1,3 @@
1
1
  module Zugzwang
2
- VERSION = "0.1.2"
3
- end
2
+ VERSION = "0.1.3"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zugzwang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edwin Onuonga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-01 00:00:00.000000000 Z
11
+ date: 2018-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,7 +118,6 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - ".gitignore"
120
120
  - Gemfile
121
- - Gemfile.lock
122
121
  - LICENSE
123
122
  - README.md
124
123
  - Rakefile
@@ -1,43 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- zugzwang (0.1.2)
5
- ruby-progressbar (~> 1.9)
6
- sequel (~> 5.9)
7
- sqlite3 (~> 1.3)
8
- thor (~> 0.20)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- diff-lcs (1.3)
14
- rake (12.3.1)
15
- rspec (3.7.0)
16
- rspec-core (~> 3.7.0)
17
- rspec-expectations (~> 3.7.0)
18
- rspec-mocks (~> 3.7.0)
19
- rspec-core (3.7.1)
20
- rspec-support (~> 3.7.0)
21
- rspec-expectations (3.7.0)
22
- diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.7.0)
24
- rspec-mocks (3.7.0)
25
- diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.7.0)
27
- rspec-support (3.7.1)
28
- ruby-progressbar (1.9.0)
29
- sequel (5.9.0)
30
- sqlite3 (1.3.13)
31
- thor (0.20.0)
32
-
33
- PLATFORMS
34
- ruby
35
-
36
- DEPENDENCIES
37
- bundler (~> 1.16)
38
- rake (~> 12.3)
39
- rspec (~> 3.7)
40
- zugzwang!
41
-
42
- BUNDLED WITH
43
- 1.16.2