doing 1.0.66 → 1.0.67
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 +4 -4
- data/README.md +1 -1
- data/lib/doing/helpers.rb +120 -0
- data/lib/doing/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2adffea75d109f047bd36b1ce55c48b83bc61a5d05d2060ece89fc8041faaabd
|
|
4
|
+
data.tar.gz: 546e1c04bf9f0b319905e21a0aadb4ce9afb2eee8c49b7e8bc551d589d4f75d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34db37e7c5974f97bad9516970bccb8d1a3b28bd0eefec7fbbf57628137cd763fc5f5473c85cee05334088f64d8a7f8621d1bd6f41fc694ad4534569e3360313
|
|
7
|
+
data.tar.gz: 510d4f38fbe89ba480aedf9f8845c99f33c7265c1f852be76151f75aed6e10fee49e9912e1b1161f6ebbd5b7b98889663e289136fe9e63828b71544c0b1fcd7c
|
data/README.md
CHANGED
|
@@ -29,7 +29,7 @@ _Side note:_ I actually use the library behind this utility as part of another s
|
|
|
29
29
|
|
|
30
30
|
## Installation
|
|
31
31
|
|
|
32
|
-
The current version of `doing` is <!--VER-->1.0.
|
|
32
|
+
The current version of `doing` is <!--VER-->1.0.66<!--END VER-->.
|
|
33
33
|
|
|
34
34
|
$ [sudo] gem install doing
|
|
35
35
|
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
##
|
|
2
|
+
## @brief Hash helpers
|
|
3
|
+
##
|
|
4
|
+
class ::Hash
|
|
5
|
+
def has_tags?(tags, bool = :and)
|
|
6
|
+
tags = tags.split(/ *, */) if tags.is_a? String
|
|
7
|
+
bool = bool.normalize_bool if bool.is_a? String
|
|
8
|
+
item = self
|
|
9
|
+
case bool
|
|
10
|
+
when :and
|
|
11
|
+
result = true
|
|
12
|
+
tags.each do |tag|
|
|
13
|
+
unless item['title'] =~ /@#{tag}/
|
|
14
|
+
result = false
|
|
15
|
+
break
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
result
|
|
19
|
+
when :not
|
|
20
|
+
result = true
|
|
21
|
+
tags.each do |tag|
|
|
22
|
+
if item['title'] =~ /@#{tag}/
|
|
23
|
+
result = false
|
|
24
|
+
break
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
result
|
|
28
|
+
else
|
|
29
|
+
result = false
|
|
30
|
+
tags.each do |tag|
|
|
31
|
+
if item['title'] =~ /@#{tag}/
|
|
32
|
+
result = true
|
|
33
|
+
break
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
result
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def matches_search?(search)
|
|
41
|
+
item = self
|
|
42
|
+
text = item['note'] ? item['title'] + item['note'].join(' ') : item['title']
|
|
43
|
+
pattern = if search.strip =~ %r{^/.*?/$}
|
|
44
|
+
search.sub(%r{/(.*?)/}, '\1')
|
|
45
|
+
else
|
|
46
|
+
search.split('').join('.{0,3}')
|
|
47
|
+
end
|
|
48
|
+
text =~ /#{pattern}/i ? true : false
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
##
|
|
53
|
+
## @brief String helpers
|
|
54
|
+
##
|
|
55
|
+
class ::String
|
|
56
|
+
def cap_first
|
|
57
|
+
sub(/^\w/) do |m|
|
|
58
|
+
m.upcase
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
##
|
|
64
|
+
## @brief Convert a boolean string to a symbol
|
|
65
|
+
##
|
|
66
|
+
## @return Symbol :and, :or, or :not
|
|
67
|
+
##
|
|
68
|
+
def normalize_bool!
|
|
69
|
+
replace normalize_bool
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def normalize_bool(default = :and)
|
|
73
|
+
case self
|
|
74
|
+
when /(and|all)/i
|
|
75
|
+
:and
|
|
76
|
+
when /(any|or)/i
|
|
77
|
+
:or
|
|
78
|
+
when /(not|none)/i
|
|
79
|
+
:not
|
|
80
|
+
else
|
|
81
|
+
default.is_a?(Symbol) ? default : default.normalize_bool
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
##
|
|
87
|
+
## @brief Turn raw urls into HTML links
|
|
88
|
+
##
|
|
89
|
+
## @param opt (Hash) Additional Options
|
|
90
|
+
##
|
|
91
|
+
def link_urls(opt = {})
|
|
92
|
+
opt[:format] ||= :html
|
|
93
|
+
if opt[:format] == :html
|
|
94
|
+
gsub(%r{(?mi)((http|https)://)?([\w\-_]+(\.[\w\-_]+)+)([\w\-.,@?^=%&:/~+#]*[\w\-@^=%&/~+#])?}) do |_match|
|
|
95
|
+
m = Regexp.last_match
|
|
96
|
+
proto = m[1].nil? ? 'http://' : ''
|
|
97
|
+
%(<a href="#{proto}#{m[0]}" title="Link to #{m[0]}">[#{m[3]}]</a>)
|
|
98
|
+
end.gsub(/<(\w+:.*?)>/) do |match|
|
|
99
|
+
m = Regexp.last_match
|
|
100
|
+
if m[1] =~ /<a href/
|
|
101
|
+
match
|
|
102
|
+
else
|
|
103
|
+
%(<a href="#{m[1]}" title="Link to #{m[1]}">[link]</a>)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
else
|
|
107
|
+
self
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
class ::Symbol
|
|
113
|
+
def normalize_bool!
|
|
114
|
+
replace normalize_bool
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def normalize_bool
|
|
118
|
+
to_s.normalize_bool
|
|
119
|
+
end
|
|
120
|
+
end
|
data/lib/doing/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: doing
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.67
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brett Terpstra
|
|
@@ -165,6 +165,7 @@ files:
|
|
|
165
165
|
- README.md
|
|
166
166
|
- bin/doing
|
|
167
167
|
- lib/doing.rb
|
|
168
|
+
- lib/doing/helpers.rb
|
|
168
169
|
- lib/doing/version.rb
|
|
169
170
|
- lib/doing/wwid.rb
|
|
170
171
|
- lib/templates/doing.css
|