slacken 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.md +60 -0
  7. data/Rakefile +36 -0
  8. data/lib/slacken.rb +21 -0
  9. data/lib/slacken/document_component.rb +73 -0
  10. data/lib/slacken/document_component/elim_blanks.rb +36 -0
  11. data/lib/slacken/document_component/elim_invalid_links.rb +26 -0
  12. data/lib/slacken/document_component/elim_line_breaks.rb +27 -0
  13. data/lib/slacken/document_component/extract_img_alt.rb +12 -0
  14. data/lib/slacken/document_component/group_indent.rb +27 -0
  15. data/lib/slacken/document_component/group_inlines.rb +26 -0
  16. data/lib/slacken/document_component/sanitize_link_containers.rb +40 -0
  17. data/lib/slacken/document_component/sanitize_special_tag_containers.rb +102 -0
  18. data/lib/slacken/document_component/stringfy_checkbox.rb +20 -0
  19. data/lib/slacken/document_component/stringfy_emoji.rb +20 -0
  20. data/lib/slacken/dom_container.rb +45 -0
  21. data/lib/slacken/node_type.rb +53 -0
  22. data/lib/slacken/render_element.rb +91 -0
  23. data/lib/slacken/rendering.rb +102 -0
  24. data/lib/slacken/slack_url.rb +7 -0
  25. data/lib/slacken/table_element.rb +23 -0
  26. data/lib/slacken/version.rb +3 -0
  27. data/sample/out.txt +38 -0
  28. data/sample/source.html +55 -0
  29. data/scripts/update_markup_fixture.rb +8 -0
  30. data/slacken.gemspec +28 -0
  31. data/spec/fixtures/example.html +114 -0
  32. data/spec/fixtures/markup_text.txt +73 -0
  33. data/spec/helpers/document_component_dsl.rb +11 -0
  34. data/spec/slacken/document_component/elim_blanks_spec.rb +34 -0
  35. data/spec/slacken/document_component/elim_invalid_links_spec.rb +49 -0
  36. data/spec/slacken/document_component/elim_line_breaks_spec.rb +41 -0
  37. data/spec/slacken/document_component/group_indent_spec.rb +37 -0
  38. data/spec/slacken/document_component/group_inlines_spec.rb +33 -0
  39. data/spec/slacken/document_component/sanitize_special_tag_containers_spec.rb +64 -0
  40. data/spec/slacken/document_component_spec.rb +19 -0
  41. data/spec/slacken_spec.rb +12 -0
  42. data/spec/spec_helper.rb +13 -0
  43. metadata +194 -0
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ module Slacken
4
+ describe DocumentComponent do
5
+ describe '#normalize' do
6
+ subject { DomContainer.parse_html(source).to_component.normalize }
7
+ let(:source) { fixture('example.html') }
8
+
9
+ it { is_expected.to have_no_blanks }
10
+ it { is_expected.to have_no_invalid_links }
11
+ it { is_expected.to have_no_line_breaks }
12
+ it { is_expected.to be_indent_grouped }
13
+ it { is_expected.to be_inlines_grouped }
14
+ it { is_expected.to be_sanitized }
15
+ it { is_expected.to be_emoji_stringfied }
16
+ it { is_expected.to be_checkbox_stringfied }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Slacken do
4
+ describe '#translate' do
5
+ subject { described_class.translate(source) }
6
+ let(:source) { fixture('example.html') }
7
+
8
+ it 'translates as expected' do
9
+ expect(subject).to eq(fixture('markup_text.txt'))
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ require 'rspec'
2
+ require 'slacken'
3
+
4
+ require 'helpers/document_component_dsl'
5
+
6
+ def fixture(name)
7
+ @fixture_cache ||= {}
8
+ @fixture_cache[name] ||= File.read(File.expand_path(name, File.expand_path('fixtures', __dir__)))
9
+ end
10
+
11
+ RSpec.configure do |c|
12
+ c.include DocumentComponentDsl, dsl: true
13
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slacken
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tomoya Chiba
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.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: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubygems-tasks
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.6'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: kosi
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
111
+ description: Translate HTML sources to markup texts for slack
112
+ email: tomo.asleep@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - ".gitignore"
118
+ - ".rspec"
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - lib/slacken.rb
124
+ - lib/slacken/document_component.rb
125
+ - lib/slacken/document_component/elim_blanks.rb
126
+ - lib/slacken/document_component/elim_invalid_links.rb
127
+ - lib/slacken/document_component/elim_line_breaks.rb
128
+ - lib/slacken/document_component/extract_img_alt.rb
129
+ - lib/slacken/document_component/group_indent.rb
130
+ - lib/slacken/document_component/group_inlines.rb
131
+ - lib/slacken/document_component/sanitize_link_containers.rb
132
+ - lib/slacken/document_component/sanitize_special_tag_containers.rb
133
+ - lib/slacken/document_component/stringfy_checkbox.rb
134
+ - lib/slacken/document_component/stringfy_emoji.rb
135
+ - lib/slacken/dom_container.rb
136
+ - lib/slacken/node_type.rb
137
+ - lib/slacken/render_element.rb
138
+ - lib/slacken/rendering.rb
139
+ - lib/slacken/slack_url.rb
140
+ - lib/slacken/table_element.rb
141
+ - lib/slacken/version.rb
142
+ - sample/out.txt
143
+ - sample/source.html
144
+ - scripts/update_markup_fixture.rb
145
+ - slacken.gemspec
146
+ - spec/fixtures/example.html
147
+ - spec/fixtures/markup_text.txt
148
+ - spec/helpers/document_component_dsl.rb
149
+ - spec/slacken/document_component/elim_blanks_spec.rb
150
+ - spec/slacken/document_component/elim_invalid_links_spec.rb
151
+ - spec/slacken/document_component/elim_line_breaks_spec.rb
152
+ - spec/slacken/document_component/group_indent_spec.rb
153
+ - spec/slacken/document_component/group_inlines_spec.rb
154
+ - spec/slacken/document_component/sanitize_special_tag_containers_spec.rb
155
+ - spec/slacken/document_component_spec.rb
156
+ - spec/slacken_spec.rb
157
+ - spec/spec_helper.rb
158
+ homepage: https://rubygems.org/gems/slacken
159
+ licenses:
160
+ - MIT
161
+ metadata: {}
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ requirements: []
177
+ rubyforge_project:
178
+ rubygems_version: 2.4.5
179
+ signing_key:
180
+ specification_version: 4
181
+ summary: Translate HTML sources to markup texts for slack
182
+ test_files:
183
+ - spec/fixtures/example.html
184
+ - spec/fixtures/markup_text.txt
185
+ - spec/helpers/document_component_dsl.rb
186
+ - spec/slacken/document_component/elim_blanks_spec.rb
187
+ - spec/slacken/document_component/elim_invalid_links_spec.rb
188
+ - spec/slacken/document_component/elim_line_breaks_spec.rb
189
+ - spec/slacken/document_component/group_indent_spec.rb
190
+ - spec/slacken/document_component/group_inlines_spec.rb
191
+ - spec/slacken/document_component/sanitize_special_tag_containers_spec.rb
192
+ - spec/slacken/document_component_spec.rb
193
+ - spec/slacken_spec.rb
194
+ - spec/spec_helper.rb