inaho 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +47 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +78 -0
- data/Guardfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +58 -0
- data/Rakefile +11 -0
- data/inaho.gemspec +26 -0
- data/lib/inaho.rb +8 -0
- data/lib/inaho/dictionary.rb +68 -0
- data/lib/inaho/entry.rb +50 -0
- data/lib/inaho/version.rb +3 -0
- data/spec/inaho/dictionary_spec.rb +37 -0
- data/spec/inaho/entry_spec.rb +34 -0
- data/spec/spec_helper.rb +8 -0
- data/vendor/AppleDictionarySchema.rng +34 -0
- data/vendor/modules/dict-struct.rng +138 -0
- metadata +135 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 3794f6f2e599498f1d0431b197b2a4aae5dd2467
|
|
4
|
+
data.tar.gz: e0f0f0f89d947d35885d034d91c96fe061543d5b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 821ee9c15f4a36235a69be150eb6ebeabe133555c4b34f3344aa37b5c6cfa536c22779d1ad09d8f0fbd3a020f26cf3ddfaa1c17b1f9a26ddfe42bf37a9d0a640
|
|
7
|
+
data.tar.gz: 56883d13d2112266d4b3cb5358311971a9f58c7c2ec3011cdfedd4bb1ed333eb1b19fbcea385dff8be4ece8a5ef6fa2f8057a7d79208cf4bbc22aa5a15821dfe
|
data/.gitignore
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
### Ruby ###
|
|
2
|
+
*.gem
|
|
3
|
+
*.rbc
|
|
4
|
+
/.config
|
|
5
|
+
/coverage/
|
|
6
|
+
/InstalledFiles
|
|
7
|
+
/pkg/
|
|
8
|
+
/spec/reports/
|
|
9
|
+
/test/tmp/
|
|
10
|
+
/test/version_tmp/
|
|
11
|
+
/tmp/
|
|
12
|
+
|
|
13
|
+
## Documentation cache and generated files:
|
|
14
|
+
/.yardoc/
|
|
15
|
+
/_yardoc/
|
|
16
|
+
/doc/
|
|
17
|
+
/rdoc/
|
|
18
|
+
|
|
19
|
+
## Environment normalisation:
|
|
20
|
+
/.bundle/
|
|
21
|
+
/lib/bundler/man/
|
|
22
|
+
|
|
23
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
24
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
25
|
+
# Gemfile.lock
|
|
26
|
+
# .ruby-version
|
|
27
|
+
# .ruby-gemset
|
|
28
|
+
|
|
29
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
30
|
+
.rvmrc
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### OSX ###
|
|
34
|
+
.DS_Store
|
|
35
|
+
.AppleDouble
|
|
36
|
+
.LSOverride
|
|
37
|
+
|
|
38
|
+
# Icon must ends with two \r.
|
|
39
|
+
Icon
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# Thumbnails
|
|
43
|
+
._*
|
|
44
|
+
|
|
45
|
+
# Files that might appear on external disk
|
|
46
|
+
.Spotlight-V100
|
|
47
|
+
.Trashes
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
inaho (0.0.1)
|
|
5
|
+
activesupport
|
|
6
|
+
nokogiri
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
activesupport (4.1.0)
|
|
12
|
+
i18n (~> 0.6, >= 0.6.9)
|
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
|
14
|
+
minitest (~> 5.1)
|
|
15
|
+
thread_safe (~> 0.1)
|
|
16
|
+
tzinfo (~> 1.1)
|
|
17
|
+
celluloid (0.15.2)
|
|
18
|
+
timers (~> 1.1.0)
|
|
19
|
+
celluloid-io (0.15.0)
|
|
20
|
+
celluloid (>= 0.15.0)
|
|
21
|
+
nio4r (>= 0.5.0)
|
|
22
|
+
coderay (1.1.0)
|
|
23
|
+
diff-lcs (1.2.5)
|
|
24
|
+
ffi (1.9.3)
|
|
25
|
+
formatador (0.2.4)
|
|
26
|
+
guard (2.4.0)
|
|
27
|
+
formatador (>= 0.2.4)
|
|
28
|
+
listen (~> 2.1)
|
|
29
|
+
lumberjack (~> 1.0)
|
|
30
|
+
pry (>= 0.9.12)
|
|
31
|
+
thor (>= 0.18.1)
|
|
32
|
+
guard-rspec (4.2.7)
|
|
33
|
+
guard (~> 2.1)
|
|
34
|
+
rspec (>= 2.14, < 4.0)
|
|
35
|
+
i18n (0.6.9)
|
|
36
|
+
json (1.8.1)
|
|
37
|
+
listen (2.5.0)
|
|
38
|
+
celluloid (>= 0.15.2)
|
|
39
|
+
celluloid-io (>= 0.15.0)
|
|
40
|
+
rb-fsevent (>= 0.9.3)
|
|
41
|
+
rb-inotify (>= 0.9)
|
|
42
|
+
lumberjack (1.0.4)
|
|
43
|
+
method_source (0.8.2)
|
|
44
|
+
mini_portile (0.6.0)
|
|
45
|
+
minitest (5.3.4)
|
|
46
|
+
nio4r (1.0.0)
|
|
47
|
+
nokogiri (1.6.2.1)
|
|
48
|
+
mini_portile (= 0.6.0)
|
|
49
|
+
pry (0.9.12.6)
|
|
50
|
+
coderay (~> 1.0)
|
|
51
|
+
method_source (~> 0.8)
|
|
52
|
+
slop (~> 3.4)
|
|
53
|
+
rb-fsevent (0.9.4)
|
|
54
|
+
rb-inotify (0.9.3)
|
|
55
|
+
ffi (>= 0.5.0)
|
|
56
|
+
rspec (2.14.1)
|
|
57
|
+
rspec-core (~> 2.14.0)
|
|
58
|
+
rspec-expectations (~> 2.14.0)
|
|
59
|
+
rspec-mocks (~> 2.14.0)
|
|
60
|
+
rspec-core (2.14.7)
|
|
61
|
+
rspec-expectations (2.14.5)
|
|
62
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
63
|
+
rspec-mocks (2.14.6)
|
|
64
|
+
slop (3.4.7)
|
|
65
|
+
thor (0.18.1)
|
|
66
|
+
thread_safe (0.3.3)
|
|
67
|
+
timers (1.1.0)
|
|
68
|
+
tzinfo (1.1.0)
|
|
69
|
+
thread_safe (~> 0.1)
|
|
70
|
+
|
|
71
|
+
PLATFORMS
|
|
72
|
+
ruby
|
|
73
|
+
|
|
74
|
+
DEPENDENCIES
|
|
75
|
+
bundler
|
|
76
|
+
guard-rspec
|
|
77
|
+
inaho!
|
|
78
|
+
rspec
|
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Sebastian Szturo
|
|
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,58 @@
|
|
|
1
|
+
## Inaho :ear_of_rice:
|
|
2
|
+
|
|
3
|
+
A gem to easily build XML Files to create Dictionaries for Apple's Dictionary.app.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
- Ruby 1.9
|
|
7
|
+
- [Dictionary Development Kit](https://github.com/SebastianSzturo/dictionary-development-kit)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this to your gemfile
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'inaho'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
and
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
bundle
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Create a Dictionary.
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
dictionary = Inaho::Dictionary.new
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Add Entries to your Dictionary.
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
entry = Inaho::Entry.new(id: 1, title: "稲穂", yomi: "いなほ")
|
|
35
|
+
entry.add_index("稲穂")
|
|
36
|
+
entry.add_index("いなほ")
|
|
37
|
+
entry.add_index("inaho")
|
|
38
|
+
entry.add_index("ear (head) of rice")
|
|
39
|
+
entry.body = "<h3>稲穂 (いなほ)</h3> <ul><li>ear (head) of rice</li></ul>"
|
|
40
|
+
|
|
41
|
+
dictionary << entry
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Build your Dictionary XML File
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
xml = dictionary.to_xml
|
|
48
|
+
File.write('./dictionary.xml', xml)
|
|
49
|
+
```
|
|
50
|
+
Create your Dictionary with Apple's [Dictionary Development Kit](https://github.com/SebastianSzturo/dictionary-development-kit).
|
|
51
|
+
|
|
52
|
+
## Contributing
|
|
53
|
+
|
|
54
|
+
1. Fork it
|
|
55
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
56
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
57
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
58
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/inaho.gemspec
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'inaho/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "inaho"
|
|
8
|
+
spec.version = Inaho::VERSION
|
|
9
|
+
spec.authors = ["Sebastian Szturo"]
|
|
10
|
+
spec.email = ["s.szturo@me.com"]
|
|
11
|
+
spec.description = "Easily create Dictionaries for Apple's Dictionary.app"
|
|
12
|
+
spec.summary = "Easily create Dictionaries for Apple's Dictionary.app"
|
|
13
|
+
spec.homepage = "http://github.com/SebastianSzturo/Inaho"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
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 "activesupport"
|
|
22
|
+
spec.add_dependency "nokogiri"
|
|
23
|
+
spec.add_development_dependency "bundler"
|
|
24
|
+
spec.add_development_dependency "rspec"
|
|
25
|
+
spec.add_development_dependency "guard-rspec"
|
|
26
|
+
end
|
data/lib/inaho.rb
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'nokogiri'
|
|
2
|
+
|
|
3
|
+
module Inaho
|
|
4
|
+
class Dictionary
|
|
5
|
+
# Create new Dictionary object.
|
|
6
|
+
#
|
|
7
|
+
# options - Optional Symbol-keyed Hash:
|
|
8
|
+
# :entries - Array of Inaho::Entry Objects
|
|
9
|
+
#
|
|
10
|
+
# Returns an instance of Inaho::Dictionary.
|
|
11
|
+
def initialize(options = {})
|
|
12
|
+
options.each { |k, v| instance_variable_set("@#{k}", v) }
|
|
13
|
+
@entries ||= []
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Add Entry Object to entries Array.
|
|
17
|
+
#
|
|
18
|
+
def <<(entry)
|
|
19
|
+
@entries << entry if entry.kind_of?(Inaho::Entry)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Provide access to entries Array.
|
|
23
|
+
#
|
|
24
|
+
# Returns Array.
|
|
25
|
+
def entries
|
|
26
|
+
return Array(@entries)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Validate Dictionary xml with Apple's RelaxNG schema.
|
|
30
|
+
#
|
|
31
|
+
# Returns true if xml is valid.
|
|
32
|
+
# Returns List of Nokogiri::XML::SyntaxError objects if xml is not valid.
|
|
33
|
+
def validate
|
|
34
|
+
errors = []
|
|
35
|
+
schema_path = File.expand_path("../../../vendor/AppleDictionarySchema.rng", __FILE__)
|
|
36
|
+
|
|
37
|
+
schema = Nokogiri::XML::RelaxNG(File.open(schema_path))
|
|
38
|
+
schema.validate(Nokogiri::XML(self.to_xml)).each do |error|
|
|
39
|
+
errors << error
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if errors.size > 0
|
|
43
|
+
return errors
|
|
44
|
+
else
|
|
45
|
+
return true
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Generates xml for Dictionary and Entry objects.
|
|
50
|
+
#
|
|
51
|
+
# Returns String.
|
|
52
|
+
def to_xml
|
|
53
|
+
xml = ""
|
|
54
|
+
xml << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
|
55
|
+
xml << "<d:dictionary xmlns=\"http://www.w3.org/1999/xhtml\" "
|
|
56
|
+
xml << "xmlns:d=\"http://www.apple.com/DTDs/DictionaryService-1.0.rng\">\n"
|
|
57
|
+
@entries.each do |entry|
|
|
58
|
+
next if entry.to_xml.nil?
|
|
59
|
+
|
|
60
|
+
xml << entry.to_xml
|
|
61
|
+
end
|
|
62
|
+
xml << "</d:dictionary>"
|
|
63
|
+
|
|
64
|
+
return xml
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
end
|
data/lib/inaho/entry.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Inaho
|
|
2
|
+
class Entry
|
|
3
|
+
attr_accessor :id, :title, :yomi, :body, :index
|
|
4
|
+
|
|
5
|
+
# Create new Entry object.
|
|
6
|
+
#
|
|
7
|
+
# options - Optional Symbol-keyed Hash:
|
|
8
|
+
# :id - Optional id if you dont want the generated one.
|
|
9
|
+
# :title - Title for the Dictionary Entry.
|
|
10
|
+
# :index - Array of strings to index the Entry.
|
|
11
|
+
# :body - Html body for the Dictionary Entry.
|
|
12
|
+
# :yomi - Alternative reading field for foreign alphabets.
|
|
13
|
+
# See Apple's Docs for more info.
|
|
14
|
+
#
|
|
15
|
+
# Returns an instance of Inaho::Dictionary.
|
|
16
|
+
def initialize(options = {})
|
|
17
|
+
options.each { |k, v| instance_variable_set("@#{k}", v) }
|
|
18
|
+
@index ||= []
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Add string to index array.
|
|
22
|
+
#
|
|
23
|
+
# Returns index Array.
|
|
24
|
+
def add_index(value)
|
|
25
|
+
@index << value.to_s
|
|
26
|
+
return @index
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Generates xml for the Entry object.
|
|
30
|
+
#
|
|
31
|
+
# Returns String.
|
|
32
|
+
def to_xml
|
|
33
|
+
return nil if title.nil? || body.nil?
|
|
34
|
+
|
|
35
|
+
xml = ""
|
|
36
|
+
xml << "<d:entry id=\"#{self.id}\" d:title=\"#{self.title}\">\n"
|
|
37
|
+
@index.each do |i|
|
|
38
|
+
xml << "\t<d:index d:value=\"#{i}\" d:title=\"#{title}\" "
|
|
39
|
+
xml << "d:yomi=\"#{yomi}\"" if !self.yomi.nil?
|
|
40
|
+
xml << "/>\n"
|
|
41
|
+
end
|
|
42
|
+
xml << "\t<div>\n"
|
|
43
|
+
xml << "\t\t#{@body}\n"
|
|
44
|
+
xml << "\t</div>\n"
|
|
45
|
+
xml << "</d:entry>\n"
|
|
46
|
+
|
|
47
|
+
return xml
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Inaho::Dictionary do
|
|
4
|
+
describe "#validate" do
|
|
5
|
+
it "should validate xml" do
|
|
6
|
+
dictionary = Inaho::Dictionary.new
|
|
7
|
+
entry = Inaho::Entry.new(id: "inaho", title: "稲穂", yomi: "いなほ")
|
|
8
|
+
entry.add_index("いなほ")
|
|
9
|
+
entry.add_index("inaho")
|
|
10
|
+
entry.body = "<h3>稲穂 (いなほ)</h3> <ul><li>ear (head) of rice</li></ul>"
|
|
11
|
+
dictionary << @entry
|
|
12
|
+
|
|
13
|
+
dictionary.validate.should == true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should not be valid without index" do
|
|
17
|
+
dictionary = Inaho::Dictionary.new
|
|
18
|
+
entry = Inaho::Entry.new(id: "inaho", title: "稲穂", yomi: "いなほ")
|
|
19
|
+
entry.body = "<h3>稲穂 (いなほ)</h3> <ul><li>ear (head) of rice</li></ul>"
|
|
20
|
+
dictionary << @entry
|
|
21
|
+
|
|
22
|
+
dictionary.validate.should be_kind_of(Array)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should be valid without a yomi" do
|
|
26
|
+
dictionary = Inaho::Dictionary.new
|
|
27
|
+
entry = Inaho::Entry.new(id: "inaho", title: "稲穂")
|
|
28
|
+
entry.id = "inaho_1"
|
|
29
|
+
entry.add_index("いなほ")
|
|
30
|
+
entry.add_index("inaho")
|
|
31
|
+
entry.body = "<h3>稲穂 (いなほ)</h3> <ul><li>ear (head) of rice</li></ul>"
|
|
32
|
+
|
|
33
|
+
dictionary.validate.should == true
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Inaho::Entry do
|
|
4
|
+
describe "#add_index" do
|
|
5
|
+
it "should add string to index array" do
|
|
6
|
+
entry = Inaho::Entry.new(id: 1, title: "稲穂", yomi: "いなほ")
|
|
7
|
+
entry.add_index("稲穂")
|
|
8
|
+
entry.add_index("いなほ")
|
|
9
|
+
entry.add_index("inaho")
|
|
10
|
+
entry.add_index("ear (head) of rice")
|
|
11
|
+
|
|
12
|
+
entry.index.size.should == 4
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "#to_xml" do
|
|
17
|
+
it "should return nil if body or title is nil" do
|
|
18
|
+
entry = Inaho::Entry.new(id: 1, title: "稲穂", yomi: "いなほ")
|
|
19
|
+
|
|
20
|
+
entry.to_xml.should be_nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should transform to xml" do
|
|
24
|
+
entry = Inaho::Entry.new(id: 1, title: "稲穂", yomi: "いなほ")
|
|
25
|
+
entry.add_index("稲穂")
|
|
26
|
+
entry.add_index("いなほ")
|
|
27
|
+
entry.add_index("inaho")
|
|
28
|
+
entry.add_index("ear (head) of rice")
|
|
29
|
+
entry.body = "<h3>稲穂 (いなほ)</h3> <ul><li>ear (head) of rice</li></ul>"
|
|
30
|
+
|
|
31
|
+
entry.to_xml.should_not be_nil
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<!-- Dictionary Schema + XHTML Strict -->
|
|
2
|
+
|
|
3
|
+
<grammar ns="http://www.w3.org/1999/xhtml"
|
|
4
|
+
xmlns="http://relaxng.org/ns/structure/1.0">
|
|
5
|
+
|
|
6
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/datatypes.rng"/>
|
|
7
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/attribs.rng"/>
|
|
8
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/text.rng"/>
|
|
9
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/hypertext.rng"/>
|
|
10
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/list.rng"/>
|
|
11
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/image.rng"/>
|
|
12
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/ssismap.rng"/>
|
|
13
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/base.rng"/>
|
|
14
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/link.rng"/>
|
|
15
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/meta.rng"/>
|
|
16
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/param.rng"/>
|
|
17
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/object.rng"/>
|
|
18
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/bdo.rng"/>
|
|
19
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/pres.rng"/>
|
|
20
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/edit.rng"/>
|
|
21
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/applet.rng"/>
|
|
22
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/form.rng"/>
|
|
23
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/style.rng"/>
|
|
24
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/script.rng"/>
|
|
25
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/table.rng"/>
|
|
26
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/csismap.rng"/>
|
|
27
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/events.rng"/>
|
|
28
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/inlstyle.rng"/>
|
|
29
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/target.rng"/>
|
|
30
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/iframe.rng"/>
|
|
31
|
+
<include href="http://thaiopensource.com/relaxng/xhtml/modules/nameident.rng"/>
|
|
32
|
+
<include href="modules/dict-struct.rng"/>
|
|
33
|
+
|
|
34
|
+
</grammar>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!-- Dictionary Structure Module -->
|
|
3
|
+
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<start>
|
|
7
|
+
<ref name="dictionary"/>
|
|
8
|
+
</start>
|
|
9
|
+
|
|
10
|
+
<define name="entry">
|
|
11
|
+
<element name="entry" ns="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
|
|
12
|
+
<ref name="entry.attlist"/>
|
|
13
|
+
<zeroOrMore>
|
|
14
|
+
<ref name="index"/>
|
|
15
|
+
</zeroOrMore>
|
|
16
|
+
<ref name="Flow.model"/>
|
|
17
|
+
</element>
|
|
18
|
+
</define>
|
|
19
|
+
|
|
20
|
+
<define name="entry.attlist">
|
|
21
|
+
<ref name="id.attrib"/>
|
|
22
|
+
<optional>
|
|
23
|
+
<ref name="parental-control.attrib"/>
|
|
24
|
+
</optional>
|
|
25
|
+
<optional>
|
|
26
|
+
<attribute name="title" ns="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
|
|
27
|
+
<text/>
|
|
28
|
+
</attribute>
|
|
29
|
+
</optional>
|
|
30
|
+
</define>
|
|
31
|
+
|
|
32
|
+
<define name="index">
|
|
33
|
+
<element name="index" ns="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
|
|
34
|
+
<ref name="index.attlist"/>
|
|
35
|
+
</element>
|
|
36
|
+
</define>
|
|
37
|
+
|
|
38
|
+
<define name="index.attlist">
|
|
39
|
+
<attribute name="value" ns="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
|
|
40
|
+
<text/>
|
|
41
|
+
</attribute>
|
|
42
|
+
<optional>
|
|
43
|
+
<attribute name="title" ns="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
|
|
44
|
+
<text/>
|
|
45
|
+
</attribute>
|
|
46
|
+
</optional>
|
|
47
|
+
<optional>
|
|
48
|
+
<ref name="parental-control.attrib"/>
|
|
49
|
+
</optional>
|
|
50
|
+
<optional>
|
|
51
|
+
<ref name="priority.attrib"/>
|
|
52
|
+
</optional>
|
|
53
|
+
<optional>
|
|
54
|
+
<attribute name="anchor" ns="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
|
|
55
|
+
<text/>
|
|
56
|
+
</attribute>
|
|
57
|
+
</optional>
|
|
58
|
+
<optional>
|
|
59
|
+
<attribute name="yomi" ns="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
|
|
60
|
+
<text/>
|
|
61
|
+
</attribute>
|
|
62
|
+
</optional>
|
|
63
|
+
|
|
64
|
+
</define>
|
|
65
|
+
|
|
66
|
+
<define name="dictionary">
|
|
67
|
+
<element name="dictionary" ns="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
|
|
68
|
+
<zeroOrMore>
|
|
69
|
+
<ref name="style"/>
|
|
70
|
+
</zeroOrMore>
|
|
71
|
+
<ref name="dictionary.attlist"/>
|
|
72
|
+
<oneOrMore>
|
|
73
|
+
<ref name="entry"/>
|
|
74
|
+
</oneOrMore>
|
|
75
|
+
</element>
|
|
76
|
+
</define>
|
|
77
|
+
|
|
78
|
+
<define name="dictionary.attlist">
|
|
79
|
+
<ref name="XHTML.version.attrib"/>
|
|
80
|
+
<ref name="I18n.attrib"/>
|
|
81
|
+
</define>
|
|
82
|
+
|
|
83
|
+
<define name="XHTML.version.attrib">
|
|
84
|
+
<optional>
|
|
85
|
+
<attribute name="version">
|
|
86
|
+
<ref name="FPI.datatype"/>
|
|
87
|
+
</attribute>
|
|
88
|
+
</optional>
|
|
89
|
+
</define>
|
|
90
|
+
|
|
91
|
+
<!-- add new attribute for div,span -->
|
|
92
|
+
<define name="priority.attrib">
|
|
93
|
+
<attribute name="priority" ns="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
|
|
94
|
+
<ref name="Number.datatype"/>
|
|
95
|
+
</attribute>
|
|
96
|
+
</define>
|
|
97
|
+
|
|
98
|
+
<define name="parental-control.attrib">
|
|
99
|
+
<attribute name="parental-control" ns="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
|
|
100
|
+
<value>1</value>
|
|
101
|
+
</attribute>
|
|
102
|
+
</define>
|
|
103
|
+
|
|
104
|
+
<define name="pr.attrib">
|
|
105
|
+
<attribute name="pr" ns="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
|
|
106
|
+
<text/>
|
|
107
|
+
</attribute>
|
|
108
|
+
</define>
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
<!-- Add attribute for XHTML -->
|
|
112
|
+
|
|
113
|
+
<define name="div.attlist" combine="interleave">
|
|
114
|
+
<optional>
|
|
115
|
+
<ref name="priority.attrib"/>
|
|
116
|
+
</optional>
|
|
117
|
+
<optional>
|
|
118
|
+
<ref name="parental-control.attrib"/>
|
|
119
|
+
</optional>
|
|
120
|
+
<optional>
|
|
121
|
+
<ref name="pr.attrib"/>
|
|
122
|
+
</optional>
|
|
123
|
+
</define>
|
|
124
|
+
|
|
125
|
+
<define name="span.attlist" combine="interleave">
|
|
126
|
+
<optional>
|
|
127
|
+
<ref name="priority.attrib"/>
|
|
128
|
+
</optional>
|
|
129
|
+
<optional>
|
|
130
|
+
<ref name="parental-control.attrib"/>
|
|
131
|
+
</optional>
|
|
132
|
+
<optional>
|
|
133
|
+
<ref name="pr.attrib"/>
|
|
134
|
+
</optional>
|
|
135
|
+
</define>
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
</grammar>
|
metadata
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: inaho
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sebastian Szturo
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-06-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: activesupport
|
|
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: nokogiri
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: guard-rspec
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description: Easily create Dictionaries for Apple's Dictionary.app
|
|
84
|
+
email:
|
|
85
|
+
- s.szturo@me.com
|
|
86
|
+
executables: []
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- ".gitignore"
|
|
91
|
+
- ".rspec"
|
|
92
|
+
- Gemfile
|
|
93
|
+
- Gemfile.lock
|
|
94
|
+
- Guardfile
|
|
95
|
+
- LICENSE.txt
|
|
96
|
+
- README.md
|
|
97
|
+
- Rakefile
|
|
98
|
+
- inaho.gemspec
|
|
99
|
+
- lib/inaho.rb
|
|
100
|
+
- lib/inaho/dictionary.rb
|
|
101
|
+
- lib/inaho/entry.rb
|
|
102
|
+
- lib/inaho/version.rb
|
|
103
|
+
- spec/inaho/dictionary_spec.rb
|
|
104
|
+
- spec/inaho/entry_spec.rb
|
|
105
|
+
- spec/spec_helper.rb
|
|
106
|
+
- vendor/AppleDictionarySchema.rng
|
|
107
|
+
- vendor/modules/dict-struct.rng
|
|
108
|
+
homepage: http://github.com/SebastianSzturo/Inaho
|
|
109
|
+
licenses:
|
|
110
|
+
- MIT
|
|
111
|
+
metadata: {}
|
|
112
|
+
post_install_message:
|
|
113
|
+
rdoc_options: []
|
|
114
|
+
require_paths:
|
|
115
|
+
- lib
|
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
|
+
requirements:
|
|
118
|
+
- - ">="
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: '0'
|
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - ">="
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
126
|
+
requirements: []
|
|
127
|
+
rubyforge_project:
|
|
128
|
+
rubygems_version: 2.2.1
|
|
129
|
+
signing_key:
|
|
130
|
+
specification_version: 4
|
|
131
|
+
summary: Easily create Dictionaries for Apple's Dictionary.app
|
|
132
|
+
test_files:
|
|
133
|
+
- spec/inaho/dictionary_spec.rb
|
|
134
|
+
- spec/inaho/entry_spec.rb
|
|
135
|
+
- spec/spec_helper.rb
|