nwn-lib 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +9 -0
- data/CHEATSHEET +25 -0
- data/README +5 -0
- data/Rakefile +1 -1
- data/bin/nwn-gff-print +2 -1
- data/lib/nwn/gff.rb +22 -2
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -75,3 +75,12 @@ Bernhard Stoeckner <elven@swordcoast.net> (8):
|
|
75
75
|
nwn-gff-import: add support for multiple files
|
76
76
|
0.3.3-rel
|
77
77
|
|
78
|
+
=== 0.3.4
|
79
|
+
Bernhard Stoeckner <elven@swordcoast.net> (7):
|
80
|
+
nwn-gff-print: -y outputs sorted hash maps
|
81
|
+
nwn-gff-print: fix --verbose switch
|
82
|
+
type :cexolocstr: do not lose empty lang ids
|
83
|
+
README: add encoding warning
|
84
|
+
struct to yaml: inline small structs
|
85
|
+
CHEATSHEET: add some hints for nwn-gff-import
|
86
|
+
0.3.4-rel
|
data/CHEATSHEET
CHANGED
@@ -2,6 +2,31 @@
|
|
2
2
|
|
3
3
|
nwn-gff-print --type UTI -k -t creature.bic 'ItemList[12]' | gffencode.pl -o item.uti
|
4
4
|
|
5
|
+
==== Convert all item files in the current directory to yaml
|
6
|
+
|
7
|
+
nwn-gff-print -v -y --postfix .yml *.uti
|
8
|
+
|
9
|
+
==== Convert all yaml item files back to their gff counterpart
|
10
|
+
|
11
|
+
nwn-gff-import -y --postfix .yml *.uti.yml
|
12
|
+
|
13
|
+
==== Makefile rules for building resources from yml files
|
14
|
+
|
15
|
+
postfix := uti
|
16
|
+
|
17
|
+
objects := $(basename $(wildcard *.$(postfix).yml))
|
18
|
+
|
19
|
+
all: $(objects)
|
20
|
+
|
21
|
+
$(objects) : %.$(postfix) : %.$(postfix).yml
|
22
|
+
nwn-gff-import -y -o $@ $<
|
23
|
+
|
24
|
+
clean:
|
25
|
+
-@rm $(objects)
|
26
|
+
|
27
|
+
This ruleset will automatically rebuild changed ymls to their respective .uti counterparts.
|
28
|
+
This only serves as an example on how to do it; it does not constitute a complete build environment.
|
29
|
+
|
5
30
|
==== Quick-edit a item
|
6
31
|
|
7
32
|
your/prompt$ nwn-gff-irb my_item.uti
|
data/README
CHANGED
@@ -8,6 +8,11 @@ There are various things included in this distribution:
|
|
8
8
|
* some binaries under bin/ (see BINARIES)
|
9
9
|
* the actual library under lib/nwn
|
10
10
|
|
11
|
+
== Attention Unicode/UTF-users
|
12
|
+
|
13
|
+
ruby 1.8 does not support character sets natively, and as such nwn-gff-irb will <b>FAIL</b> to encode non-standard characters properly on non-latin1 shells.
|
14
|
+
This will be worked around in a future release until the release of ruby 1.9, which will provide native charset support.
|
15
|
+
|
11
16
|
== Quickstart
|
12
17
|
|
13
18
|
It is easiest to just use the gem, which is available through rubyforge (<tt>sudo gem install nwn-lib</tt>).
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ include FileUtils
|
|
9
9
|
# Configuration
|
10
10
|
##############################################################################
|
11
11
|
NAME = "nwn-lib"
|
12
|
-
VERS = "0.3.
|
12
|
+
VERS = "0.3.4"
|
13
13
|
CLEAN.include ["**/.*.sw?", "pkg", ".config", "rdoc", "coverage"]
|
14
14
|
RDOC_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', \
|
15
15
|
'nwn-lib: a ruby library for accessing NWN resource files', \
|
data/bin/nwn-gff-print
CHANGED
@@ -4,6 +4,7 @@ require 'optparse'
|
|
4
4
|
require 'nwn/gff'
|
5
5
|
require 'nwn/helpers'
|
6
6
|
require 'yaml'
|
7
|
+
require 'nwn/yaml'
|
7
8
|
|
8
9
|
format = nil
|
9
10
|
types_too = false
|
@@ -65,7 +66,7 @@ OptionParser.new do |o|
|
|
65
66
|
path = p
|
66
67
|
end
|
67
68
|
|
68
|
-
o.on "-v" "--verbose", "Be verbose" do
|
69
|
+
o.on "-v", "--verbose", "Be verbose" do
|
69
70
|
verbose = true
|
70
71
|
end
|
71
72
|
end.parse!
|
data/lib/nwn/gff.rb
CHANGED
@@ -404,6 +404,22 @@ class NWN::Gff::Struct
|
|
404
404
|
[ '@struct_id', '@hash' ]
|
405
405
|
end
|
406
406
|
|
407
|
+
def to_yaml( opts = {} )
|
408
|
+
YAML::quick_emit( nil, opts ) do |out|
|
409
|
+
out.map( taguri, to_yaml_style ) do |map|
|
410
|
+
# Inline certain structs that are small enough.
|
411
|
+
map.style = :inline if hash.size <= 1 &&
|
412
|
+
hash.values.select {|x|
|
413
|
+
NWN::Gff::Element::NonInline.index(x.type)
|
414
|
+
}.size == 0
|
415
|
+
|
416
|
+
to_yaml_properties.sort.each do |m|
|
417
|
+
map.add( m[1..-1], instance_variable_get( m ) ) # unless instance_variable_get( m ).nil?
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
407
423
|
def initialize
|
408
424
|
@struct_id = 0
|
409
425
|
@hash = {}
|
@@ -469,14 +485,18 @@ class NWN::Gff::CExoLocString
|
|
469
485
|
end
|
470
486
|
|
471
487
|
def size
|
472
|
-
@languages.
|
488
|
+
@languages.size
|
473
489
|
end
|
474
490
|
|
475
491
|
def each
|
476
|
-
@languages.
|
492
|
+
@languages.each {|k,v|
|
477
493
|
yield k, v
|
478
494
|
}
|
479
495
|
end
|
496
|
+
|
497
|
+
def compact
|
498
|
+
@languages.compact.reject {|k,v| "" == v}
|
499
|
+
end
|
480
500
|
end
|
481
501
|
|
482
502
|
# A class that parses binary GFF bytes into ruby-friendly data structures.
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: nwn-lib
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.3.
|
7
|
-
date: 2008-08-
|
6
|
+
version: 0.3.4
|
7
|
+
date: 2008-08-08 00:00:00 +02:00
|
8
8
|
summary: a ruby library for accessing Neverwinter Nights resource files
|
9
9
|
require_paths:
|
10
10
|
- lib
|