polites 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +18 -0
  5. data/.tool-versions +1 -0
  6. data/.travis.yml +6 -0
  7. data/.yardopts +1 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +15 -0
  10. data/Gemfile.lock +128 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +70 -0
  13. data/Rakefile +9 -0
  14. data/bin/console +15 -0
  15. data/bin/setup +8 -0
  16. data/exe/polites +8 -0
  17. data/lib/polites.rb +33 -0
  18. data/lib/polites/block.rb +65 -0
  19. data/lib/polites/block/blockquote.rb +8 -0
  20. data/lib/polites/block/code_block.rb +18 -0
  21. data/lib/polites/block/divider.rb +8 -0
  22. data/lib/polites/block/heading.rb +8 -0
  23. data/lib/polites/block/heading1.rb +8 -0
  24. data/lib/polites/block/heading2.rb +8 -0
  25. data/lib/polites/block/heading3.rb +8 -0
  26. data/lib/polites/block/heading4.rb +8 -0
  27. data/lib/polites/block/heading5.rb +8 -0
  28. data/lib/polites/block/heading6.rb +8 -0
  29. data/lib/polites/block/list.rb +14 -0
  30. data/lib/polites/block/ordered_list.rb +8 -0
  31. data/lib/polites/block/paragraph.rb +8 -0
  32. data/lib/polites/block/unordered_list.rb +8 -0
  33. data/lib/polites/cli.rb +52 -0
  34. data/lib/polites/convert.rb +29 -0
  35. data/lib/polites/doc/_index.html +85 -0
  36. data/lib/polites/doc/class_list.html +51 -0
  37. data/lib/polites/doc/css/common.css +1 -0
  38. data/lib/polites/doc/css/full_list.css +58 -0
  39. data/lib/polites/doc/css/style.css +496 -0
  40. data/lib/polites/doc/file_list.html +51 -0
  41. data/lib/polites/doc/frames.html +17 -0
  42. data/lib/polites/doc/index.html +85 -0
  43. data/lib/polites/doc/js/app.js +314 -0
  44. data/lib/polites/doc/js/full_list.js +216 -0
  45. data/lib/polites/doc/js/jquery.js +4 -0
  46. data/lib/polites/doc/method_list.html +51 -0
  47. data/lib/polites/doc/top-level-namespace.html +100 -0
  48. data/lib/polites/file.rb +67 -0
  49. data/lib/polites/html_formatter.rb +119 -0
  50. data/lib/polites/list_indenter.rb +34 -0
  51. data/lib/polites/markup.rb +31 -0
  52. data/lib/polites/nanoc.rb +46 -0
  53. data/lib/polites/nanoc/data_source.rb +93 -0
  54. data/lib/polites/nanoc/embedded_images_filter.rb +22 -0
  55. data/lib/polites/nanoc/extract_file_filter.rb +21 -0
  56. data/lib/polites/node.rb +28 -0
  57. data/lib/polites/parser.rb +174 -0
  58. data/lib/polites/plist.rb +28 -0
  59. data/lib/polites/range_tag.rb +29 -0
  60. data/lib/polites/settings.rb +35 -0
  61. data/lib/polites/sheet.rb +63 -0
  62. data/lib/polites/simple_tag.rb +22 -0
  63. data/lib/polites/span.rb +60 -0
  64. data/lib/polites/span/annotation.rb +18 -0
  65. data/lib/polites/span/code.rb +8 -0
  66. data/lib/polites/span/delete.rb +8 -0
  67. data/lib/polites/span/emph.rb +8 -0
  68. data/lib/polites/span/footnote.rb +18 -0
  69. data/lib/polites/span/image.rb +29 -0
  70. data/lib/polites/span/link.rb +21 -0
  71. data/lib/polites/span/mark.rb +8 -0
  72. data/lib/polites/span/strong.rb +8 -0
  73. data/lib/polites/tag.rb +20 -0
  74. data/lib/polites/text.rb +20 -0
  75. data/lib/polites/version.rb +5 -0
  76. data/polites-nanoc.gemspec +31 -0
  77. data/polites.gemspec +33 -0
  78. metadata +153 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c10112a402b05b305c8b0f0f35c5e12445fa6bfaf2b08c265b6afe9bf7872aab
4
+ data.tar.gz: 7657d9cbcfe412ad9f87ee28db254fc1f2597efc7eb778261cfff5d81fe9ee35
5
+ SHA512:
6
+ metadata.gz: d58f9da84de182b7aacf89d7900e211c92684725374ab7c132a6cefdc05d40f51726bb0e671e14374e84306b2621fb8fd44debf24c3f2e4bd272ffb84e165293
7
+ data.tar.gz: '064096d81364faa6b32a756e31875cb728a067628cdfef9a7c0c4c5525d3b918ffd11c23d5cbe1c5a5afb58e6956216a1732ddb4f412b44540040dddd51b1662'
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,18 @@
1
+ # The behavior of RuboCop can be controlled via the .rubocop.yml
2
+ # configuration file. It makes it possible to enable/disable
3
+ # certain cops (checks) and to alter their behavior if they accept
4
+ # any parameters. The file can be placed either in your home
5
+ # directory or in some project directory.
6
+ #
7
+ # RuboCop will start looking for the configuration file in the directory
8
+ # where the inspected file is and continue its way up to the root directory.
9
+ #
10
+ # See https://docs.rubocop.org/rubocop/configuration
11
+ AllCops:
12
+ NewCops: enable
13
+
14
+ Style/ClassAndModuleChildren:
15
+ Enabled: false
16
+
17
+ Metrics/BlockLength:
18
+ Enabled: false
@@ -0,0 +1 @@
1
+ ruby 2.7.2
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1 @@
1
+ --no-private lib/**/*.rb --readme README.md --markup markdown --markup-provider kramdown - LICENSE.txt CODE_OF_CONDUCT.md
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at arjan@arjanvandergaag.nl. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec name: 'polites'
6
+ gemspec name: 'polites-nanoc'
7
+
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
10
+
11
+ group :development do
12
+ gem 'kramdown'
13
+ gem 'rubocop'
14
+ gem 'yard'
15
+ end
@@ -0,0 +1,128 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ polites (0.1.0)
5
+ nokogiri
6
+ rubyzip
7
+ polites-nanoc (0.1.0)
8
+ nanoc (~> 4)
9
+ polites (~> 0.1.0)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ addressable (2.7.0)
15
+ public_suffix (>= 2.0.2, < 5.0)
16
+ ast (2.4.1)
17
+ colored (1.2)
18
+ concurrent-ruby (1.1.7)
19
+ cri (2.15.10)
20
+ ddmemoize (1.0.0)
21
+ ddmetrics (~> 1.0)
22
+ ref (~> 2.0)
23
+ ddmetrics (1.0.1)
24
+ ddplugin (1.0.2)
25
+ diff-lcs (1.4.4)
26
+ hamster (3.0.0)
27
+ concurrent-ruby (~> 1.0)
28
+ json_schema (0.20.9)
29
+ kramdown (2.3.0)
30
+ rexml
31
+ mini_portile2 (2.4.0)
32
+ nanoc (4.11.19)
33
+ addressable (~> 2.5)
34
+ colored (~> 1.2)
35
+ nanoc-checking (~> 1.0)
36
+ nanoc-cli (= 4.11.19)
37
+ nanoc-core (= 4.11.19)
38
+ nanoc-deploying (~> 1.0)
39
+ parallel (~> 1.12)
40
+ tty-command (~> 0.8)
41
+ tty-which (~> 0.4)
42
+ nanoc-checking (1.0.0)
43
+ nanoc-cli (~> 4.11, >= 4.11.15)
44
+ nanoc-core (~> 4.11, >= 4.11.15)
45
+ nanoc-cli (4.11.19)
46
+ cri (~> 2.15)
47
+ diff-lcs (~> 1.3)
48
+ nanoc-core (= 4.11.19)
49
+ zeitwerk (~> 2.1)
50
+ nanoc-core (4.11.19)
51
+ concurrent-ruby (~> 1.1)
52
+ ddmemoize (~> 1.0)
53
+ ddmetrics (~> 1.0)
54
+ ddplugin (~> 1.0)
55
+ hamster (~> 3.0)
56
+ json_schema (~> 0.19)
57
+ slow_enumerator_tools (~> 1.0)
58
+ tomlrb (~> 1.2)
59
+ tty-platform (~> 0.2)
60
+ zeitwerk (~> 2.1)
61
+ nanoc-deploying (1.0.0)
62
+ nanoc-checking (~> 1.0)
63
+ nanoc-cli (~> 4.11, >= 4.11.15)
64
+ nanoc-core (~> 4.11, >= 4.11.15)
65
+ nokogiri (1.10.10)
66
+ mini_portile2 (~> 2.4.0)
67
+ parallel (1.20.0)
68
+ parser (2.7.2.0)
69
+ ast (~> 2.4.1)
70
+ pastel (0.8.0)
71
+ tty-color (~> 0.5)
72
+ public_suffix (4.0.6)
73
+ rainbow (3.0.0)
74
+ rake (12.3.3)
75
+ ref (2.0.0)
76
+ regexp_parser (1.8.2)
77
+ rexml (3.2.4)
78
+ rspec (3.10.0)
79
+ rspec-core (~> 3.10.0)
80
+ rspec-expectations (~> 3.10.0)
81
+ rspec-mocks (~> 3.10.0)
82
+ rspec-core (3.10.0)
83
+ rspec-support (~> 3.10.0)
84
+ rspec-expectations (3.10.0)
85
+ diff-lcs (>= 1.2.0, < 2.0)
86
+ rspec-support (~> 3.10.0)
87
+ rspec-mocks (3.10.0)
88
+ diff-lcs (>= 1.2.0, < 2.0)
89
+ rspec-support (~> 3.10.0)
90
+ rspec-support (3.10.0)
91
+ rubocop (1.3.1)
92
+ parallel (~> 1.10)
93
+ parser (>= 2.7.1.5)
94
+ rainbow (>= 2.2.2, < 4.0)
95
+ regexp_parser (>= 1.8)
96
+ rexml
97
+ rubocop-ast (>= 1.1.1)
98
+ ruby-progressbar (~> 1.7)
99
+ unicode-display_width (>= 1.4.0, < 2.0)
100
+ rubocop-ast (1.1.1)
101
+ parser (>= 2.7.1.5)
102
+ ruby-progressbar (1.10.1)
103
+ rubyzip (2.3.0)
104
+ slow_enumerator_tools (1.1.0)
105
+ tomlrb (1.3.0)
106
+ tty-color (0.6.0)
107
+ tty-command (0.10.0)
108
+ pastel (~> 0.8)
109
+ tty-platform (0.3.0)
110
+ tty-which (0.4.2)
111
+ unicode-display_width (1.7.0)
112
+ yard (0.9.25)
113
+ zeitwerk (2.4.1)
114
+
115
+ PLATFORMS
116
+ ruby
117
+
118
+ DEPENDENCIES
119
+ kramdown
120
+ rake (~> 12.0)
121
+ rspec (~> 3.0)
122
+ rubocop
123
+ polites!
124
+ polites-nanoc!
125
+ yard
126
+
127
+ BUNDLED WITH
128
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Arjan van der Gaag
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.
@@ -0,0 +1,70 @@
1
+ # Polites
2
+
3
+ Polites allows you to work with files generated by the [Ulysses](https://ulysses.app) writing application for macos.
4
+
5
+ Most importantly, this gem allows you to take Ulysses .ulyz files as input and transform them into HTML, all from Ruby. Additionally, you can extract embedded media files from the .ulyz file.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'polites'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install polites
22
+
23
+ ## Usage
24
+
25
+ Transform a file to HTML:
26
+
27
+ ```ruby
28
+ Polites::Convert.new.call('/path/to/file.ulyz')
29
+ # => (html content)
30
+ ```
31
+
32
+ Parse a sheet:
33
+
34
+ ```ruby
35
+ Polites::File.open('/path/to/file.ulyz') do |f|
36
+ sheet = Polites::Parser.new.parse_sheet(f.content)
37
+ sheet.keywords # => ['Keyword1', 'Keyword2']
38
+ sheet.files # => ['1a3577ba004942ecb71d8a940cab4b1f']
39
+ Polites::HtmlFormatter.new.call(sheet)
40
+ # => (html content)
41
+ end
42
+ ```
43
+
44
+ ## Usage with Nanoc
45
+
46
+ When using [Nanoc](https://nanoc.ws) you can install `polites-nanoc` so you can use a Ulysses [external folder](https://ulysses.app/tutorials/external-folders) as a Nanoc data source.
47
+
48
+ ```ruby
49
+ gem 'polites-nanoc'
50
+ ```
51
+
52
+ Refer to the API docs for `Polites::Nanoc` for more information.
53
+
54
+ ## Development
55
+
56
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
57
+
58
+ 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).
59
+
60
+ ## Contributing
61
+
62
+ Bug reports and pull requests are welcome on GitHub at https://github.com/avdgaag/polites. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/avdgaag/polites/blob/master/CODE_OF_CONDUCT.md).
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
67
+
68
+ ## Code of Conduct
69
+
70
+ Everyone interacting in the Polites project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/avdgaag/polites/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ Bundler::GemHelper.install_tasks name: 'polites'
4
+ Bundler::GemHelper.install_tasks name: 'polites-nanoc'
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'polites'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
5
+ require 'polites'
6
+ require 'polites/cli'
7
+
8
+ Polites::Cli.new(stdin: $stdin, stdout: $stdout).call(ARGV)
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'polites/version'
4
+
5
+ # Polites allows you to work with files generated by the
6
+ # [Ulysses](https://ulysses.app) writing application for macos.
7
+ #
8
+ # Most importantly, this gem allows you to take Ulysses .ulyz files as input and
9
+ # transform them into HTML, all from Ruby. Additionally, you can extract
10
+ # embedded media files from the .ulyz file.
11
+ #
12
+ # @example Transform a file to HTML
13
+ # Polites::Convert.new.call('/path/to/file.ulyz')
14
+ # # => (html content)
15
+ # @example Parse a sheet
16
+ # Polites::File.open('/path/to/file.ulyz') do |f|
17
+ # sheet = Polites::Parser.new.parse_sheet(f.content)
18
+ # sheet.keywords # => ['Keyword1', 'Keyword2']
19
+ # sheet.files # => ['1a3577ba004942ecb71d8a940cab4b1f']
20
+ # Polites::HtmlFormatter.new.call(sheet)
21
+ # # => (html content)
22
+ # end
23
+ module Polites
24
+ # Generic error all Polites-specific errors inherit from.
25
+ class Error < StandardError; end
26
+
27
+ # Raised when encountering an error during parsing of source files.
28
+ class ParseError < Error; end
29
+
30
+ # Raised when encountering an error during the formatting of our internal AST
31
+ # into some target output.
32
+ class FormattingError < Error; end
33
+ end