ulysses 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/ulysses.rb +11 -0
- data/lib/ulysses/exporter.rb +287 -0
- data/lib/ulysses/group.rb +35 -0
- data/lib/ulysses/library.rb +18 -0
- data/lib/ulysses/sheet.rb +28 -0
- data/lib/ulysses/version.rb +3 -0
- data/ulysses.gemspec +30 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f4e13d121f75e0e2a05613bcce5e1cde731d18ec
|
4
|
+
data.tar.gz: a7fa728bb25f65dc90be147f4a7d734e3f9220bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2558ca71b86d63dfc6b785a66b65af216b4f43b635357fbad898957df045aad8719a1b5071022d1d9c5b7072e11cb6f46246aa23a2c98a30af662b4da576be98
|
7
|
+
data.tar.gz: 558294b9a9c596eb118ebfef2d8893bc7dda1166ecbd6a9bfbdb502cf823ca78b660f7bdaa0f94cfb9cf243aaf5fc5950497b8951ec2f7944b3e8024a58efb4d
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at y@whir.org. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Yaodong Zhao
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Ulysses
|
2
|
+
|
3
|
+
This is a library to export your to HTML files. It still in development.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ulysses'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ulysses
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Get your library:
|
24
|
+
|
25
|
+
library = Ulysses::Library.new
|
26
|
+
|
27
|
+
Get groups from library
|
28
|
+
|
29
|
+
groups = library.groups
|
30
|
+
|
31
|
+
Get children groups:
|
32
|
+
|
33
|
+
group = library.groups.first
|
34
|
+
children = group.children
|
35
|
+
|
36
|
+
Get Sheets:
|
37
|
+
|
38
|
+
group.sheets
|
39
|
+
|
40
|
+
Export sheet to HTML:
|
41
|
+
|
42
|
+
sheet = group.sheets.first
|
43
|
+
html = sheet.to_html
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
48
|
+
|
49
|
+
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).
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yaodong/gem-ulysses. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
54
|
+
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ulysses"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/ulysses.rb
ADDED
@@ -0,0 +1,287 @@
|
|
1
|
+
module Ulysses
|
2
|
+
class Exporter
|
3
|
+
|
4
|
+
def initialize(sheet_xml)
|
5
|
+
@xml = Nokogiri::XML sheet_xml
|
6
|
+
@coder = HTMLEntities.new
|
7
|
+
@annotations = []
|
8
|
+
@footnotes = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_html
|
12
|
+
tree = xml_to_tree @xml.xpath('/sheet/string[@xml:space="preserve"]')
|
13
|
+
html = tree_to_html tree
|
14
|
+
html = parse_prefix_tags(html)
|
15
|
+
html = append_footnotes(html)
|
16
|
+
html = append_annotations(html)
|
17
|
+
Kramdown::Document.new(html).to_html
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def xml_to_tree(xml)
|
23
|
+
xml.children.map do |child|
|
24
|
+
if child.text?
|
25
|
+
child.content
|
26
|
+
elsif child.element?
|
27
|
+
{
|
28
|
+
name: child.name,
|
29
|
+
attributes: Hash[child.attribute_nodes.map { |an| [an.node_name, an.content] }],
|
30
|
+
children: child.children.length > 0 ? xml_to_tree(child) : []
|
31
|
+
}
|
32
|
+
else
|
33
|
+
raise "Unknown node type: #{child.class}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def tree_to_html(tree)
|
39
|
+
html = ''
|
40
|
+
tree.each do |node|
|
41
|
+
if node.is_a?(String)
|
42
|
+
html += @coder.encode node
|
43
|
+
else
|
44
|
+
case node[:name]
|
45
|
+
when 'p'
|
46
|
+
html += p_to_html node
|
47
|
+
when 'tags'
|
48
|
+
html += tree_to_html(node[:children])
|
49
|
+
when 'tag'
|
50
|
+
html += prefix_tag_to_placeholder node
|
51
|
+
when 'element'
|
52
|
+
html += element_to_html(node)
|
53
|
+
when 'attribute'
|
54
|
+
html += attribute_to_html(node)
|
55
|
+
when 'string'
|
56
|
+
html += string_to_html(node)
|
57
|
+
else
|
58
|
+
raise "Unknown tree node type: #{node[:name]}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
html
|
63
|
+
end
|
64
|
+
|
65
|
+
def p_to_html(node)
|
66
|
+
if node[:children].any?
|
67
|
+
tree_to_html(node[:children])
|
68
|
+
else
|
69
|
+
''
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def inline_tag_to_html(node, tag, attr = nil)
|
74
|
+
open_tag = attr.nil? ? "<#{tag} #{attr}>" : "<#{tag}>"
|
75
|
+
if node[:children].any?
|
76
|
+
open_tag + tree_to_html(node[:children]) + "</#{tag}>"
|
77
|
+
else
|
78
|
+
"#{open_tag}</#{tag}>"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def link_to_html(link)
|
83
|
+
string = '<a'
|
84
|
+
text = ''
|
85
|
+
link[:children].each do |child|
|
86
|
+
if child.is_a? String
|
87
|
+
text = child
|
88
|
+
else
|
89
|
+
identifier = child[:attributes]['identifier']
|
90
|
+
case
|
91
|
+
when 'URL'
|
92
|
+
string += ' url="'+ child[:children].first + '"'
|
93
|
+
when 'title'
|
94
|
+
string += ' title="'+ child[:children].first + '"'
|
95
|
+
else
|
96
|
+
raise "unknown link attr identifier #{identifier}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
string + '>' + text + '</a>'
|
101
|
+
end
|
102
|
+
|
103
|
+
def image_to_html(node)
|
104
|
+
html = '<img'
|
105
|
+
node[:children].each do |child|
|
106
|
+
case child[:attributes]['identifier']
|
107
|
+
when 'URL'
|
108
|
+
html += ' url="'+ child[:children].first + '"'
|
109
|
+
when 'title'
|
110
|
+
html += ' title="'+ child[:children].first + '"'
|
111
|
+
else
|
112
|
+
# skip
|
113
|
+
end
|
114
|
+
end
|
115
|
+
html + ' />'
|
116
|
+
end
|
117
|
+
|
118
|
+
def video_to_html(node)
|
119
|
+
source = ''
|
120
|
+
node[:children].each do |child|
|
121
|
+
case child[:attributes]['identifier']
|
122
|
+
when 'URL'
|
123
|
+
source = child[:children].first
|
124
|
+
else
|
125
|
+
# skip
|
126
|
+
end
|
127
|
+
end
|
128
|
+
'<video><source src="' + source + '"></video>'
|
129
|
+
end
|
130
|
+
|
131
|
+
def element_to_html(node)
|
132
|
+
case node[:attributes]['kind']
|
133
|
+
when 'strong'
|
134
|
+
inline_tag_to_html(node, 'strong')
|
135
|
+
when 'emph'
|
136
|
+
inline_tag_to_html(node, 'em')
|
137
|
+
when 'mark'
|
138
|
+
inline_tag_to_html(node, 'span', 'class="marked"')
|
139
|
+
when 'delete'
|
140
|
+
inline_tag_to_html(node, 'del')
|
141
|
+
when 'inlineComment'
|
142
|
+
inline_tag_to_html(node, 'span', 'class="comment"')
|
143
|
+
when 'code'
|
144
|
+
inline_tag_to_html(node, 'code')
|
145
|
+
when 'inlineNative'
|
146
|
+
inline_tag_to_html(node, 'span', 'class="native"')
|
147
|
+
when 'link'
|
148
|
+
link_to_html(node)
|
149
|
+
when 'annotation'
|
150
|
+
@annotations << [node[:children].last, tree_to_html(node[:children].first[:children])]
|
151
|
+
"<placeholder-annotation-#{@annotations.size - 1}/>"
|
152
|
+
when 'image'
|
153
|
+
image_to_html(node)
|
154
|
+
when 'video'
|
155
|
+
video_to_html(node)
|
156
|
+
when 'footnote'
|
157
|
+
string_node = node[:children].first[:children].first
|
158
|
+
@footnotes << tree_to_html(string_node[:children])
|
159
|
+
"<placeholder-footnote-#{@footnotes.size - 1}/>"
|
160
|
+
else
|
161
|
+
raise node
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def prefix_tag_to_placeholder(node)
|
166
|
+
case node[:attributes]['kind']
|
167
|
+
when 'codeblock'
|
168
|
+
string = '<<prefix-tag-code-block>>'
|
169
|
+
when 'comment'
|
170
|
+
string = '<<prefix-tag-comment>>'
|
171
|
+
when 'divider'
|
172
|
+
string = '<hr class="divider" />'
|
173
|
+
when 'nativeblock'
|
174
|
+
string = '<<prefix-tag-native-block>>'
|
175
|
+
when 'blockquote'
|
176
|
+
string = '<<prefix-tag-block-quote>>'
|
177
|
+
when 'orderedList'
|
178
|
+
string = node[:children].first
|
179
|
+
when 'unorderedList'
|
180
|
+
string = node[:children].first
|
181
|
+
when 'heading1'
|
182
|
+
string = '<<prefix-tag-heading-1>>'
|
183
|
+
when 'heading2'
|
184
|
+
string = '<<prefix-tag-heading-2>>'
|
185
|
+
when 'heading3'
|
186
|
+
string = '<<prefix-tag-heading-5>>'
|
187
|
+
when 'heading4'
|
188
|
+
string = '<<prefix-tag-heading-4>>'
|
189
|
+
when 'heading5'
|
190
|
+
string = '<<prefix-tag-heading-5>>'
|
191
|
+
when 'heading6'
|
192
|
+
string = '<<prefix-tag-heading-6>>'
|
193
|
+
else
|
194
|
+
if node[:attributes].empty? && node[:children].first == "\t"
|
195
|
+
string = "\t"
|
196
|
+
else
|
197
|
+
raise node
|
198
|
+
end
|
199
|
+
end
|
200
|
+
string
|
201
|
+
end
|
202
|
+
|
203
|
+
def attribute_to_html(node)
|
204
|
+
case node[:attributes]['identifier']
|
205
|
+
when 'text'
|
206
|
+
html = tree_to_html node[:children]
|
207
|
+
else
|
208
|
+
raise "Unknown attribute node type: #{node[:attributes]['identifier']}"
|
209
|
+
end
|
210
|
+
html
|
211
|
+
end
|
212
|
+
|
213
|
+
def string_to_html(node)
|
214
|
+
case node[:attributes]['space']
|
215
|
+
when 'preserve'
|
216
|
+
html = tree_to_html node[:children]
|
217
|
+
else
|
218
|
+
raise "Unknown string node: #{node[:attributes]['space']}"
|
219
|
+
end
|
220
|
+
html
|
221
|
+
end
|
222
|
+
|
223
|
+
def parse_prefix_tags(html)
|
224
|
+
lines = html.split("\n")
|
225
|
+
|
226
|
+
prefix_tags = []
|
227
|
+
lines = lines.map do |line|
|
228
|
+
if /\A<<(prefix-tag[a-z0-9\-]+)>>(.*)\Z/i.match line
|
229
|
+
prefix_tags << $1
|
230
|
+
"<#{$1}>" + $2 + "</#{$1}>"
|
231
|
+
else
|
232
|
+
line
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
html = lines.join("\n")
|
237
|
+
prefix_tags.uniq.each do |prefix|
|
238
|
+
case prefix
|
239
|
+
when 'prefix-tag-code-block'
|
240
|
+
html_tag = 'pre-code'
|
241
|
+
when 'prefix-tag-native-block'
|
242
|
+
html_tag = 'pre-raw'
|
243
|
+
when 'prefix-tag-comment'
|
244
|
+
html_tag = 'should-delete'
|
245
|
+
when 'prefix-tag-block-quote'
|
246
|
+
html_tag = 'blockquote'
|
247
|
+
when /\Aprefix-tag-heading-(\d)\Z/i
|
248
|
+
html_tag = "h#{$1}"
|
249
|
+
else
|
250
|
+
raise "Unknown prefix tag: #{prefix}"
|
251
|
+
end
|
252
|
+
html.gsub! %r/(<\/?)#{prefix}>/, "\\1#{html_tag}>"
|
253
|
+
html.gsub! %r/<\/#{html_tag}>(\n*)<#{html_tag}>/, "\\1"
|
254
|
+
end
|
255
|
+
|
256
|
+
html.gsub! /<should-delete>.*<\/should-delete>\n?/, ''
|
257
|
+
|
258
|
+
html.gsub! /<pre-code>/, '<pre><code>'
|
259
|
+
html.gsub! /<\/pre-code>/, '</code></pre>'
|
260
|
+
|
261
|
+
html.gsub! /<pre-raw>/, '<p class="raw">'
|
262
|
+
html.gsub! /<\/pre-raw>/, '</p>'
|
263
|
+
|
264
|
+
html
|
265
|
+
end
|
266
|
+
|
267
|
+
def append_footnotes(html)
|
268
|
+
footnote_html = '<div class="footnotes">'
|
269
|
+
@footnotes.each_with_index do |fn, index|
|
270
|
+
html.gsub! /<placeholder-footnote-#{index}\/>/, "<sup><a href=\"#fn#{index}\" id=\"ref#{index}\">#{index}</a></sup>"
|
271
|
+
footnote_html += "<sup id=\"fn#{index}\">#{index}. " + fn + '</sup>'
|
272
|
+
end
|
273
|
+
html + "\n\n" + footnote_html + "</div>\n"
|
274
|
+
end
|
275
|
+
|
276
|
+
def append_annotations(html)
|
277
|
+
annotations_html = '<div class="annotations">'
|
278
|
+
@annotations.each_with_index do |at, index|
|
279
|
+
html.gsub! /<placeholder-annotation-#{index}/, "<span class=\"annotated\" data-annotation=\"#{index}\">#{at[0]}</span>"
|
280
|
+
annotations_html += "<section data-annotation=\"#{index}\">" + at[1] + '</section>'
|
281
|
+
end
|
282
|
+
|
283
|
+
html + "\n\n" + annotations_html + "</div>\n"
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|
287
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Ulysses
|
2
|
+
class Group
|
3
|
+
|
4
|
+
attr_reader :dirname
|
5
|
+
|
6
|
+
def initialize(info_file_path)
|
7
|
+
@dirname = File.dirname(info_file_path)
|
8
|
+
@info = parse_info(info_file_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def children
|
12
|
+
@info['childOrder'].children.map do |child|
|
13
|
+
Group.new File.join(@dirname, child.content, 'Info.ulgroup') if child.element?
|
14
|
+
end.compact
|
15
|
+
end
|
16
|
+
|
17
|
+
def sheets
|
18
|
+
list = @info['sheetClusters'].children.find { |child| child.element? && child.name == 'array' }
|
19
|
+
list.children.map do |child|
|
20
|
+
Sheet.new File.join(@dirname, child.content) if child.element? && child.name == 'string'
|
21
|
+
end.compact
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def parse_info(file_path)
|
27
|
+
xml = Nokogiri::XML File.read(file_path)
|
28
|
+
dict = xml.xpath('//dict').children.map do |child|
|
29
|
+
(child.name == 'key' ? child.content : child) if child.element?
|
30
|
+
end.compact
|
31
|
+
Hash[*dict]
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Ulysses
|
2
|
+
class Library
|
3
|
+
|
4
|
+
attr_reader :dirname
|
5
|
+
|
6
|
+
def initialize(dirname = nil)
|
7
|
+
dirname ||= '~/Library/Mobile Documents/X5AZV975AG~com~soulmen~ulysses3/Documents/Library'
|
8
|
+
@dirname = File.expand_path(dirname)
|
9
|
+
end
|
10
|
+
|
11
|
+
def groups
|
12
|
+
Dir.glob(File.join @dirname, 'Groups-ulgroup', '*.ulgroup').map do |info_file|
|
13
|
+
Group.new info_file
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Ulysses
|
2
|
+
class Sheet
|
3
|
+
|
4
|
+
attr_reader :dirname
|
5
|
+
|
6
|
+
def initialize(dirname)
|
7
|
+
@dirname = dirname
|
8
|
+
end
|
9
|
+
|
10
|
+
def reload
|
11
|
+
@content = nil
|
12
|
+
@text = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def content
|
16
|
+
@content ||= File.read(File.join(@dirname, 'Content.xml'))
|
17
|
+
end
|
18
|
+
|
19
|
+
def text
|
20
|
+
@text ||= File.read(File.join(@dirname, 'Text.txt'))
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_html
|
24
|
+
Exporter.new(content).to_html
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/ulysses.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ulysses/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ulysses"
|
8
|
+
spec.version = Ulysses::VERSION
|
9
|
+
spec.authors = ["Yaodong Zhao"]
|
10
|
+
spec.email = ["y@whir.org"]
|
11
|
+
|
12
|
+
spec.summary = 'Access ulysses library by ruby'
|
13
|
+
spec.description = 'Access ulysses library by ruby'
|
14
|
+
spec.homepage = 'https://github.com/yaodong/gem-ulysses'
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency 'nokogiri'
|
23
|
+
spec.add_dependency 'kramdown'
|
24
|
+
spec.add_dependency 'htmlentities'
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ulysses
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yaodong Zhao
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
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: kramdown
|
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: htmlentities
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.0'
|
97
|
+
description: Access ulysses library by ruby
|
98
|
+
email:
|
99
|
+
- y@whir.org
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- CODE_OF_CONDUCT.md
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- lib/ulysses.rb
|
115
|
+
- lib/ulysses/exporter.rb
|
116
|
+
- lib/ulysses/group.rb
|
117
|
+
- lib/ulysses/library.rb
|
118
|
+
- lib/ulysses/sheet.rb
|
119
|
+
- lib/ulysses/version.rb
|
120
|
+
- ulysses.gemspec
|
121
|
+
homepage: https://github.com/yaodong/gem-ulysses
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.4.5
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Access ulysses library by ruby
|
145
|
+
test_files: []
|