augury 0.1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +13 -0
- data/.gitignore +6 -1
- data/.rubocop.yml +45 -0
- data/.solargraph.yml +15 -0
- data/.travis.yml +14 -2
- data/CHANGELOG.md +33 -0
- data/Gemfile +21 -0
- data/Gemfile.lock +175 -0
- data/README.md +185 -25
- data/Rakefile +5 -3
- data/TODO.md +10 -0
- data/augury.gemspec +17 -24
- data/bin/console +2 -0
- data/bin/setup +1 -3
- data/lib/augury.rb +4 -2
- data/lib/augury/cli.rb +76 -4
- data/lib/augury/exception.rb +9 -0
- data/lib/augury/fortune.rb +68 -11
- data/lib/augury/version.rb +3 -1
- metadata +23 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 64257249dcbb8b277c6e19b5a53fffb5f66ef9faf301443fe80c4cdc2416df17
|
4
|
+
data.tar.gz: 43c407f9e4bfcb659c1beb15e2456d70a7df949cd1c7c72680dd058e42398e50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f395c7327e9e32b4dd8eb793868f3588f2d680c59b97d045af09589996e1bb1bd467ec3ba4efda183e120664f3dff56c36b5d3f9e2b3feca22637c800ba9b91
|
7
|
+
data.tar.gz: 49ef40634fae8a75d28a872eb8e64e68127a4a65255c8d4d444cd7d7696b79b5f2a072fea504ef16a18ff3e7883fc838e63367affdabf8f6f3725857688ebe42
|
data/.codeclimate.yml
ADDED
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
Exclude:
|
4
|
+
- bin/**/*
|
5
|
+
- vendor/**/*
|
6
|
+
|
7
|
+
Style/TrailingCommaInArguments:
|
8
|
+
EnforcedStyleForMultiline: comma
|
9
|
+
|
10
|
+
Style/TrailingCommaInHashLiteral:
|
11
|
+
EnforcedStyleForMultiline: comma
|
12
|
+
|
13
|
+
Style/TrailingCommaInArrayLiteral:
|
14
|
+
EnforcedStyleForMultiline: comma
|
15
|
+
|
16
|
+
Style/RedundantSelf:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Layout/IndentationWidth:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
# Alignment so that changing var / method does not change all lines in diff
|
23
|
+
Layout/ParameterAlignment:
|
24
|
+
EnforcedStyle: with_fixed_indentation
|
25
|
+
|
26
|
+
Layout/ArgumentAlignment:
|
27
|
+
EnforcedStyle: with_fixed_indentation
|
28
|
+
|
29
|
+
Layout/MultilineMethodCallIndentation:
|
30
|
+
EnforcedStyle: indented
|
31
|
+
|
32
|
+
Layout/MultilineOperationIndentation:
|
33
|
+
EnforcedStyle: indented
|
34
|
+
|
35
|
+
Layout/EndAlignment:
|
36
|
+
EnforcedStyleAlignWith: variable
|
37
|
+
AutoCorrect: true
|
38
|
+
|
39
|
+
Layout/CaseIndentation:
|
40
|
+
EnforcedStyle: end
|
41
|
+
IndentOneStep: true
|
42
|
+
|
43
|
+
# Ignore for rspec
|
44
|
+
Metrics/BlockLength:
|
45
|
+
ExcludedMethods: ['describe', 'context']
|
data/.solargraph.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
-
|
4
|
-
|
3
|
+
- 3.0
|
4
|
+
- 2.7
|
5
|
+
- 2.6
|
6
|
+
before_install:
|
7
|
+
- sudo apt-get -y install fortune
|
8
|
+
before_script:
|
9
|
+
- export PATH=$PATH:/usr/games
|
10
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
11
|
+
- chmod +x ./cc-test-reporter
|
12
|
+
- ./cc-test-reporter before-build
|
13
|
+
script:
|
14
|
+
- bundle exec rspec
|
15
|
+
after_script:
|
16
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Changes
|
2
|
+
|
3
|
+
## 1.0.1 (2020-01-08)
|
4
|
+
|
5
|
+
- Remove unused gem
|
6
|
+
|
7
|
+
## 1.0.0 (2020-01-08)
|
8
|
+
|
9
|
+
- Convert augury config from ini style to yaml (breaking change)
|
10
|
+
- Add options for filtering out tweets (retweets, replies, links)
|
11
|
+
- Add option to show twitter user name as an attribution
|
12
|
+
- Ensure output has not html entities in it
|
13
|
+
|
14
|
+
## 0.3.0 (2015-08-20)
|
15
|
+
|
16
|
+
- Add `count` option and allow for a user to get all tweets
|
17
|
+
- Improve error handling
|
18
|
+
- Handle spaces in `path` argument
|
19
|
+
- Properly get defaults from the config if not passed on the command line
|
20
|
+
- Updated docs and interactive help
|
21
|
+
|
22
|
+
## 0.2.1 (2015-08-19)
|
23
|
+
|
24
|
+
- Fix docs on rubygems site
|
25
|
+
|
26
|
+
## 0.2.0 (2015-08-19)
|
27
|
+
|
28
|
+
- Initial working code and documentation
|
29
|
+
|
30
|
+
## 0.1.0 (2015-08-19)
|
31
|
+
|
32
|
+
- Initial code skeleton
|
33
|
+
- Test push to rubygems
|
data/Gemfile
CHANGED
@@ -1,4 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in augury.gemspec
|
4
6
|
gemspec
|
7
|
+
|
8
|
+
gem 'rake'
|
9
|
+
|
10
|
+
# Testing
|
11
|
+
gem 'rspec', '~>3.0'
|
12
|
+
gem 'simplecov'
|
13
|
+
gem 'vcr'
|
14
|
+
gem 'webmock'
|
15
|
+
|
16
|
+
# Debugging
|
17
|
+
gem 'pry'
|
18
|
+
gem 'pry-awesome_print'
|
19
|
+
gem 'pry-byebug'
|
20
|
+
|
21
|
+
# Linting / completion
|
22
|
+
gem 'rubocop', '0.92'
|
23
|
+
gem 'rubocop-rake'
|
24
|
+
gem 'rubocop-rspec'
|
25
|
+
gem 'solargraph'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
augury (1.0.1)
|
5
|
+
facets (~> 3.0)
|
6
|
+
thor (~> 1.0)
|
7
|
+
twitter (~> 7.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.7.0)
|
13
|
+
public_suffix (>= 2.0.2, < 5.0)
|
14
|
+
ast (2.4.1)
|
15
|
+
awesome_print (1.8.0)
|
16
|
+
backport (1.1.2)
|
17
|
+
benchmark (0.1.1)
|
18
|
+
buftok (0.2.0)
|
19
|
+
byebug (11.1.3)
|
20
|
+
coderay (1.1.3)
|
21
|
+
crack (0.4.5)
|
22
|
+
rexml
|
23
|
+
diff-lcs (1.4.4)
|
24
|
+
docile (1.3.4)
|
25
|
+
domain_name (0.5.20190701)
|
26
|
+
unf (>= 0.0.5, < 1.0.0)
|
27
|
+
e2mmap (0.1.0)
|
28
|
+
equalizer (0.0.11)
|
29
|
+
facets (3.1.0)
|
30
|
+
ffi (1.14.2)
|
31
|
+
ffi-compiler (1.0.1)
|
32
|
+
ffi (>= 1.0.0)
|
33
|
+
rake
|
34
|
+
hashdiff (1.0.1)
|
35
|
+
http (4.4.1)
|
36
|
+
addressable (~> 2.3)
|
37
|
+
http-cookie (~> 1.0)
|
38
|
+
http-form_data (~> 2.2)
|
39
|
+
http-parser (~> 1.2.0)
|
40
|
+
http-cookie (1.0.3)
|
41
|
+
domain_name (~> 0.5)
|
42
|
+
http-form_data (2.3.0)
|
43
|
+
http-parser (1.2.2)
|
44
|
+
ffi-compiler
|
45
|
+
http_parser.rb (0.6.0)
|
46
|
+
jaro_winkler (1.5.4)
|
47
|
+
kramdown (2.3.0)
|
48
|
+
rexml
|
49
|
+
kramdown-parser-gfm (1.1.0)
|
50
|
+
kramdown (~> 2.0)
|
51
|
+
memoizable (0.4.2)
|
52
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
53
|
+
method_source (1.0.0)
|
54
|
+
mini_portile2 (2.5.0)
|
55
|
+
multipart-post (2.1.1)
|
56
|
+
naught (1.1.0)
|
57
|
+
nokogiri (1.11.1)
|
58
|
+
mini_portile2 (~> 2.5.0)
|
59
|
+
racc (~> 1.4)
|
60
|
+
parallel (1.20.1)
|
61
|
+
parser (2.7.2.0)
|
62
|
+
ast (~> 2.4.1)
|
63
|
+
pry (0.13.1)
|
64
|
+
coderay (~> 1.1)
|
65
|
+
method_source (~> 1.0)
|
66
|
+
pry-awesome_print (9.6.11)
|
67
|
+
awesome_print (>= 1.1.0, < 999)
|
68
|
+
pry (>= 0.9.0, < 999)
|
69
|
+
pry-byebug (3.9.0)
|
70
|
+
byebug (~> 11.0)
|
71
|
+
pry (~> 0.13.0)
|
72
|
+
public_suffix (4.0.6)
|
73
|
+
racc (1.5.2)
|
74
|
+
rainbow (3.0.0)
|
75
|
+
rake (13.0.3)
|
76
|
+
regexp_parser (2.0.3)
|
77
|
+
reverse_markdown (2.0.0)
|
78
|
+
nokogiri
|
79
|
+
rexml (3.2.4)
|
80
|
+
rspec (3.10.0)
|
81
|
+
rspec-core (~> 3.10.0)
|
82
|
+
rspec-expectations (~> 3.10.0)
|
83
|
+
rspec-mocks (~> 3.10.0)
|
84
|
+
rspec-core (3.10.1)
|
85
|
+
rspec-support (~> 3.10.0)
|
86
|
+
rspec-expectations (3.10.1)
|
87
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
88
|
+
rspec-support (~> 3.10.0)
|
89
|
+
rspec-mocks (3.10.1)
|
90
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
91
|
+
rspec-support (~> 3.10.0)
|
92
|
+
rspec-support (3.10.1)
|
93
|
+
rubocop (0.92.0)
|
94
|
+
parallel (~> 1.10)
|
95
|
+
parser (>= 2.7.1.5)
|
96
|
+
rainbow (>= 2.2.2, < 4.0)
|
97
|
+
regexp_parser (>= 1.7)
|
98
|
+
rexml
|
99
|
+
rubocop-ast (>= 0.5.0)
|
100
|
+
ruby-progressbar (~> 1.7)
|
101
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
102
|
+
rubocop-ast (1.4.0)
|
103
|
+
parser (>= 2.7.1.5)
|
104
|
+
rubocop-rake (0.5.1)
|
105
|
+
rubocop
|
106
|
+
rubocop-rspec (1.44.1)
|
107
|
+
rubocop (~> 0.87)
|
108
|
+
rubocop-ast (>= 0.7.1)
|
109
|
+
ruby-progressbar (1.11.0)
|
110
|
+
simple_oauth (0.3.1)
|
111
|
+
simplecov (0.21.1)
|
112
|
+
docile (~> 1.1)
|
113
|
+
simplecov-html (~> 0.11)
|
114
|
+
simplecov_json_formatter (~> 0.1)
|
115
|
+
simplecov-html (0.12.3)
|
116
|
+
simplecov_json_formatter (0.1.2)
|
117
|
+
solargraph (0.40.1)
|
118
|
+
backport (~> 1.1)
|
119
|
+
benchmark
|
120
|
+
bundler (>= 1.17.2)
|
121
|
+
e2mmap
|
122
|
+
jaro_winkler (~> 1.5)
|
123
|
+
kramdown (~> 2.3)
|
124
|
+
kramdown-parser-gfm (~> 1.1)
|
125
|
+
parser (~> 2.3)
|
126
|
+
reverse_markdown (>= 1.0.5, < 3)
|
127
|
+
rubocop (>= 0.52)
|
128
|
+
thor (~> 1.0)
|
129
|
+
tilt (~> 2.0)
|
130
|
+
yard (~> 0.9, >= 0.9.24)
|
131
|
+
thor (1.0.1)
|
132
|
+
thread_safe (0.3.6)
|
133
|
+
tilt (2.0.10)
|
134
|
+
twitter (7.0.0)
|
135
|
+
addressable (~> 2.3)
|
136
|
+
buftok (~> 0.2.0)
|
137
|
+
equalizer (~> 0.0.11)
|
138
|
+
http (~> 4.0)
|
139
|
+
http-form_data (~> 2.0)
|
140
|
+
http_parser.rb (~> 0.6.0)
|
141
|
+
memoizable (~> 0.4.0)
|
142
|
+
multipart-post (~> 2.0)
|
143
|
+
naught (~> 1.0)
|
144
|
+
simple_oauth (~> 0.3.0)
|
145
|
+
unf (0.1.4)
|
146
|
+
unf_ext
|
147
|
+
unf_ext (0.0.7.7)
|
148
|
+
unicode-display_width (1.7.0)
|
149
|
+
vcr (6.0.0)
|
150
|
+
webmock (3.11.0)
|
151
|
+
addressable (>= 2.3.6)
|
152
|
+
crack (>= 0.3.2)
|
153
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
154
|
+
yard (0.9.26)
|
155
|
+
|
156
|
+
PLATFORMS
|
157
|
+
ruby
|
158
|
+
|
159
|
+
DEPENDENCIES
|
160
|
+
augury!
|
161
|
+
pry
|
162
|
+
pry-awesome_print
|
163
|
+
pry-byebug
|
164
|
+
rake
|
165
|
+
rspec (~> 3.0)
|
166
|
+
rubocop (= 0.92)
|
167
|
+
rubocop-rake
|
168
|
+
rubocop-rspec
|
169
|
+
simplecov
|
170
|
+
solargraph
|
171
|
+
vcr
|
172
|
+
webmock
|
173
|
+
|
174
|
+
BUNDLED WITH
|
175
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,8 +1,49 @@
|
|
1
1
|
# Augury
|
2
2
|
|
3
|
-
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/73443845cac0dadff540/maintainability)](https://codeclimate.com/github/claytron/augury/maintainability)
|
4
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/73443845cac0dadff540/test_coverage)](https://codeclimate.com/github/claytron/augury/test_coverage)
|
5
|
+
[![Tests](https://travis-ci.com/claytron/augury.svg?branch=master)](https://travis-ci.com/github/claytron/augury)
|
6
|
+
|
7
|
+
Have you ever wanted to turn a twitter account into a fortune file?
|
4
8
|
Well, today is your lucky day!
|
5
|
-
|
9
|
+
|
10
|
+
<blockquote>
|
11
|
+
Augury is the practice from ancient Roman religion of<br>
|
12
|
+
interpreting omens from the observed flight of birds.<br><br>
|
13
|
+
As per <a href="https://en.wikipedia.org/wiki/Augury">Wikipedia</a>
|
14
|
+
</blockquote>
|
15
|
+
|
16
|
+
There are a lot of really funny twitter accounts out there.
|
17
|
+
Let's just pick one and get started.
|
18
|
+
|
19
|
+
```sh
|
20
|
+
$ augury generate seinfeldtoday
|
21
|
+
```
|
22
|
+
|
23
|
+
This just created the fortune files in the current directory:
|
24
|
+
|
25
|
+
```sh
|
26
|
+
$ ls
|
27
|
+
seinfeldtoday seinfeldtoday.dat
|
28
|
+
```
|
29
|
+
|
30
|
+
You can now read the new fortunes!
|
31
|
+
|
32
|
+
```sh
|
33
|
+
$ fortune seinfeldtoday
|
34
|
+
Elaine has no idea what her BF does for a living and it's now too
|
35
|
+
late to ask. E:"Teacher, I think. Or a doctor? Wait Is
|
36
|
+
'computers' a job?"
|
37
|
+
```
|
38
|
+
|
39
|
+
Thanks for all the laughs fortune :)
|
40
|
+
|
41
|
+
Here are some accounts that work well with Augury:
|
42
|
+
|
43
|
+
- [Modern Seinfeld](https://twitter.com/seinfeldtoday)
|
44
|
+
- [Very Short Story](https://twitter.com/veryshortstory)
|
45
|
+
- [Bored Elon Musk](https://twitter.com/boredelonmusk)
|
46
|
+
- Your own feed, so you can get nostalgic.
|
6
47
|
|
7
48
|
## Installation
|
8
49
|
|
@@ -14,48 +55,154 @@ gem 'augury'
|
|
14
55
|
|
15
56
|
And then execute:
|
16
57
|
|
17
|
-
|
58
|
+
```sh
|
59
|
+
$ bundle
|
60
|
+
```
|
18
61
|
|
19
62
|
Or install it yourself as:
|
20
63
|
|
21
|
-
|
64
|
+
```sh
|
65
|
+
$ gem install augury
|
66
|
+
```
|
67
|
+
|
68
|
+
### Requirements
|
69
|
+
|
70
|
+
This gem requires that the fortune program is also installed.
|
71
|
+
The fortune program ships with a `strfile` program that converts the plain text files to something that fortune can select from.
|
72
|
+
|
73
|
+
For example,
|
74
|
+
if you are using Homebrew on OS X:
|
75
|
+
|
76
|
+
```sh
|
77
|
+
$ brew install fortune
|
78
|
+
```
|
22
79
|
|
23
80
|
## Configuration
|
24
81
|
|
25
|
-
|
82
|
+
### Augury Config
|
26
83
|
|
27
|
-
|
84
|
+
Create the `~/.augry.cfg` file and then set the permissions since your Twitter API info will be in there.
|
28
85
|
|
29
|
-
|
86
|
+
```sh
|
87
|
+
$ touch ~/.augury.cfg
|
88
|
+
$ chmod 600 ~/.augury.cfg
|
89
|
+
```
|
90
|
+
|
91
|
+
Set any of these settings in the `augury` section of the config like this:
|
92
|
+
|
93
|
+
```yaml
|
94
|
+
count: 20
|
95
|
+
attribution: true
|
96
|
+
```
|
30
97
|
|
31
|
-
|
32
|
-
This can be done by setting up the `~/.augury.conf` file.
|
33
|
-
Here is an example of its contents:
|
98
|
+
### Option list
|
34
99
|
|
35
|
-
|
36
|
-
consumer_secret = "YOUR_CONSUMER_SECRET"
|
37
|
-
access_token = "YOUR_ACCESS_TOKEN"
|
38
|
-
access_token_secret = "YOUR_ACCESS_SECRET"
|
100
|
+
These are the available options for the `~/.augury.yml` config file.
|
39
101
|
|
40
|
-
|
102
|
+
Option | Description | Default
|
103
|
+
------ | :---------- | -------
|
104
|
+
`append` | Make the script add more entries to the specified file instead of re-writing it | `false`
|
105
|
+
`width` | Set the default width used if none is given on the command line. | `72`
|
106
|
+
`count` | The number of tweets to get. Set to 0 to get all. | `200`
|
107
|
+
`retweets` | Include retweets. | `false`
|
108
|
+
`replies` | Include replies. | `false`
|
109
|
+
`links` | Include tweets with links in them. | `false`
|
110
|
+
`attribution` | Add an author attribution to each fortune. | `false`
|
41
111
|
|
42
|
-
|
112
|
+
### Twitter Setup
|
113
|
+
|
114
|
+
First, you will need to create a new Twitter application by going here:
|
115
|
+
https://developer.twitter.com
|
116
|
+
|
117
|
+
This will give you the ability to generate the consumer and access information used below.
|
118
|
+
|
119
|
+
Add the following to your `~/.augury.yml` config.
|
120
|
+
|
121
|
+
```yaml
|
122
|
+
twitter:
|
123
|
+
consumer_key: YOUR_CONSUMER_KEY
|
124
|
+
consumer_secret: YOUR_CONSUMER_SECRET
|
125
|
+
access_token: YOUR_ACCESS_TOKEN
|
126
|
+
access_token_secret: YOUR_ACCESS_TOKEN_SECRET
|
127
|
+
```
|
43
128
|
|
44
129
|
## Usage
|
45
130
|
|
46
|
-
|
131
|
+
Create a fortune for the latest *seinfeldtoday* tweets.
|
132
|
+
|
133
|
+
```sh
|
134
|
+
$ augury generate seinfeldtoday
|
135
|
+
```
|
136
|
+
|
137
|
+
Now you have some fortunes.
|
138
|
+
|
139
|
+
```sh
|
140
|
+
$ fortune seinfeldtoday
|
141
|
+
```
|
142
|
+
|
143
|
+
Specify a width and a different path to use:
|
144
|
+
|
145
|
+
```sh
|
146
|
+
$ augury generate -w 120 seinfeldtoday /usr/local/share/games/fortune/Modern\ Seinfeld
|
147
|
+
```
|
148
|
+
|
149
|
+
If this is where your fortune program looks for fortunes,
|
150
|
+
you can now use the new fortune.
|
151
|
+
|
152
|
+
```sh
|
153
|
+
$ fortune "Modern Seinfeld"
|
154
|
+
```
|
155
|
+
|
156
|
+
### See the interactive help
|
157
|
+
|
158
|
+
Run the help to get more details about what the program can do
|
159
|
+
|
160
|
+
```sh
|
161
|
+
$ augury help
|
162
|
+
$ augury help generate
|
163
|
+
```
|
47
164
|
|
48
165
|
## Development
|
49
166
|
|
50
|
-
|
51
|
-
|
52
|
-
|
167
|
+
If you want to contribute to this library,
|
168
|
+
do the following.
|
169
|
+
|
170
|
+
Create a fork, then get the code
|
171
|
+
|
172
|
+
```sh
|
173
|
+
$ git clone git@github.com:YOUR_USERNAME/augury.git
|
174
|
+
$ cd augury
|
175
|
+
```
|
176
|
+
|
177
|
+
Run the setup script to get everything installed:
|
53
178
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
179
|
+
**NOTE**: This requires having bundler available.
|
180
|
+
That is beyond the scope of this README.
|
181
|
+
|
182
|
+
```sh
|
183
|
+
$ bin/setup
|
184
|
+
```
|
185
|
+
|
186
|
+
Once that is finished, there is a console available.
|
187
|
+
This gives you access to all the code via Pry.
|
188
|
+
|
189
|
+
```sh
|
190
|
+
$ bin/console
|
191
|
+
```
|
192
|
+
|
193
|
+
The `augury` command will be available in `exe`:
|
194
|
+
|
195
|
+
```sh
|
196
|
+
$ bundle exec ruby exe/augury help
|
197
|
+
```
|
198
|
+
|
199
|
+
### Run the tests
|
200
|
+
|
201
|
+
You can run the tests with the rake task:
|
202
|
+
|
203
|
+
```sh
|
204
|
+
$ bundle exec rake spec
|
205
|
+
```
|
59
206
|
|
60
207
|
## Contributing
|
61
208
|
|
@@ -64,3 +211,16 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/claytr
|
|
64
211
|
## License
|
65
212
|
|
66
213
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
214
|
+
|
215
|
+
## Thanks for all the fish
|
216
|
+
|
217
|
+
Thanks to [TinderBox](http://gettinderbox.com) for giving us time to make cool things happen!
|
218
|
+
|
219
|
+
This was an excellent learning experience for the author,
|
220
|
+
who was new at programming in Ruby.
|
221
|
+
|
222
|
+
The [Developing a RubyGem using Bundler][gemdocs] documentation was fun to read and informative.
|
223
|
+
It helped get the skeleton of the code set up and extra goodies in the development profile.
|
224
|
+
Highly recommended read!
|
225
|
+
|
226
|
+
[gemdocs]: https://github.com/radar/guides/blob/master/gem-development.md#developing-a-rubygem-using-bundler
|
data/Rakefile
CHANGED
data/TODO.md
ADDED
@@ -0,0 +1,10 @@
|
|
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.
|
data/augury.gemspec
CHANGED
@@ -1,34 +1,27 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
require 'augury/version'
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/augury/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'augury'
|
8
7
|
spec.version = Augury::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
8
|
+
spec.authors = ['Clayton Parker']
|
9
|
+
spec.email = ['robots@claytron.com']
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
11
|
+
spec.summary = 'Turn a twitter feed into a fortune file'
|
12
|
+
spec.description = 'This gem turns a twitter feed into a fortune file that you can use with the fortune program'
|
13
|
+
spec.homepage = 'https://github.com/claytron/augury'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir =
|
18
|
+
spec.bindir = 'exe'
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
20
|
+
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
# Actual dependencies
|
23
|
-
spec.add_dependency
|
24
|
-
spec.add_dependency
|
25
|
-
|
26
|
-
|
27
|
-
# Development dependencies
|
28
|
-
spec.add_development_dependency "bundler", "~> 1.10"
|
29
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
-
spec.add_development_dependency "rspec"
|
31
|
-
spec.add_development_dependency "pry"
|
32
|
-
spec.add_development_dependency "cucumber"
|
33
|
-
spec.add_development_dependency "aruba"
|
23
|
+
spec.add_dependency 'thor', '~>1.0'
|
24
|
+
spec.add_dependency 'twitter', '~>7.0'
|
25
|
+
## For the word_wrap function
|
26
|
+
spec.add_dependency 'facets', '~>3.0'
|
34
27
|
end
|
data/bin/console
CHANGED
data/bin/setup
CHANGED
data/lib/augury.rb
CHANGED
data/lib/augury/cli.rb
CHANGED
@@ -1,12 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'thor'
|
4
|
+
require 'yaml'
|
2
5
|
require 'augury'
|
3
6
|
|
4
7
|
module Augury
|
5
8
|
class CLI < Thor
|
6
|
-
desc 'generate USERNAME', 'Generate a fortune file for the given username'
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
desc 'generate USERNAME [PATH]', 'Generate a fortune file for the given username'
|
10
|
+
|
11
|
+
option :width,
|
12
|
+
type: :numeric,
|
13
|
+
aliases: '-w',
|
14
|
+
desc: 'The maximum number of columns that will be written on a line. DEFAULT: 72'
|
15
|
+
|
16
|
+
option :append,
|
17
|
+
type: :boolean,
|
18
|
+
aliases: '-a',
|
19
|
+
desc: 'If set, the target path will be appended to instead of overwritten'
|
20
|
+
|
21
|
+
option :count,
|
22
|
+
type: :numeric,
|
23
|
+
aliases: '-c',
|
24
|
+
desc: 'The number of tweets to get. Set to 0 to get all. DEFAULT: 200'
|
25
|
+
|
26
|
+
option :retweets,
|
27
|
+
type: :boolean,
|
28
|
+
aliases: '-r',
|
29
|
+
desc: 'Include retweets. DEFAULT: false'
|
30
|
+
|
31
|
+
option :replies,
|
32
|
+
type: :boolean,
|
33
|
+
aliases: '-R',
|
34
|
+
desc: 'Include replies. DEFAULT: false'
|
35
|
+
|
36
|
+
option :links,
|
37
|
+
type: :boolean,
|
38
|
+
aliases: '-l',
|
39
|
+
desc: 'Include tweets with links in them. DEFAULT: false'
|
40
|
+
|
41
|
+
option :attribution,
|
42
|
+
type: :boolean,
|
43
|
+
aliases: '-A',
|
44
|
+
desc: 'Add an author attribution to each fortune. DEFAULT: false'
|
45
|
+
|
46
|
+
def generate(username, *path)
|
47
|
+
path = File.expand_path(path[0] || username)
|
48
|
+
augury = Augury::Fortune.new(username, path, options)
|
49
|
+
augury.twitter_setup
|
50
|
+
augury.retrieve_tweets
|
51
|
+
augury.write_fortune
|
52
|
+
say "Fortune written out to #{path}"
|
53
|
+
rescue StandardError => e
|
54
|
+
say 'There was an error running the command. Details below:'
|
55
|
+
say e.message
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def options
|
62
|
+
original_options = super
|
63
|
+
defaults = Thor::CoreExt::HashWithIndifferentAccess.new(
|
64
|
+
{
|
65
|
+
width: 72,
|
66
|
+
append: false,
|
67
|
+
count: 200,
|
68
|
+
retweets: false,
|
69
|
+
replies: false,
|
70
|
+
links: false,
|
71
|
+
attribution: false,
|
72
|
+
},
|
73
|
+
)
|
74
|
+
|
75
|
+
config_path = File.expand_path('~/.augury.yml')
|
76
|
+
if File.file?(config_path)
|
77
|
+
config_options = Thor::CoreExt::HashWithIndifferentAccess.new(YAML.load_file(config_path) || {})
|
78
|
+
defaults = defaults.merge(config_options)
|
79
|
+
end
|
80
|
+
|
81
|
+
Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
|
10
82
|
end
|
11
83
|
end
|
12
84
|
end
|
data/lib/augury/fortune.rb
CHANGED
@@ -1,21 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
require 'facets/string/word_wrap'
|
1
5
|
require 'twitter'
|
2
|
-
require 'parseconfig'
|
3
6
|
|
4
7
|
module Augury
|
5
8
|
class Fortune
|
6
|
-
def initialize
|
7
|
-
|
8
|
-
@
|
9
|
-
@
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
def initialize(username, path, config)
|
10
|
+
@username = username
|
11
|
+
@path = path
|
12
|
+
@config = config
|
13
|
+
@tweets = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def collect_with_max_id(collection = [], max_id = nil, &block)
|
17
|
+
response = yield(max_id)
|
18
|
+
collection += response
|
19
|
+
if response.empty?
|
20
|
+
collection.flatten
|
21
|
+
elsif !@config[:count].zero? && collection.length >= @config[:count]
|
22
|
+
collection.flatten
|
23
|
+
else
|
24
|
+
collect_with_max_id(collection, response.last.id - 1, &block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def retrieve_tweets
|
29
|
+
collect_with_max_id do |max_id|
|
30
|
+
options = {
|
31
|
+
count: @config[:count].zero? ? 200 : @config[:count],
|
32
|
+
include_rts: @config[:retweets],
|
33
|
+
exclude_replies: !@config[:replies],
|
34
|
+
}
|
35
|
+
options[:max_id] = max_id unless max_id.nil?
|
36
|
+
@tweets = @twitter.user_timeline(@username, options)
|
37
|
+
end
|
38
|
+
rescue Twitter::Error::TooManyRequests => e
|
39
|
+
reset_length = e.rate_limit.reset_in + 1
|
40
|
+
puts "Twitter rate limit exceeded. Waiting #{reset_length} minute(s)"
|
41
|
+
sleep reset_length
|
42
|
+
end
|
43
|
+
|
44
|
+
def format_fortune
|
45
|
+
filtered = @tweets.flat_map(&:full_text).reject do |tweet|
|
46
|
+
tweet.match(/https?:/) unless @config[:links]
|
14
47
|
end
|
48
|
+
formatted = filtered.flat_map { |tweet| CGI.unescapeHTML(tweet).word_wrap(@config[:width]) }
|
49
|
+
author = @config[:attribution] ? "\n-- #{@twitter.user(@username).name}\n" : ''
|
50
|
+
formatted.join("#{author}%\n")
|
15
51
|
end
|
16
52
|
|
17
|
-
def
|
18
|
-
|
53
|
+
def write_fortune
|
54
|
+
# Write out the file
|
55
|
+
begin
|
56
|
+
mode = @config[:append] ? 'a' : 'w'
|
57
|
+
file = File.open(@path, mode)
|
58
|
+
file.write("%\n") if @config[:append]
|
59
|
+
file.write(format_fortune)
|
60
|
+
ensure
|
61
|
+
file&.close
|
62
|
+
end
|
63
|
+
# Create the dat file too
|
64
|
+
`strfile '#{@path}' '#{@path}.dat'`
|
65
|
+
end
|
66
|
+
|
67
|
+
def twitter_setup
|
68
|
+
raise Augury::TwitterConfigError unless @config[:twitter]
|
69
|
+
|
70
|
+
@twitter = Twitter::REST::Client.new do |cfg|
|
71
|
+
cfg.consumer_key = @config[:twitter]['consumer_key']
|
72
|
+
cfg.consumer_secret = @config[:twitter]['consumer_secret']
|
73
|
+
cfg.access_token = @config[:twitter]['access_token']
|
74
|
+
cfg.access_token_secret = @config[:twitter]['access_token_secret']
|
75
|
+
end
|
19
76
|
end
|
20
77
|
end
|
21
78
|
end
|
data/lib/augury/version.rb
CHANGED
metadata
CHANGED
@@ -1,141 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: augury
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clayton Parker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: twitter
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: parseconfig
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
13
|
- !ruby/object:Gem::Dependency
|
42
14
|
name: thor
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
44
16
|
requirements:
|
45
|
-
- - "
|
17
|
+
- - "~>"
|
46
18
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
19
|
+
version: '1.0'
|
48
20
|
type: :runtime
|
49
21
|
prerelease: false
|
50
22
|
version_requirements: !ruby/object:Gem::Requirement
|
51
23
|
requirements:
|
52
|
-
- - "
|
24
|
+
- - "~>"
|
53
25
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
26
|
+
version: '1.0'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
28
|
+
name: twitter
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
58
30
|
requirements:
|
59
31
|
- - "~>"
|
60
32
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
62
|
-
type: :
|
33
|
+
version: '7.0'
|
34
|
+
type: :runtime
|
63
35
|
prerelease: false
|
64
36
|
version_requirements: !ruby/object:Gem::Requirement
|
65
37
|
requirements:
|
66
38
|
- - "~>"
|
67
39
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
40
|
+
version: '7.0'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
42
|
+
name: facets
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
45
|
- - "~>"
|
74
46
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
76
|
-
type: :
|
47
|
+
version: '3.0'
|
48
|
+
type: :runtime
|
77
49
|
prerelease: false
|
78
50
|
version_requirements: !ruby/object:Gem::Requirement
|
79
51
|
requirements:
|
80
52
|
- - "~>"
|
81
53
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pry
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: cucumber
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: aruba
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
54
|
+
version: '3.0'
|
139
55
|
description: This gem turns a twitter feed into a fortune file that you can use with
|
140
56
|
the fortune program
|
141
57
|
email:
|
@@ -145,19 +61,26 @@ executables:
|
|
145
61
|
extensions: []
|
146
62
|
extra_rdoc_files: []
|
147
63
|
files:
|
64
|
+
- ".codeclimate.yml"
|
148
65
|
- ".gitignore"
|
149
66
|
- ".rspec"
|
67
|
+
- ".rubocop.yml"
|
68
|
+
- ".solargraph.yml"
|
150
69
|
- ".travis.yml"
|
70
|
+
- CHANGELOG.md
|
151
71
|
- Gemfile
|
72
|
+
- Gemfile.lock
|
152
73
|
- LICENSE.txt
|
153
74
|
- README.md
|
154
75
|
- Rakefile
|
76
|
+
- TODO.md
|
155
77
|
- augury.gemspec
|
156
78
|
- bin/console
|
157
79
|
- bin/setup
|
158
80
|
- exe/augury
|
159
81
|
- lib/augury.rb
|
160
82
|
- lib/augury/cli.rb
|
83
|
+
- lib/augury/exception.rb
|
161
84
|
- lib/augury/fortune.rb
|
162
85
|
- lib/augury/version.rb
|
163
86
|
homepage: https://github.com/claytron/augury
|
@@ -172,15 +95,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
95
|
requirements:
|
173
96
|
- - ">="
|
174
97
|
- !ruby/object:Gem::Version
|
175
|
-
version:
|
98
|
+
version: 2.6.0
|
176
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
100
|
requirements:
|
178
101
|
- - ">="
|
179
102
|
- !ruby/object:Gem::Version
|
180
103
|
version: '0'
|
181
104
|
requirements: []
|
182
|
-
|
183
|
-
rubygems_version: 2.4.5
|
105
|
+
rubygems_version: 3.1.4
|
184
106
|
signing_key:
|
185
107
|
specification_version: 4
|
186
108
|
summary: Turn a twitter feed into a fortune file
|