augury 1.0.3 → 1.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +13 -13
- data/README.md +63 -0
- data/augury.gemspec +1 -1
- data/lib/augury/cli.rb +14 -6
- data/lib/augury/exception.rb +6 -0
- data/lib/augury/fortune.rb +33 -2
- data/lib/augury/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5bfe458d2f8431e98c03bef3fd02e3110cc0a3be14523a468dca050f3ea1c478
|
|
4
|
+
data.tar.gz: d758020f0f3281a559a48237fe17edf9a9600c7d7072a11c5597ae038fd7b07c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b756e409e7d664fe41e85394979f126ae43c623e7b98a8e1c214916fa18860664f1431a485fa8d210798eccf2165b944cc646d577ff76c00a77513f2ef146834
|
|
7
|
+
data.tar.gz: 79250c0549f60c415bdf476f16faf41bccc3f8dd05f97f44b1bbd9aab25508e0beff1e51bb3cebbf71a228cc767ed884f4f66b618a25e15c4dcfc4f44d530ac2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 1.1.0 (2020-01-24)
|
|
4
|
+
|
|
5
|
+
- Add ability to transform tweet text with find / replace
|
|
6
|
+
- Get full text of tweets, not the default abbreviated version
|
|
7
|
+
- Switch to better word wrapping library
|
|
8
|
+
|
|
3
9
|
## 1.0.3 (2020-01-23)
|
|
4
10
|
|
|
5
11
|
- Pin Thor version to avoid issue with `options` override
|
data/Gemfile.lock
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
augury (1.0
|
|
5
|
-
facets (~> 3.0)
|
|
4
|
+
augury (1.1.0)
|
|
6
5
|
thor (~> 1.0.0)
|
|
7
6
|
twitter (~> 7.0)
|
|
7
|
+
word_wrap (~> 1.0)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
12
|
addressable (2.7.0)
|
|
13
13
|
public_suffix (>= 2.0.2, < 5.0)
|
|
14
|
-
ast (2.4.
|
|
14
|
+
ast (2.4.2)
|
|
15
15
|
awesome_print (1.8.0)
|
|
16
16
|
backport (1.1.2)
|
|
17
17
|
benchmark (0.1.1)
|
|
@@ -21,12 +21,11 @@ GEM
|
|
|
21
21
|
crack (0.4.5)
|
|
22
22
|
rexml
|
|
23
23
|
diff-lcs (1.4.4)
|
|
24
|
-
docile (1.3.
|
|
24
|
+
docile (1.3.5)
|
|
25
25
|
domain_name (0.5.20190701)
|
|
26
26
|
unf (>= 0.0.5, < 1.0.0)
|
|
27
27
|
e2mmap (0.1.0)
|
|
28
28
|
equalizer (0.0.11)
|
|
29
|
-
facets (3.1.0)
|
|
30
29
|
ffi (1.14.2)
|
|
31
30
|
ffi-compiler (1.0.1)
|
|
32
31
|
ffi (>= 1.0.0)
|
|
@@ -40,8 +39,8 @@ GEM
|
|
|
40
39
|
http-cookie (1.0.3)
|
|
41
40
|
domain_name (~> 0.5)
|
|
42
41
|
http-form_data (2.3.0)
|
|
43
|
-
http-parser (1.2.
|
|
44
|
-
ffi-compiler
|
|
42
|
+
http-parser (1.2.3)
|
|
43
|
+
ffi-compiler (>= 1.0, < 2.0)
|
|
45
44
|
http_parser.rb (0.6.0)
|
|
46
45
|
jaro_winkler (1.5.4)
|
|
47
46
|
kramdown (2.3.0)
|
|
@@ -58,7 +57,7 @@ GEM
|
|
|
58
57
|
mini_portile2 (~> 2.5.0)
|
|
59
58
|
racc (~> 1.4)
|
|
60
59
|
parallel (1.20.1)
|
|
61
|
-
parser (
|
|
60
|
+
parser (3.0.0.0)
|
|
62
61
|
ast (~> 2.4.1)
|
|
63
62
|
pry (0.13.1)
|
|
64
63
|
coderay (~> 1.1)
|
|
@@ -102,7 +101,7 @@ GEM
|
|
|
102
101
|
rubocop-ast (>= 0.5.0)
|
|
103
102
|
ruby-progressbar (~> 1.7)
|
|
104
103
|
unicode-display_width (>= 1.4.0, < 2.0)
|
|
105
|
-
rubocop-ast (1.4.
|
|
104
|
+
rubocop-ast (1.4.1)
|
|
106
105
|
parser (>= 2.7.1.5)
|
|
107
106
|
rubocop-rake (0.5.1)
|
|
108
107
|
rubocop
|
|
@@ -111,13 +110,13 @@ GEM
|
|
|
111
110
|
rubocop-ast (>= 0.7.1)
|
|
112
111
|
ruby-progressbar (1.11.0)
|
|
113
112
|
simple_oauth (0.3.1)
|
|
114
|
-
simplecov (0.21.
|
|
113
|
+
simplecov (0.21.2)
|
|
115
114
|
docile (~> 1.1)
|
|
116
115
|
simplecov-html (~> 0.11)
|
|
117
116
|
simplecov_json_formatter (~> 0.1)
|
|
118
117
|
simplecov-html (0.12.3)
|
|
119
118
|
simplecov_json_formatter (0.1.2)
|
|
120
|
-
solargraph (0.40.
|
|
119
|
+
solargraph (0.40.2)
|
|
121
120
|
backport (~> 1.1)
|
|
122
121
|
benchmark
|
|
123
122
|
bundler (>= 1.17.2)
|
|
@@ -125,7 +124,7 @@ GEM
|
|
|
125
124
|
jaro_winkler (~> 1.5)
|
|
126
125
|
kramdown (~> 2.3)
|
|
127
126
|
kramdown-parser-gfm (~> 1.1)
|
|
128
|
-
parser (~>
|
|
127
|
+
parser (~> 3.0)
|
|
129
128
|
reverse_markdown (>= 1.0.5, < 3)
|
|
130
129
|
rubocop (>= 0.52)
|
|
131
130
|
thor (~> 1.0)
|
|
@@ -150,10 +149,11 @@ GEM
|
|
|
150
149
|
unf_ext (0.0.7.7)
|
|
151
150
|
unicode-display_width (1.7.0)
|
|
152
151
|
vcr (6.0.0)
|
|
153
|
-
webmock (3.11.
|
|
152
|
+
webmock (3.11.1)
|
|
154
153
|
addressable (>= 2.3.6)
|
|
155
154
|
crack (>= 0.3.2)
|
|
156
155
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
156
|
+
word_wrap (1.0.0)
|
|
157
157
|
yard (0.9.26)
|
|
158
158
|
|
|
159
159
|
PLATFORMS
|
data/README.md
CHANGED
|
@@ -107,7 +107,11 @@ Option | Description | Default
|
|
|
107
107
|
`retweets` | Include retweets. | `false`
|
|
108
108
|
`replies` | Include replies. | `false`
|
|
109
109
|
`links` | Include tweets with links in them. | `false`
|
|
110
|
+
`remove_links` | Remove all links from tweets before any other `transforms`. If set, this infers `links` is `true`. | `false`
|
|
110
111
|
`attribution` | Add an author attribution to each fortune. | `false`
|
|
112
|
+
`apply_transforms` | Apply the global and feed specific transforms. | `false`
|
|
113
|
+
`transforms` | Transformations to apply to specific user feeds. See [Transforms](#transforms) below. |
|
|
114
|
+
`global-transforms` | Transformations to apply to all feeds. Applied after `transforms` See [Transforms](#transforms) below. |
|
|
111
115
|
|
|
112
116
|
### Twitter Setup
|
|
113
117
|
|
|
@@ -126,6 +130,65 @@ twitter:
|
|
|
126
130
|
access_token_secret: YOUR_ACCESS_TOKEN_SECRET
|
|
127
131
|
```
|
|
128
132
|
|
|
133
|
+
### Transforms
|
|
134
|
+
|
|
135
|
+
Global substitutions can be made using regular expressions.
|
|
136
|
+
Each transform is a pattern and replacement.
|
|
137
|
+
For instance, if you wanted to replace all `Hello`'s with `Hello world`, you could add the following:
|
|
138
|
+
|
|
139
|
+
```yaml
|
|
140
|
+
global-transforms:
|
|
141
|
+
-
|
|
142
|
+
- !ruby/regexp /(hello)/i
|
|
143
|
+
- "\\1 world"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Global transforms are applied after all other `transforms`.
|
|
147
|
+
Word wrapping is applied after the transforms have been applied.
|
|
148
|
+
|
|
149
|
+
#### Feed specific
|
|
150
|
+
|
|
151
|
+
Transforms can also be defined per user feed.
|
|
152
|
+
If you wanted to do the same as the global above, but only for `seinfeldtoday`, then add the following:
|
|
153
|
+
|
|
154
|
+
```yaml
|
|
155
|
+
transforms:
|
|
156
|
+
seinfeldtoday:
|
|
157
|
+
-
|
|
158
|
+
- !ruby/regexp /(hello)/i
|
|
159
|
+
- "\\1 world"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Or a more interesting example using the example earlier for `seinfeldtoday`:
|
|
163
|
+
|
|
164
|
+
```text
|
|
165
|
+
Elaine has no idea what her BF does for a living and it's now too
|
|
166
|
+
late to ask. E:"Teacher, I think. Or a doctor? Wait Is
|
|
167
|
+
'computers' a job?"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Then add the following to make this a bit more readable:
|
|
171
|
+
|
|
172
|
+
```yaml
|
|
173
|
+
transforms:
|
|
174
|
+
seinfeldtoday:
|
|
175
|
+
-
|
|
176
|
+
- !ruby/regexp /(E:\s*)/
|
|
177
|
+
- "\n\nElaine: "
|
|
178
|
+
-
|
|
179
|
+
- !ruby/regexp /BF/
|
|
180
|
+
- "boyfriend"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Then we end up with this:
|
|
184
|
+
|
|
185
|
+
```text
|
|
186
|
+
Elaine has no idea what her boyfriend does for a living and it's now
|
|
187
|
+
too late to ask.
|
|
188
|
+
|
|
189
|
+
Elaine: "Teacher, I think. Or a doctor? Wait Is 'computers' a job?"
|
|
190
|
+
```
|
|
191
|
+
|
|
129
192
|
## Usage
|
|
130
193
|
|
|
131
194
|
Create a fortune for the latest *seinfeldtoday* tweets.
|
data/augury.gemspec
CHANGED
data/lib/augury/cli.rb
CHANGED
|
@@ -16,7 +16,7 @@ module Augury
|
|
|
16
16
|
option :append,
|
|
17
17
|
type: :boolean,
|
|
18
18
|
aliases: '-a',
|
|
19
|
-
desc: 'If set, the target path will be appended to instead of overwritten'
|
|
19
|
+
desc: 'If set, the target path will be appended to instead of overwritten. DEFAULT: false'
|
|
20
20
|
|
|
21
21
|
option :count,
|
|
22
22
|
type: :numeric,
|
|
@@ -38,11 +38,21 @@ module Augury
|
|
|
38
38
|
aliases: '-l',
|
|
39
39
|
desc: 'Include tweets with links in them. DEFAULT: false'
|
|
40
40
|
|
|
41
|
+
option :remove_links,
|
|
42
|
+
type: :boolean,
|
|
43
|
+
aliases: '--remove-links',
|
|
44
|
+
desc: 'Remove links from tweets. DEFAULT: false'
|
|
45
|
+
|
|
41
46
|
option :attribution,
|
|
42
47
|
type: :boolean,
|
|
43
48
|
aliases: '-A',
|
|
44
49
|
desc: 'Add an author attribution to each fortune. DEFAULT: false'
|
|
45
50
|
|
|
51
|
+
option :apply_transforms,
|
|
52
|
+
type: :boolean,
|
|
53
|
+
aliases: '-t',
|
|
54
|
+
desc: 'Apply transforms from config file. DEFAULT: false'
|
|
55
|
+
|
|
46
56
|
def generate(username, *path)
|
|
47
57
|
path = File.expand_path(path[0] || username)
|
|
48
58
|
augury = Augury::Fortune.new(username, path, options)
|
|
@@ -63,12 +73,7 @@ module Augury
|
|
|
63
73
|
defaults = Thor::CoreExt::HashWithIndifferentAccess.new(
|
|
64
74
|
{
|
|
65
75
|
width: 72,
|
|
66
|
-
append: false,
|
|
67
76
|
count: 200,
|
|
68
|
-
retweets: false,
|
|
69
|
-
replies: false,
|
|
70
|
-
links: false,
|
|
71
|
-
attribution: false,
|
|
72
77
|
},
|
|
73
78
|
)
|
|
74
79
|
|
|
@@ -78,6 +83,9 @@ module Augury
|
|
|
78
83
|
defaults = defaults.merge(config_options)
|
|
79
84
|
end
|
|
80
85
|
|
|
86
|
+
# Enforce implied options
|
|
87
|
+
defaults[:links] = true if original_options[:remove_links] || defaults[:remove_links]
|
|
88
|
+
|
|
81
89
|
Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
|
|
82
90
|
end
|
|
83
91
|
end
|
data/lib/augury/exception.rb
CHANGED
data/lib/augury/fortune.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'cgi'
|
|
4
|
-
require '
|
|
4
|
+
require 'word_wrap'
|
|
5
5
|
require 'twitter'
|
|
6
6
|
|
|
7
7
|
module Augury
|
|
@@ -30,6 +30,7 @@ module Augury
|
|
|
30
30
|
@tweets = collect_with_max_id do |max_id|
|
|
31
31
|
options = {
|
|
32
32
|
count: 200,
|
|
33
|
+
tweet_mode: 'extended',
|
|
33
34
|
include_rts: @config[:retweets],
|
|
34
35
|
exclude_replies: !@config[:replies],
|
|
35
36
|
}
|
|
@@ -46,7 +47,14 @@ module Augury
|
|
|
46
47
|
filtered = @tweets.flat_map(&:full_text).reject do |tweet|
|
|
47
48
|
tweet.match(/https?:/) unless @config[:links]
|
|
48
49
|
end
|
|
49
|
-
|
|
50
|
+
to_transform = transforms
|
|
51
|
+
formatted = filtered.flat_map do |tweet|
|
|
52
|
+
text = CGI.unescapeHTML(tweet)
|
|
53
|
+
to_transform.each do |transform|
|
|
54
|
+
text.gsub!(transform[0], transform[1])
|
|
55
|
+
end
|
|
56
|
+
WordWrap.ww text, @config.fetch(:width, 72)
|
|
57
|
+
end
|
|
50
58
|
author = @config[:attribution] ? "\n-- #{@twitter.user(@username).name}\n" : ''
|
|
51
59
|
formatted.join("#{author}%\n")
|
|
52
60
|
end
|
|
@@ -75,5 +83,28 @@ module Augury
|
|
|
75
83
|
cfg.access_token_secret = @config[:twitter]['access_token_secret']
|
|
76
84
|
end
|
|
77
85
|
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
|
|
89
|
+
def transforms
|
|
90
|
+
all_transforms = []
|
|
91
|
+
all_transforms << [/https?:\/\/[^\s]+/, ''] if @config[:remove_links]
|
|
92
|
+
return all_transforms unless @config[:apply_transforms]
|
|
93
|
+
|
|
94
|
+
all_transforms.push(*@config.dig('transforms', @username) || [])
|
|
95
|
+
all_transforms.push(*@config.fetch('global-transforms', []))
|
|
96
|
+
|
|
97
|
+
raise Augury::TransformError unless validate_transforms(all_transforms)
|
|
98
|
+
|
|
99
|
+
all_transforms
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def validate_transforms(all_transforms)
|
|
103
|
+
all_transforms.all? do |transform|
|
|
104
|
+
transform.count == 2 &&
|
|
105
|
+
[String, Regexp].include?(transform[0].class) &&
|
|
106
|
+
transform[1].is_a?(String)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
78
109
|
end
|
|
79
110
|
end
|
data/lib/augury/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: augury
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Clayton Parker
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-01-
|
|
11
|
+
date: 2021-01-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -39,19 +39,19 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '7.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: word_wrap
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
47
|
+
version: '1.0'
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
54
|
+
version: '1.0'
|
|
55
55
|
description: This gem turns a twitter feed into a fortune file that you can use with
|
|
56
56
|
the fortune program
|
|
57
57
|
email:
|