augury 0.2.1 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a745ff0e70cbdadbaf9dd4415b1edb16ec0bb87d
4
- data.tar.gz: 34a82cf9069b55127f301c6a54c623fea08866d0
2
+ SHA256:
3
+ metadata.gz: 0202c829a5e6fdfb712f3cf87ea3a340d2242ed6c86a328ab6fefce9c255963d
4
+ data.tar.gz: 2a90f740ab640843302ae6bc5e767c6d2f486d3c9ff060c200f8721ada5c16bd
5
5
  SHA512:
6
- metadata.gz: 6470c46d253a9315362d40d7035b516b7db8e69c936c2042b76a172fe145658d5e43f5f08185510715d92cafc65995cd91b9cc2f95ae60df549338de39c2d809
7
- data.tar.gz: 6f4e38961aa97d87c085c2b7c9b5f007536eb5b5f6a21026420842c2afb39afc5a70ab3546ae3033a9ea37a96c08c4ea74afdb8c1106f64a519697e158d15101
6
+ metadata.gz: 3c91a52995151ac50e642785bafe6247e79598eacda3ad32c3fd0ae8331b48596c6567342b17a11918761dff5da2ff2dbdd2544ec16643db666121689f95675f
7
+ data.tar.gz: 7c77c6c70e749e3c7f703a089554f686e3c7a1383c4f651a38a490b5f3c6244e28b658053a5bde478499e1994c6321817cd28ca6c8545b768a2fe83e2f72279d
@@ -0,0 +1,10 @@
1
+ ---
2
+ plugins:
3
+ fixme:
4
+ enabled: true
5
+ rubocop:
6
+ enabled: true
7
+ channel: rubocop-0-92
8
+ ratings:
9
+ paths:
10
+ - "**.rb"
data/.gitignore CHANGED
@@ -1,10 +1,13 @@
1
1
  /.bundle/
2
+ /vendor/
2
3
  /.yardoc
3
- /Gemfile.lock
4
4
  /_yardoc/
5
5
  /coverage/
6
6
  /doc/
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- *.gem
10
+ /*.gem
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
@@ -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']
@@ -0,0 +1,15 @@
1
+ ---
2
+ include:
3
+ - "**/*.rb"
4
+ exclude:
5
+ - spec/**/*
6
+ - test/**/*
7
+ - vendor/**/*
8
+ - ".bundle/**/*"
9
+ require: []
10
+ domains: []
11
+ reporters:
12
+ - rubocop
13
+ require_paths: []
14
+ plugins: []
15
+ max_files: 5000
@@ -1,4 +1,16 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- before_install: gem install bundler -v 1.10.6
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
@@ -0,0 +1,42 @@
1
+ # Changes
2
+
3
+ ## 1.0.3 (2020-01-23)
4
+
5
+ - Pin Thor version to avoid issue with `options` override
6
+ - Add tests for `Augury::CLI`
7
+
8
+ ## 1.0.2 (2020-01-09)
9
+
10
+ - Fix bug with specific tweet count retrieval
11
+
12
+ ## 1.0.1 (2020-01-08)
13
+
14
+ - Remove unused gem
15
+
16
+ ## 1.0.0 (2020-01-08)
17
+
18
+ - Convert augury config from ini style to yaml (breaking change)
19
+ - Add options for filtering out tweets (retweets, replies, links)
20
+ - Add option to show twitter user name as an attribution
21
+ - Ensure output has not html entities in it
22
+
23
+ ## 0.3.0 (2015-08-20)
24
+
25
+ - Add `count` option and allow for a user to get all tweets
26
+ - Improve error handling
27
+ - Handle spaces in `path` argument
28
+ - Properly get defaults from the config if not passed on the command line
29
+ - Updated docs and interactive help
30
+
31
+ ## 0.2.1 (2015-08-19)
32
+
33
+ - Fix docs on rubygems site
34
+
35
+ ## 0.2.0 (2015-08-19)
36
+
37
+ - Initial working code and documentation
38
+
39
+ ## 0.1.0 (2015-08-19)
40
+
41
+ - Initial code skeleton
42
+ - Test push to rubygems
data/Gemfile CHANGED
@@ -1,4 +1,26 @@
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
+ gem 'pry-doc'
21
+
22
+ # Linting / completion
23
+ gem 'rubocop', '0.92'
24
+ gem 'rubocop-rake'
25
+ gem 'rubocop-rspec'
26
+ gem 'solargraph'
@@ -0,0 +1,179 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ augury (1.0.2)
5
+ facets (~> 3.0)
6
+ thor (~> 1.0.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
+ pry-doc (1.1.0)
73
+ pry (~> 0.11)
74
+ yard (~> 0.9.11)
75
+ public_suffix (4.0.6)
76
+ racc (1.5.2)
77
+ rainbow (3.0.0)
78
+ rake (13.0.3)
79
+ regexp_parser (2.0.3)
80
+ reverse_markdown (2.0.0)
81
+ nokogiri
82
+ rexml (3.2.4)
83
+ rspec (3.10.0)
84
+ rspec-core (~> 3.10.0)
85
+ rspec-expectations (~> 3.10.0)
86
+ rspec-mocks (~> 3.10.0)
87
+ rspec-core (3.10.1)
88
+ rspec-support (~> 3.10.0)
89
+ rspec-expectations (3.10.1)
90
+ diff-lcs (>= 1.2.0, < 2.0)
91
+ rspec-support (~> 3.10.0)
92
+ rspec-mocks (3.10.1)
93
+ diff-lcs (>= 1.2.0, < 2.0)
94
+ rspec-support (~> 3.10.0)
95
+ rspec-support (3.10.1)
96
+ rubocop (0.92.0)
97
+ parallel (~> 1.10)
98
+ parser (>= 2.7.1.5)
99
+ rainbow (>= 2.2.2, < 4.0)
100
+ regexp_parser (>= 1.7)
101
+ rexml
102
+ rubocop-ast (>= 0.5.0)
103
+ ruby-progressbar (~> 1.7)
104
+ unicode-display_width (>= 1.4.0, < 2.0)
105
+ rubocop-ast (1.4.0)
106
+ parser (>= 2.7.1.5)
107
+ rubocop-rake (0.5.1)
108
+ rubocop
109
+ rubocop-rspec (1.44.1)
110
+ rubocop (~> 0.87)
111
+ rubocop-ast (>= 0.7.1)
112
+ ruby-progressbar (1.11.0)
113
+ simple_oauth (0.3.1)
114
+ simplecov (0.21.1)
115
+ docile (~> 1.1)
116
+ simplecov-html (~> 0.11)
117
+ simplecov_json_formatter (~> 0.1)
118
+ simplecov-html (0.12.3)
119
+ simplecov_json_formatter (0.1.2)
120
+ solargraph (0.40.1)
121
+ backport (~> 1.1)
122
+ benchmark
123
+ bundler (>= 1.17.2)
124
+ e2mmap
125
+ jaro_winkler (~> 1.5)
126
+ kramdown (~> 2.3)
127
+ kramdown-parser-gfm (~> 1.1)
128
+ parser (~> 2.3)
129
+ reverse_markdown (>= 1.0.5, < 3)
130
+ rubocop (>= 0.52)
131
+ thor (~> 1.0)
132
+ tilt (~> 2.0)
133
+ yard (~> 0.9, >= 0.9.24)
134
+ thor (1.0.1)
135
+ thread_safe (0.3.6)
136
+ tilt (2.0.10)
137
+ twitter (7.0.0)
138
+ addressable (~> 2.3)
139
+ buftok (~> 0.2.0)
140
+ equalizer (~> 0.0.11)
141
+ http (~> 4.0)
142
+ http-form_data (~> 2.0)
143
+ http_parser.rb (~> 0.6.0)
144
+ memoizable (~> 0.4.0)
145
+ multipart-post (~> 2.0)
146
+ naught (~> 1.0)
147
+ simple_oauth (~> 0.3.0)
148
+ unf (0.1.4)
149
+ unf_ext
150
+ unf_ext (0.0.7.7)
151
+ unicode-display_width (1.7.0)
152
+ vcr (6.0.0)
153
+ webmock (3.11.0)
154
+ addressable (>= 2.3.6)
155
+ crack (>= 0.3.2)
156
+ hashdiff (>= 0.4.0, < 2.0.0)
157
+ yard (0.9.26)
158
+
159
+ PLATFORMS
160
+ ruby
161
+
162
+ DEPENDENCIES
163
+ augury!
164
+ pry
165
+ pry-awesome_print
166
+ pry-byebug
167
+ pry-doc
168
+ rake
169
+ rspec (~> 3.0)
170
+ rubocop (= 0.92)
171
+ rubocop-rake
172
+ rubocop-rspec
173
+ simplecov
174
+ solargraph
175
+ vcr
176
+ webmock
177
+
178
+ BUNDLED WITH
179
+ 2.1.4
data/README.md CHANGED
@@ -1,25 +1,36 @@
1
1
  # Augury
2
2
 
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
+
3
7
  Have you ever wanted to turn a twitter account into a fortune file?
4
8
  Well, today is your lucky day!
5
9
 
6
- Here is an example:
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>
7
15
 
8
- ```
9
- $ augury generate SeinfeldToday
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
10
21
  ```
11
22
 
12
23
  This just created the fortune files in the current directory:
13
24
 
14
- ```
25
+ ```sh
15
26
  $ ls
16
- SeinfeldToday SeinfeldToday.dat
27
+ seinfeldtoday seinfeldtoday.dat
17
28
  ```
18
29
 
19
30
  You can now read the new fortunes!
20
31
 
21
- ```
22
- $ fortune SeinfeldToday
32
+ ```sh
33
+ $ fortune seinfeldtoday
23
34
  Elaine has no idea what her BF does for a living and it's now too
24
35
  late to ask. E:"Teacher, I think. Or a doctor? Wait Is
25
36
  'computers' a job?"
@@ -27,6 +38,13 @@ late to ask. E:"Teacher, I think. Or a doctor? Wait Is
27
38
 
28
39
  Thanks for all the laughs fortune :)
29
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.
47
+
30
48
  ## Installation
31
49
 
32
50
  Add this line to your application's Gemfile:
@@ -37,13 +55,13 @@ gem 'augury'
37
55
 
38
56
  And then execute:
39
57
 
40
- ```
58
+ ```sh
41
59
  $ bundle
42
60
  ```
43
61
 
44
62
  Or install it yourself as:
45
63
 
46
- ```
64
+ ```sh
47
65
  $ gem install augury
48
66
  ```
49
67
 
@@ -55,7 +73,7 @@ The fortune program ships with a `strfile` program that converts the plain text
55
73
  For example,
56
74
  if you are using Homebrew on OS X:
57
75
 
58
- ```
76
+ ```sh
59
77
  $ brew install fortune
60
78
  ```
61
79
 
@@ -63,69 +81,142 @@ $ brew install fortune
63
81
 
64
82
  ### Augury Config
65
83
 
66
- Create the `~/.augry.cfg` file and then set the permissions since your Twitter API info will be in there.
84
+ Create the `~/.augry.yml` file and then set the permissions since your Twitter API info will be in there.
67
85
 
68
86
  ```sh
69
- $ touch ~/.augury.cfg
70
- $ chmod 600 ~/.augury.cfg
87
+ $ touch ~/.augury.yml
88
+ $ chmod 600 ~/.augury.yml
71
89
  ```
72
90
 
73
- Set any of these settings in the `augury` section of the config like this:
91
+ Set any of the available settings in the config like this:
74
92
 
75
- ```ini
76
- [augury]
77
- example_option = "An interesting value"
93
+ ```yaml
94
+ count: 20
95
+ attribution: true
78
96
  ```
79
97
 
80
98
  ### Option list
81
99
 
82
- These are the available options for the `~/.augury.cfg`
100
+ These are the available options for the `~/.augury.yml` config file.
83
101
 
84
- - `append` Make the script add more entries to the specified file instead of re-writing it. DEFAULT: False
85
- - `width` Set the default width used if none is given on the command line. DEFAULT: 72
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`
86
111
 
87
112
  ### Twitter Setup
88
113
 
89
114
  First, you will need to create a new Twitter application by going here:
90
- https://apps.twitter.com
115
+ https://developer.twitter.com
91
116
 
92
117
  This will give you the ability to generate the consumer and access information used below.
93
118
 
94
- Add the following to your `~/.augury.cfg` file.
119
+ Add the following to your `~/.augury.yml` config.
95
120
 
96
- ```ini
97
- [twitter]
98
- consumer_key = "YOUR_CONSUMER_KEY"
99
- consumer_secret = "YOUR_CONSUMER_SECRET"
100
- access_token = "YOUR_ACCESS_TOKEN"
101
- access_token_secret = "YOUR_ACCESS_SECRET"
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
102
127
  ```
103
128
 
104
129
  ## Usage
105
130
 
106
- Create a fortune for the latest SeinfeldToday tweets.
131
+ Create a fortune for the latest *seinfeldtoday* tweets.
107
132
 
108
- ```
109
- $ augury generate SeinfeldToday
133
+ ```sh
134
+ $ augury generate seinfeldtoday
110
135
  ```
111
136
 
112
137
  Now you have some fortunes.
113
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"
114
154
  ```
115
- $ fortune SeinfeldToday
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
116
163
  ```
117
164
 
118
165
  ## Development
119
166
 
120
- After checking out the repo, run `bin/setup` to install dependencies.
121
- Then, run `rake spec` to run the tests.
122
- You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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:
123
178
 
124
- To install this gem onto your local machine, run `bundle exec rake install`.
125
- To release a new version, update the version number in `version.rb`,
126
- and then run `bundle exec rake release`,
127
- which will create a git tag for the version,
128
- push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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 rspec
205
+ ```
206
+
207
+ #### Twitter ENV
208
+
209
+ 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.
210
+
211
+ ```sh
212
+ $ eval `bin/extract_creds`
213
+ ```
214
+
215
+ Then run the tests as you normally would.
216
+
217
+ ```sh
218
+ $ bundle exec rspec
219
+ ```
129
220
 
130
221
  ## Contributing
131
222
 
@@ -134,3 +225,16 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/claytr
134
225
  ## License
135
226
 
136
227
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
228
+
229
+ ## Thanks for all the fish
230
+
231
+ Thanks to [TinderBox](http://gettinderbox.com) for giving us time to make cool things happen!
232
+
233
+ This was an excellent learning experience for the author,
234
+ who was new at programming in Ruby.
235
+
236
+ The [Developing a RubyGem using Bundler][gemdocs] documentation was fun to read and informative.
237
+ It helped get the skeleton of the code set up and extra goodies in the development profile.
238
+ Highly recommended read!
239
+
240
+ [gemdocs]: https://github.com/radar/guides/blob/master/gem-development.md#developing-a-rubygem-using-bundler
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -1,45 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
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 = "augury"
6
+ spec.name = 'augury'
8
7
  spec.version = Augury::VERSION
9
- spec.authors = ["Clayton Parker"]
10
- spec.email = ["robots@claytron.com"]
8
+ spec.authors = ['Clayton Parker']
9
+ spec.email = ['robots@claytron.com']
11
10
 
12
- spec.summary = %q{Turn a twitter feed into a fortune file}
13
- spec.description = %q{This gem turns a twitter feed into a fortune file that you can use with the fortune program}
14
- spec.homepage = "https://github.com/claytron/augury"
15
- spec.license = "MIT"
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 = "exe"
18
+ spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
21
 
22
22
  # Actual dependencies
23
- spec.add_dependency "parseconfig"
24
- spec.add_dependency "thor"
25
- spec.add_dependency "twitter"
26
- ## Handle booleans from simple config
27
- spec.add_dependency "wannabe_bool"
23
+ spec.add_dependency 'thor', '~>1.0.0'
24
+ spec.add_dependency 'twitter', '~>7.0'
28
25
  ## For the word_wrap function
29
- spec.add_dependency "facets"
30
-
31
- # Development dependencies
32
- ## Setup
33
- spec.add_development_dependency "bundler", "~> 1.10"
34
- spec.add_development_dependency "rake", "~> 10.0"
35
- ## Testing
36
- spec.add_development_dependency "rspec"
37
- spec.add_development_dependency "cucumber"
38
- spec.add_development_dependency "aruba"
39
- ## Debugging
40
- spec.add_development_dependency "pry"
41
- spec.add_development_dependency 'pry-stack_explorer'
42
- spec.add_development_dependency 'pry-byebug'
43
- spec.add_development_dependency 'pry-doc'
44
- spec.add_development_dependency 'pry-awesome_print'
26
+ spec.add_dependency 'facets', '~>3.0'
45
27
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "bundler/setup"
4
4
  require "augury"
5
+ # Load up the cli here as well
6
+ require "augury/cli"
5
7
 
6
8
  # You can add fixtures and/or initialization code here to make experimenting
7
9
  # with your gem easier. You can also use a different console, if you like.
@@ -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 CHANGED
@@ -2,6 +2,4 @@
2
2
  set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
 
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
5
+ bundle install --binstubs
@@ -1,7 +1,8 @@
1
- require "augury/version"
1
+ # frozen_string_literal: true
2
+
3
+ require 'augury/version'
2
4
 
3
5
  module Augury
4
- # Your code goes here...
5
6
  end
6
7
 
7
8
  require 'augury/fortune'
@@ -1,27 +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
9
  desc 'generate USERNAME [PATH]', 'Generate a fortune file for the given username'
7
- option :width, :type => :numeric, :aliases => :w
8
- option :append, :type => :boolean, :aliases => :a
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
+
9
46
  def generate(username, *path)
10
47
  path = File.expand_path(path[0] || username)
11
- begin
12
- augury = Augury::Fortune.new(
13
- username,
14
- path,
15
- options['width'],
16
- options['append']
17
- )
18
- rescue Augury::TwitterConfigError => e
19
- puts e.message
20
- exit 1
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(ENV.fetch('AUGURY_CFG_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)
21
79
  end
22
- tweets = augury.tweet_texts
23
- augury.write_fortune(augury.format_fortune(tweets))
24
- puts "Fortune written out to #{path}"
80
+
81
+ Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
25
82
  end
26
83
  end
27
84
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Augury
2
4
  class TwitterConfigError < StandardError
3
5
  def message
4
- "No twitter credential configuration found in the augury config"
6
+ 'No twitter credential configuration found in the augury config'
5
7
  end
6
8
  end
7
9
  end
@@ -1,55 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cgi'
1
4
  require 'facets/string/word_wrap'
2
- require 'parseconfig'
3
5
  require 'twitter'
4
- require 'wannabe_bool'
5
6
 
6
7
  module Augury
7
8
  class Fortune
8
- def initialize(username, path, width=nil, append=nil)
9
- begin
10
- @config = ParseConfig.new(File.expand_path('~/.augury.cfg'))
11
- rescue Errno::EACCES
12
- @config = ParseConfig.new
13
- end
14
-
15
- augury_config = @config.params['augury'] || {}
9
+ def initialize(username, path, config)
16
10
  @username = username
17
11
  @path = path
18
- @width = width || augury_config['width'] || 72
19
- @append = append || augury_config['append'].to_b || false
20
-
21
- twitter_config = @config.params['twitter']
22
- raise Augury::TwitterConfigError unless twitter_config
23
- @twitter = Twitter::REST::Client.new do |config|
24
- config.consumer_key = twitter_config['consumer_key']
25
- config.consumer_secret = twitter_config['consumer_secret']
26
- config.access_token = twitter_config['access_token']
27
- config.access_token_secret = twitter_config['access_token_secret']
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
21
+ elsif !@config[:count].zero? && collection.length >= @config[:count]
22
+ # Get everything or trim the results to the count
23
+ @config[:count].zero? ? collection : collection[0..@config[:count] - 1]
24
+ else
25
+ collect_with_max_id(collection, response.last.id - 1, &block)
28
26
  end
29
27
  end
30
28
 
31
- def tweet_texts
32
- @twitter.user_timeline(@username).flat_map { |tweet| tweet.full_text }
29
+ def retrieve_tweets
30
+ @tweets = collect_with_max_id do |max_id|
31
+ options = {
32
+ count: 200,
33
+ include_rts: @config[:retweets],
34
+ exclude_replies: !@config[:replies],
35
+ }
36
+ options[:max_id] = max_id unless max_id.nil?
37
+ @twitter.user_timeline(@username, options)
38
+ end
39
+ rescue Twitter::Error::TooManyRequests => e
40
+ reset_length = e.rate_limit.reset_in + 1
41
+ puts "Twitter rate limit exceeded. Waiting #{reset_length} minute(s)"
42
+ sleep reset_length
33
43
  end
34
44
 
35
- def format_fortune(tweets)
36
- tweets.flat_map { |tweet| tweet.word_wrap(@width) }.join("%\n")
45
+ def format_fortune
46
+ filtered = @tweets.flat_map(&:full_text).reject do |tweet|
47
+ tweet.match(/https?:/) unless @config[:links]
48
+ end
49
+ formatted = filtered.flat_map { |tweet| CGI.unescapeHTML(tweet).word_wrap(@config[:width]) }
50
+ author = @config[:attribution] ? "\n-- #{@twitter.user(@username).name}\n" : ''
51
+ formatted.join("#{author}%\n")
37
52
  end
38
53
 
39
- def write_fortune(text)
54
+ def write_fortune
40
55
  # Write out the file
41
56
  begin
42
- mode = @append ? 'a' : 'w'
57
+ mode = @config[:append] ? 'a' : 'w'
43
58
  file = File.open(@path, mode)
44
- file.write("%\n") if @append
45
- file.write(text)
46
- rescue IOError => e
47
- puts e
59
+ file.write("%\n") if @config[:append]
60
+ file.write(format_fortune)
48
61
  ensure
49
- file.close unless file.nil?
62
+ file&.close
50
63
  end
51
64
  # Create the dat file too
52
- `strfile #{@path} #{@path}.dat`
65
+ `strfile '#{@path}' '#{@path}.dat'`
66
+ end
67
+
68
+ def twitter_setup
69
+ raise Augury::TwitterConfigError unless @config[:twitter]
70
+
71
+ @twitter = Twitter::REST::Client.new do |cfg|
72
+ cfg.consumer_key = @config[:twitter]['consumer_key']
73
+ cfg.consumer_secret = @config[:twitter]['consumer_secret']
74
+ cfg.access_token = @config[:twitter]['access_token']
75
+ cfg.access_token_secret = @config[:twitter]['access_token_secret']
76
+ end
53
77
  end
54
78
  end
55
79
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Augury
2
- VERSION = "0.2.1"
4
+ VERSION = '1.0.3'
3
5
  end
metadata CHANGED
@@ -1,225 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: augury
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clayton Parker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-20 00:00:00.000000000 Z
11
+ date: 2021-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: parseconfig
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
13
  - !ruby/object:Gem::Dependency
28
14
  name: thor
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - ">="
17
+ - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '0'
19
+ version: 1.0.0
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - ">="
24
+ - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '0'
26
+ version: 1.0.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: twitter
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: wannabe_bool
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: facets
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: bundler
85
29
  requirement: !ruby/object:Gem::Requirement
86
30
  requirements:
87
31
  - - "~>"
88
32
  - !ruby/object:Gem::Version
89
- version: '1.10'
90
- type: :development
33
+ version: '7.0'
34
+ type: :runtime
91
35
  prerelease: false
92
36
  version_requirements: !ruby/object:Gem::Requirement
93
37
  requirements:
94
38
  - - "~>"
95
39
  - !ruby/object:Gem::Version
96
- version: '1.10'
40
+ version: '7.0'
97
41
  - !ruby/object:Gem::Dependency
98
- name: rake
42
+ name: facets
99
43
  requirement: !ruby/object:Gem::Requirement
100
44
  requirements:
101
45
  - - "~>"
102
46
  - !ruby/object:Gem::Version
103
- version: '10.0'
104
- type: :development
47
+ version: '3.0'
48
+ type: :runtime
105
49
  prerelease: false
106
50
  version_requirements: !ruby/object:Gem::Requirement
107
51
  requirements:
108
52
  - - "~>"
109
53
  - !ruby/object:Gem::Version
110
- version: '10.0'
111
- - !ruby/object:Gem::Dependency
112
- name: rspec
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: cucumber
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'
139
- - !ruby/object:Gem::Dependency
140
- name: aruba
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: pry
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: pry-stack_explorer
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: pry-byebug
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: pry-doc
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
- - !ruby/object:Gem::Dependency
210
- name: pry-awesome_print
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - ">="
214
- - !ruby/object:Gem::Version
215
- version: '0'
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - ">="
221
- - !ruby/object:Gem::Version
222
- version: '0'
54
+ version: '3.0'
223
55
  description: This gem turns a twitter feed into a fortune file that you can use with
224
56
  the fortune program
225
57
  email:
@@ -229,16 +61,21 @@ executables:
229
61
  extensions: []
230
62
  extra_rdoc_files: []
231
63
  files:
64
+ - ".codeclimate.yml"
232
65
  - ".gitignore"
233
66
  - ".rspec"
67
+ - ".rubocop.yml"
68
+ - ".solargraph.yml"
234
69
  - ".travis.yml"
70
+ - CHANGELOG.md
235
71
  - Gemfile
72
+ - Gemfile.lock
236
73
  - LICENSE.txt
237
74
  - README.md
238
75
  - Rakefile
239
- - TODO.md
240
76
  - augury.gemspec
241
77
  - bin/console
78
+ - bin/extract_creds
242
79
  - bin/setup
243
80
  - exe/augury
244
81
  - lib/augury.rb
@@ -258,17 +95,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
258
95
  requirements:
259
96
  - - ">="
260
97
  - !ruby/object:Gem::Version
261
- version: '0'
98
+ version: 2.6.0
262
99
  required_rubygems_version: !ruby/object:Gem::Requirement
263
100
  requirements:
264
101
  - - ">="
265
102
  - !ruby/object:Gem::Version
266
103
  version: '0'
267
104
  requirements: []
268
- rubyforge_project:
269
- rubygems_version: 2.4.5
105
+ rubygems_version: 3.1.4
270
106
  signing_key:
271
107
  specification_version: 4
272
108
  summary: Turn a twitter feed into a fortune file
273
109
  test_files: []
274
- has_rdoc:
data/TODO.md DELETED
@@ -1,11 +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
- - Add options for how many tweets to retrieve
8
- - Ask user for twitter config on first start, save it out
9
- - Sign each entry with the name of the twitter account
10
- - Series of regex that could be applied.
11
- This would be a way to make SeinfeldToday dialog get put on their own lines.