augury 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +0 -3
- data/.gitignore +58 -8
- data/.rbenv-gemsets +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +25 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +18 -15
- data/README.md +82 -5
- data/augury.gemspec +2 -3
- data/bin/console +12 -0
- data/bin/extract_creds +12 -0
- data/bin/setup +5 -0
- data/lib/augury/cli.rb +21 -7
- data/lib/augury/exception.rb +6 -0
- data/lib/augury/fortune.rb +41 -8
- data/lib/augury/version.rb +1 -1
- metadata +14 -25
- data/TODO.md +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c20cb6d68923a886d955dc7f94305b9f59acb06991e96112170b933c4dbf56ae
|
4
|
+
data.tar.gz: 29a140a75cb40148ac27955ccfb489e322f79a54e9f735933e67dc0f291588b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81038a2cd623f5a7ba2ba9e38bcceb104b301a90276e71f4eaa2a37152f49ffa45cae9d01e83a0ec1142401d1a006cb4cca348efe3c2ace6d2c57bd99555b0b2
|
7
|
+
data.tar.gz: 24ddd1018b9ff51169a2c8dd6d76e43623e84fac2a19a3161ee96b1947829967c586c46b41fac222aa8befa7a22d3d280da5645ffd05f898f75cf3ca7d8b2abc
|
data/.codeclimate.yml
CHANGED
data/.gitignore
CHANGED
@@ -1,13 +1,63 @@
|
|
1
|
-
|
2
|
-
/
|
3
|
-
|
4
|
-
|
1
|
+
# gem sets
|
2
|
+
/gems/
|
3
|
+
|
4
|
+
# rspec failure tracking
|
5
|
+
.rspec_status
|
6
|
+
|
7
|
+
# Ruby.gitignore
|
8
|
+
*.gem
|
9
|
+
*.rbc
|
10
|
+
/.config
|
5
11
|
/coverage/
|
6
|
-
/
|
12
|
+
/InstalledFiles
|
7
13
|
/pkg/
|
8
14
|
/spec/reports/
|
15
|
+
/spec/examples.txt
|
16
|
+
/test/tmp/
|
17
|
+
/test/version_tmp/
|
9
18
|
/tmp/
|
10
|
-
/bin/*
|
11
19
|
|
12
|
-
#
|
13
|
-
.
|
20
|
+
# Used by dotenv library to load environment variables.
|
21
|
+
# .env
|
22
|
+
|
23
|
+
# Ignore Byebug command history file.
|
24
|
+
.byebug_history
|
25
|
+
|
26
|
+
## Specific to RubyMotion:
|
27
|
+
.dat*
|
28
|
+
.repl_history
|
29
|
+
build/
|
30
|
+
*.bridgesupport
|
31
|
+
build-iPhoneOS/
|
32
|
+
build-iPhoneSimulator/
|
33
|
+
|
34
|
+
## Specific to RubyMotion (use of CocoaPods):
|
35
|
+
#
|
36
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
37
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
38
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
39
|
+
#
|
40
|
+
# vendor/Pods/
|
41
|
+
|
42
|
+
## Documentation cache and generated files:
|
43
|
+
/.yardoc/
|
44
|
+
/_yardoc/
|
45
|
+
/doc/
|
46
|
+
/rdoc/
|
47
|
+
|
48
|
+
## Environment normalization:
|
49
|
+
/.bundle/
|
50
|
+
/vendor/bundle
|
51
|
+
/lib/bundler/man/
|
52
|
+
|
53
|
+
# for a library or gem, you might want to ignore these files since the code is
|
54
|
+
# intended to run in multiple environments; otherwise, check them in:
|
55
|
+
# Gemfile.lock
|
56
|
+
# .ruby-version
|
57
|
+
# .ruby-gemset
|
58
|
+
|
59
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
60
|
+
.rvmrc
|
61
|
+
|
62
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
63
|
+
# .rubocop-https?--*
|
data/.rbenv-gemsets
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
./gems
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
augury
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 1.1.1 (2020-02-13)
|
4
|
+
|
5
|
+
- Fix attribution on last item
|
6
|
+
- More test coverage for formatting
|
7
|
+
- Add hidden debug option
|
8
|
+
|
9
|
+
## 1.1.0 (2020-01-24)
|
10
|
+
|
11
|
+
- Add ability to transform tweet text with find / replace
|
12
|
+
- Get full text of tweets, not the default abbreviated version
|
13
|
+
- Switch to better word wrapping library
|
14
|
+
|
15
|
+
## 1.0.3 (2020-01-23)
|
16
|
+
|
17
|
+
- Pin Thor version to avoid issue with `options` override
|
18
|
+
- Add tests for `Augury::CLI`
|
19
|
+
|
20
|
+
## 1.0.2 (2020-01-09)
|
21
|
+
|
22
|
+
- Fix bug with specific tweet count retrieval
|
23
|
+
|
24
|
+
## 1.0.1 (2020-01-08)
|
25
|
+
|
26
|
+
- Remove unused gem
|
27
|
+
|
3
28
|
## 1.0.0 (2020-01-08)
|
4
29
|
|
5
30
|
- Convert augury config from ini style to yaml (breaking change)
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
augury (1.
|
5
|
-
|
6
|
-
facets (~> 3.0)
|
7
|
-
thor (~> 1.0)
|
4
|
+
augury (1.1.0)
|
5
|
+
thor (~> 1.0.0)
|
8
6
|
twitter (~> 7.0)
|
7
|
+
word_wrap (~> 1.0)
|
9
8
|
|
10
9
|
GEM
|
11
10
|
remote: https://rubygems.org/
|
12
11
|
specs:
|
13
12
|
addressable (2.7.0)
|
14
13
|
public_suffix (>= 2.0.2, < 5.0)
|
15
|
-
ast (2.4.
|
14
|
+
ast (2.4.2)
|
16
15
|
awesome_print (1.8.0)
|
17
16
|
backport (1.1.2)
|
18
17
|
benchmark (0.1.1)
|
@@ -22,12 +21,11 @@ GEM
|
|
22
21
|
crack (0.4.5)
|
23
22
|
rexml
|
24
23
|
diff-lcs (1.4.4)
|
25
|
-
docile (1.3.
|
24
|
+
docile (1.3.5)
|
26
25
|
domain_name (0.5.20190701)
|
27
26
|
unf (>= 0.0.5, < 1.0.0)
|
28
27
|
e2mmap (0.1.0)
|
29
28
|
equalizer (0.0.11)
|
30
|
-
facets (3.1.0)
|
31
29
|
ffi (1.14.2)
|
32
30
|
ffi-compiler (1.0.1)
|
33
31
|
ffi (>= 1.0.0)
|
@@ -41,8 +39,8 @@ GEM
|
|
41
39
|
http-cookie (1.0.3)
|
42
40
|
domain_name (~> 0.5)
|
43
41
|
http-form_data (2.3.0)
|
44
|
-
http-parser (1.2.
|
45
|
-
ffi-compiler
|
42
|
+
http-parser (1.2.3)
|
43
|
+
ffi-compiler (>= 1.0, < 2.0)
|
46
44
|
http_parser.rb (0.6.0)
|
47
45
|
jaro_winkler (1.5.4)
|
48
46
|
kramdown (2.3.0)
|
@@ -59,7 +57,7 @@ GEM
|
|
59
57
|
mini_portile2 (~> 2.5.0)
|
60
58
|
racc (~> 1.4)
|
61
59
|
parallel (1.20.1)
|
62
|
-
parser (
|
60
|
+
parser (3.0.0.0)
|
63
61
|
ast (~> 2.4.1)
|
64
62
|
pry (0.13.1)
|
65
63
|
coderay (~> 1.1)
|
@@ -70,6 +68,9 @@ GEM
|
|
70
68
|
pry-byebug (3.9.0)
|
71
69
|
byebug (~> 11.0)
|
72
70
|
pry (~> 0.13.0)
|
71
|
+
pry-doc (1.1.0)
|
72
|
+
pry (~> 0.11)
|
73
|
+
yard (~> 0.9.11)
|
73
74
|
public_suffix (4.0.6)
|
74
75
|
racc (1.5.2)
|
75
76
|
rainbow (3.0.0)
|
@@ -100,7 +101,7 @@ GEM
|
|
100
101
|
rubocop-ast (>= 0.5.0)
|
101
102
|
ruby-progressbar (~> 1.7)
|
102
103
|
unicode-display_width (>= 1.4.0, < 2.0)
|
103
|
-
rubocop-ast (1.4.
|
104
|
+
rubocop-ast (1.4.1)
|
104
105
|
parser (>= 2.7.1.5)
|
105
106
|
rubocop-rake (0.5.1)
|
106
107
|
rubocop
|
@@ -109,13 +110,13 @@ GEM
|
|
109
110
|
rubocop-ast (>= 0.7.1)
|
110
111
|
ruby-progressbar (1.11.0)
|
111
112
|
simple_oauth (0.3.1)
|
112
|
-
simplecov (0.21.
|
113
|
+
simplecov (0.21.2)
|
113
114
|
docile (~> 1.1)
|
114
115
|
simplecov-html (~> 0.11)
|
115
116
|
simplecov_json_formatter (~> 0.1)
|
116
117
|
simplecov-html (0.12.3)
|
117
118
|
simplecov_json_formatter (0.1.2)
|
118
|
-
solargraph (0.40.
|
119
|
+
solargraph (0.40.2)
|
119
120
|
backport (~> 1.1)
|
120
121
|
benchmark
|
121
122
|
bundler (>= 1.17.2)
|
@@ -123,7 +124,7 @@ GEM
|
|
123
124
|
jaro_winkler (~> 1.5)
|
124
125
|
kramdown (~> 2.3)
|
125
126
|
kramdown-parser-gfm (~> 1.1)
|
126
|
-
parser (~>
|
127
|
+
parser (~> 3.0)
|
127
128
|
reverse_markdown (>= 1.0.5, < 3)
|
128
129
|
rubocop (>= 0.52)
|
129
130
|
thor (~> 1.0)
|
@@ -148,10 +149,11 @@ GEM
|
|
148
149
|
unf_ext (0.0.7.7)
|
149
150
|
unicode-display_width (1.7.0)
|
150
151
|
vcr (6.0.0)
|
151
|
-
webmock (3.11.
|
152
|
+
webmock (3.11.1)
|
152
153
|
addressable (>= 2.3.6)
|
153
154
|
crack (>= 0.3.2)
|
154
155
|
hashdiff (>= 0.4.0, < 2.0.0)
|
156
|
+
word_wrap (1.0.0)
|
155
157
|
yard (0.9.26)
|
156
158
|
|
157
159
|
PLATFORMS
|
@@ -162,6 +164,7 @@ DEPENDENCIES
|
|
162
164
|
pry
|
163
165
|
pry-awesome_print
|
164
166
|
pry-byebug
|
167
|
+
pry-doc
|
165
168
|
rake
|
166
169
|
rspec (~> 3.0)
|
167
170
|
rubocop (= 0.92)
|
data/README.md
CHANGED
@@ -81,14 +81,14 @@ $ brew install fortune
|
|
81
81
|
|
82
82
|
### Augury Config
|
83
83
|
|
84
|
-
Create the `~/.augry.
|
84
|
+
Create the `~/.augry.yml` file and then set the permissions since your Twitter API info will be in there.
|
85
85
|
|
86
86
|
```sh
|
87
|
-
$ touch ~/.augury.
|
88
|
-
$ chmod 600 ~/.augury.
|
87
|
+
$ touch ~/.augury.yml
|
88
|
+
$ chmod 600 ~/.augury.yml
|
89
89
|
```
|
90
90
|
|
91
|
-
Set any of
|
91
|
+
Set any of the available settings in the config like this:
|
92
92
|
|
93
93
|
```yaml
|
94
94
|
count: 20
|
@@ -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.
|
@@ -201,7 +264,21 @@ $ bundle exec ruby exe/augury help
|
|
201
264
|
You can run the tests with the rake task:
|
202
265
|
|
203
266
|
```sh
|
204
|
-
$ bundle exec
|
267
|
+
$ bundle exec rspec
|
268
|
+
```
|
269
|
+
|
270
|
+
#### Twitter ENV
|
271
|
+
|
272
|
+
If you need to record a test with the Twitter API, you can set up the proper env vars by getting them from your currently set up `augury.yml` file.
|
273
|
+
|
274
|
+
```sh
|
275
|
+
$ eval `bin/extract_creds`
|
276
|
+
```
|
277
|
+
|
278
|
+
Then run the tests as you normally would.
|
279
|
+
|
280
|
+
```sh
|
281
|
+
$ bundle exec rspec
|
205
282
|
```
|
206
283
|
|
207
284
|
## Contributing
|
data/augury.gemspec
CHANGED
@@ -20,9 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
# Actual dependencies
|
23
|
-
spec.add_dependency 'thor', '~>1.0'
|
23
|
+
spec.add_dependency 'thor', '~>1.0.0'
|
24
24
|
spec.add_dependency 'twitter', '~>7.0'
|
25
25
|
## For the word_wrap function
|
26
|
-
spec.add_dependency '
|
27
|
-
spec.add_dependency 'facets', '~>3.0'
|
26
|
+
spec.add_dependency 'word_wrap', '~>1.0'
|
28
27
|
end
|
data/bin/console
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "augury"
|
5
|
+
# Load up the cli here as well
|
6
|
+
require "augury/cli"
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
|
11
|
+
require "pry"
|
12
|
+
Pry.start
|
data/bin/extract_creds
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
begin
|
7
|
+
augury_config = YAML.load_file(File.expand_path('~/.augury.yml'))
|
8
|
+
puts augury_config['twitter'].collect { |k, v| "export TWITTER_#{k.upcase}=#{v}" }.join("\n")
|
9
|
+
rescue Errno::ENOENT
|
10
|
+
puts 'echo "No config file present (~/.augury.yml) no env vars set"'
|
11
|
+
exit 1
|
12
|
+
end
|
data/bin/setup
ADDED
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,26 @@ 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
|
+
|
56
|
+
option :debug,
|
57
|
+
type: :boolean,
|
58
|
+
aliases: '-d',
|
59
|
+
hide: true
|
60
|
+
|
46
61
|
def generate(username, *path)
|
47
62
|
path = File.expand_path(path[0] || username)
|
48
63
|
augury = Augury::Fortune.new(username, path, options)
|
@@ -53,6 +68,7 @@ module Augury
|
|
53
68
|
rescue StandardError => e
|
54
69
|
say 'There was an error running the command. Details below:'
|
55
70
|
say e.message
|
71
|
+
puts e.backtrace if options[:debug]
|
56
72
|
exit 1
|
57
73
|
end
|
58
74
|
|
@@ -63,21 +79,19 @@ module Augury
|
|
63
79
|
defaults = Thor::CoreExt::HashWithIndifferentAccess.new(
|
64
80
|
{
|
65
81
|
width: 72,
|
66
|
-
append: false,
|
67
82
|
count: 200,
|
68
|
-
retweets: false,
|
69
|
-
replies: false,
|
70
|
-
links: false,
|
71
|
-
attribution: false,
|
72
83
|
},
|
73
84
|
)
|
74
85
|
|
75
|
-
config_path = File.expand_path('~/.augury.yml')
|
86
|
+
config_path = File.expand_path(ENV.fetch('AUGURY_CFG_PATH', '~/.augury.yml'))
|
76
87
|
if File.file?(config_path)
|
77
88
|
config_options = Thor::CoreExt::HashWithIndifferentAccess.new(YAML.load_file(config_path) || {})
|
78
89
|
defaults = defaults.merge(config_options)
|
79
90
|
end
|
80
91
|
|
92
|
+
# Enforce implied options
|
93
|
+
defaults[:links] = true if original_options[:remove_links] || defaults[:remove_links]
|
94
|
+
|
81
95
|
Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
|
82
96
|
end
|
83
97
|
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
|
@@ -17,23 +17,25 @@ module Augury
|
|
17
17
|
response = yield(max_id)
|
18
18
|
collection += response
|
19
19
|
if response.empty?
|
20
|
-
collection
|
20
|
+
collection
|
21
21
|
elsif !@config[:count].zero? && collection.length >= @config[:count]
|
22
|
-
|
22
|
+
# Get everything or trim the results to the count
|
23
|
+
@config[:count].zero? ? collection : collection[0..@config[:count] - 1]
|
23
24
|
else
|
24
25
|
collect_with_max_id(collection, response.last.id - 1, &block)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
def retrieve_tweets
|
29
|
-
collect_with_max_id do |max_id|
|
30
|
+
@tweets = collect_with_max_id do |max_id|
|
30
31
|
options = {
|
31
|
-
count:
|
32
|
+
count: 200,
|
33
|
+
tweet_mode: 'extended',
|
32
34
|
include_rts: @config[:retweets],
|
33
35
|
exclude_replies: !@config[:replies],
|
34
36
|
}
|
35
37
|
options[:max_id] = max_id unless max_id.nil?
|
36
|
-
@
|
38
|
+
@twitter.user_timeline(@username, options)
|
37
39
|
end
|
38
40
|
rescue Twitter::Error::TooManyRequests => e
|
39
41
|
reset_length = e.rate_limit.reset_in + 1
|
@@ -45,9 +47,17 @@ module Augury
|
|
45
47
|
filtered = @tweets.flat_map(&:full_text).reject do |tweet|
|
46
48
|
tweet.match(/https?:/) unless @config[:links]
|
47
49
|
end
|
48
|
-
|
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
|
49
58
|
author = @config[:attribution] ? "\n-- #{@twitter.user(@username).name}\n" : ''
|
50
|
-
formatted.join("#{author}%\n")
|
59
|
+
text = formatted.join("#{author}%\n")
|
60
|
+
text + author if author
|
51
61
|
end
|
52
62
|
|
53
63
|
def write_fortune
|
@@ -74,5 +84,28 @@ module Augury
|
|
74
84
|
cfg.access_token_secret = @config[:twitter]['access_token_secret']
|
75
85
|
end
|
76
86
|
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def transforms
|
91
|
+
all_transforms = []
|
92
|
+
all_transforms << [/https?:\/\/[^\s]+/, ''] if @config[:remove_links]
|
93
|
+
return all_transforms unless @config[:apply_transforms]
|
94
|
+
|
95
|
+
all_transforms.push(*@config.dig('transforms', @username) || [])
|
96
|
+
all_transforms.push(*@config.fetch('global-transforms', []))
|
97
|
+
|
98
|
+
raise Augury::TransformError unless validate_transforms(all_transforms)
|
99
|
+
|
100
|
+
all_transforms
|
101
|
+
end
|
102
|
+
|
103
|
+
def validate_transforms(all_transforms)
|
104
|
+
all_transforms.all? do |transform|
|
105
|
+
transform.count == 2 &&
|
106
|
+
[String, Regexp].include?(transform[0].class) &&
|
107
|
+
transform[1].is_a?(String)
|
108
|
+
end
|
109
|
+
end
|
77
110
|
end
|
78
111
|
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.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clayton Parker
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: twitter
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,33 +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: '
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: facets
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.0'
|
47
|
+
version: '1.0'
|
62
48
|
type: :runtime
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
54
|
+
version: '1.0'
|
69
55
|
description: This gem turns a twitter feed into a fortune file that you can use with
|
70
56
|
the fortune program
|
71
57
|
email:
|
@@ -77,8 +63,11 @@ extra_rdoc_files: []
|
|
77
63
|
files:
|
78
64
|
- ".codeclimate.yml"
|
79
65
|
- ".gitignore"
|
66
|
+
- ".rbenv-gemsets"
|
80
67
|
- ".rspec"
|
81
68
|
- ".rubocop.yml"
|
69
|
+
- ".ruby-gemset"
|
70
|
+
- ".ruby-version"
|
82
71
|
- ".solargraph.yml"
|
83
72
|
- ".travis.yml"
|
84
73
|
- CHANGELOG.md
|
@@ -87,9 +76,9 @@ files:
|
|
87
76
|
- LICENSE.txt
|
88
77
|
- README.md
|
89
78
|
- Rakefile
|
90
|
-
- TODO.md
|
91
79
|
- augury.gemspec
|
92
80
|
- bin/console
|
81
|
+
- bin/extract_creds
|
93
82
|
- bin/setup
|
94
83
|
- exe/augury
|
95
84
|
- lib/augury.rb
|
@@ -101,7 +90,7 @@ homepage: https://github.com/claytron/augury
|
|
101
90
|
licenses:
|
102
91
|
- MIT
|
103
92
|
metadata: {}
|
104
|
-
post_install_message:
|
93
|
+
post_install_message:
|
105
94
|
rdoc_options: []
|
106
95
|
require_paths:
|
107
96
|
- lib
|
@@ -117,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
106
|
version: '0'
|
118
107
|
requirements: []
|
119
108
|
rubygems_version: 3.1.4
|
120
|
-
signing_key:
|
109
|
+
signing_key:
|
121
110
|
specification_version: 4
|
122
111
|
summary: Turn a twitter feed into a fortune file
|
123
112
|
test_files: []
|
data/TODO.md
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# TODO
|
2
|
-
|
3
|
-
Some ideas for things that could be added:
|
4
|
-
|
5
|
-
- Add an option to limit the tweets from a certain date forward.
|
6
|
-
This would allow for adding the latest tweets via cron.
|
7
|
-
- Ask user for twitter config on first start, save it out
|
8
|
-
- Series of regex that could be applied.
|
9
|
-
This would be a way to make SeinfeldToday dialog get put on their own lines.
|
10
|
-
- Different word wrapping options. To a width, or by sentence, or whatever.
|