phrase_browser 0.1.0
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -0
- data/lib/phrase_browser.rb +76 -0
- metadata +70 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9d0edcd2d312500aec57e837321e7f0465aa7074c2f82e0b13d7f01dd71b4708
|
4
|
+
data.tar.gz: 578ef052cbebd0228a3eb3ec10afd08749e6310b5cc34748a5b4603b518b2be4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f371019bc9ad688eaf87cab8c17951961193bd100c059691d87ed1b4c7138c838891b97fc7a5629f535221cbfa5d9e112817c63ba14075f61458f24a233a351a
|
7
|
+
data.tar.gz: 119fe114509b6ba390e90e3945a2621a3e8dc48f8364697ee408a9863711370eec6b4a9b883e78eff2f35906d476dd60b05c2a4bb0c191d82117011971c1cc04
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
����Ҧ�Q��m�=�M4�����>3\K���2��P3�>N�2=' 1��a���}��ג���Gk�|��C�x�_+/ ��S��qϞӊ����ӏ:[��`����K��1��6�Һ$��G�,I��&K�����s)�s��
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: phrase_browser.rb
|
4
|
+
|
5
|
+
# description: Experimental gem to look up a phrase from a list of words
|
6
|
+
# layed out in an HTML accordion style menu.
|
7
|
+
|
8
|
+
require 'htmlcom'
|
9
|
+
require 'kramdown'
|
10
|
+
|
11
|
+
|
12
|
+
class PhraseBrowser
|
13
|
+
using ColouredText
|
14
|
+
|
15
|
+
|
16
|
+
def initialize(s, target_url: '', debug: false)
|
17
|
+
|
18
|
+
@target_url, @debug = target_url, debug
|
19
|
+
|
20
|
+
ignorewords = ["the", "of", "and", "to", "in", "a", "is", "that", "for",
|
21
|
+
"it", "as", "was", "with", "be", "by", "on", "not", "he",
|
22
|
+
"i", "this", "are", "or","his", "from", "at", "which",
|
23
|
+
"but", "have", "an", "had", "they", "you", "were",
|
24
|
+
"their", "one", "all", "we", "can", "her", "has", "there",
|
25
|
+
"been", "if", "more", "when", "will", "would", "who",
|
26
|
+
"so", "no"]
|
27
|
+
|
28
|
+
h = {}
|
29
|
+
a = s.strip.lines.each do |rawx|
|
30
|
+
|
31
|
+
x = rawx.chomp
|
32
|
+
|
33
|
+
x.downcase.split(/ +/).each do |raw_word|
|
34
|
+
|
35
|
+
word = raw_word[/\w+/]
|
36
|
+
next if ignorewords.include? word
|
37
|
+
h[word.to_sym] ||= []
|
38
|
+
h[word.to_sym] << x
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
@a = h.to_a.sort!
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_html()
|
48
|
+
|
49
|
+
doc = Rexle.new('<accordion/>')
|
50
|
+
|
51
|
+
@a.each do |word, raw_phrases|
|
52
|
+
|
53
|
+
phrases = raw_phrases.map do |x|
|
54
|
+
|
55
|
+
if block_given? then
|
56
|
+
yield(x)
|
57
|
+
else
|
58
|
+
phrase = x[/[^#]+/]
|
59
|
+
"* [%s](%s=%s)" % [phrase, @target_url, URI.encode(phrase)]
|
60
|
+
end
|
61
|
+
|
62
|
+
end.join("\n")
|
63
|
+
|
64
|
+
e = Rexle::Element.new('panel')
|
65
|
+
e.attributes[:title] = word.to_s
|
66
|
+
e.add Rexle.new(Kramdown::Document.new(phrases).to_html).root
|
67
|
+
doc.root.add e
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
puts doc.root.xml.debug if @debug
|
72
|
+
HtmlCom::Accordion.new(doc.root.xml).to_html
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phrase_browser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkxMjE4MjIwMTMzWhcN
|
15
|
+
MjAxMjE3MjIwMTMzWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCnlfnJ
|
17
|
+
MYfU8LDTpFb69Ty4DJLfYA4MueFdc5MKGUEhzAyC/raE3wScDmiOP0yPfb+fUIiI
|
18
|
+
WR2Ehjk4sfQ6kqqBwBECcXIiS72pfKiFVHZ4X0srFYL97f4LVubRdtUqQwj8uVqu
|
19
|
+
ORVyVSOiM/PPXdXPqHLl80uMfCPqRCNdAZKLhECcUZLpAMhuywmhyTmihnaDm2wZ
|
20
|
+
J9PBvyZmKLLwtXcWuRjEze+xIUexfyh79plAskvU+ew2fyfsVPNBLtvwT4R0Iwo5
|
21
|
+
MlwzO8gSdj6uroWhM8snR1brDcXsgaHN+JdN2pq+4BixfQynu7+ZWOvPw6XZ4f28
|
22
|
+
L0iaYGdaodf8G7in4el2JVN/jUQvQEAQ4x6Gu/zrc2BBAEjWTrNiXKukl+rdaWHf
|
23
|
+
osv/ehLfevrmAELqM5lSh+esoL+ZXUn059OecLHg6a7BtRvD7uquuSMxwxFJOMjq
|
24
|
+
+fqfHax/rbnVH25m6CGWIBA96CaigHtDns8NLJp6ttg/Weu5dfGOjFJerAcCAwEA
|
25
|
+
AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUMgvOJ6Ey
|
26
|
+
X7EQrfXVDIG4aUrTVqwwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
|
+
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAoSpTqA6jA7pUH75oXh4Ms9v1C1kE8nu3BrA33vMf
|
29
|
+
Au56YE1oIaWGydY6Clh+AdicoJBOFtwc/BZFPfVZLe6+T5kwgDHg0/7gZGl379aa
|
30
|
+
Mlvy0eNeZ5yAk7lVSoc45ePGKoXrqL5LA4l4wmIz2W0KscOfQsl9AGDa+g2daLID
|
31
|
+
zEWZC+z9u/sBzbiXltThbTWZzqyr3wwVlb11Zi/1s+MSBnDo05wpUl5f9pvDyu/u
|
32
|
+
6p7b73QqEQKTt+cCSzLsZzJwEU4XYqxSXSF6eTsjwpUPPNEmWB1lKJwFNxgKly5o
|
33
|
+
kfNeA2+NvznQz5/tnROiAlaak/jipEHd5+2rvtq9GpGxp0VoU7ACQZymARjxU8Go
|
34
|
+
jQtPRNO6cmUrHaIwQ/Oqk08OA0kmobakmXVjTXoXYpGBRxFjOyjzjMZFEoVarBr1
|
35
|
+
d/LgGxKFEyi3xKzrGvvtG0hROh5EU7qEpE1Nw4gePi+X6+KwdZOkNRczQLk6valg
|
36
|
+
1btYwB1GMozwTbXpS7qZL3HB
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2019-12-18 00:00:00.000000000 Z
|
39
|
+
dependencies: []
|
40
|
+
description:
|
41
|
+
email: james@jamesrobertson.eu
|
42
|
+
executables: []
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files: []
|
45
|
+
files:
|
46
|
+
- lib/phrase_browser.rb
|
47
|
+
homepage: https://github.com/jrobertson/phrase_browser
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
metadata: {}
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubygems_version: 3.0.3
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: phrase_browser
|
70
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|