augury 0.3.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a0c7c48771363a9a5c848e76b7747bf9b5d9fbd3
4
- data.tar.gz: 2dd47ecc12e320134c3ce249f64e088a436a1a4e
2
+ SHA256:
3
+ metadata.gz: dde4ab6e3cfe2e7942e603cecbd45b49c74080b37923bdc050426e769ce9241b
4
+ data.tar.gz: e820b4fee8dba782143f93ac761d1bbdee9743e82108425d32c864d19255cb6d
5
5
  SHA512:
6
- metadata.gz: 8afece52e31616184f74750ae3eee61eca34ef30a7582ffac4f9777b3515cbea1e84d94e5610a4a2f1b1bb075cd64d1bb77358a564bded2a9251d83e26aa917e
7
- data.tar.gz: c5ad6b4b98c483fca41f513f29e201f0b9a13b1f0bd9b31c3f34e725179d4b52b28ca98bae506169111e5e64ebdadaccbfd8ca75df5cebba73d30646e008dbb7
6
+ metadata.gz: 4ebf89891a5f7b535aa8fe76fd1b08e055fde4530e326442743741c0476842c65440361cc651672509d6ca56ec3236ba60b70d1a9e613b76e83e30c4631c5411
7
+ data.tar.gz: afc5e614422f71e30e8e16492eb7679d2d659759a7adad9d2d506648e2c01410c90c6d73851fbe9ae035ad3cf04f75c44f179470ffa8633a85fb8f05d9d40118
@@ -0,0 +1,13 @@
1
+ ---
2
+ plugins:
3
+ fixme:
4
+ enabled: true
5
+ rubocop:
6
+ enabled: true
7
+ channel: rubocop-0-92
8
+ ratings:
9
+ paths:
10
+ - "**.rb"
11
+ exclude_paths:
12
+ - features/**/*
13
+ - spec/**/*
data/.gitignore CHANGED
@@ -1,11 +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
11
10
  /bin/*
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
@@ -1,5 +1,12 @@
1
1
  # Changes
2
2
 
3
+ ## 1.0.0 (2020-01-08)
4
+
5
+ - Convert augury config from ini style to yaml (breaking change)
6
+ - Add options for filtering out tweets (retweets, replies, links)
7
+ - Add option to show twitter user name as an attribution
8
+ - Ensure output has not html entities in it
9
+
3
10
  ## 0.3.0 (2015-08-20)
4
11
 
5
12
  - Add `count` option and allow for a user to get all tweets
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'
@@ -0,0 +1,176 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ augury (1.0.0)
5
+ equalizer (~> 0.0)
6
+ facets (~> 3.0)
7
+ thor (~> 1.0)
8
+ twitter (~> 7.0)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ addressable (2.7.0)
14
+ public_suffix (>= 2.0.2, < 5.0)
15
+ ast (2.4.1)
16
+ awesome_print (1.8.0)
17
+ backport (1.1.2)
18
+ benchmark (0.1.1)
19
+ buftok (0.2.0)
20
+ byebug (11.1.3)
21
+ coderay (1.1.3)
22
+ crack (0.4.5)
23
+ rexml
24
+ diff-lcs (1.4.4)
25
+ docile (1.3.4)
26
+ domain_name (0.5.20190701)
27
+ unf (>= 0.0.5, < 1.0.0)
28
+ e2mmap (0.1.0)
29
+ equalizer (0.0.11)
30
+ facets (3.1.0)
31
+ ffi (1.14.2)
32
+ ffi-compiler (1.0.1)
33
+ ffi (>= 1.0.0)
34
+ rake
35
+ hashdiff (1.0.1)
36
+ http (4.4.1)
37
+ addressable (~> 2.3)
38
+ http-cookie (~> 1.0)
39
+ http-form_data (~> 2.2)
40
+ http-parser (~> 1.2.0)
41
+ http-cookie (1.0.3)
42
+ domain_name (~> 0.5)
43
+ http-form_data (2.3.0)
44
+ http-parser (1.2.2)
45
+ ffi-compiler
46
+ http_parser.rb (0.6.0)
47
+ jaro_winkler (1.5.4)
48
+ kramdown (2.3.0)
49
+ rexml
50
+ kramdown-parser-gfm (1.1.0)
51
+ kramdown (~> 2.0)
52
+ memoizable (0.4.2)
53
+ thread_safe (~> 0.3, >= 0.3.1)
54
+ method_source (1.0.0)
55
+ mini_portile2 (2.5.0)
56
+ multipart-post (2.1.1)
57
+ naught (1.1.0)
58
+ nokogiri (1.11.1)
59
+ mini_portile2 (~> 2.5.0)
60
+ racc (~> 1.4)
61
+ parallel (1.20.1)
62
+ parser (2.7.2.0)
63
+ ast (~> 2.4.1)
64
+ pry (0.13.1)
65
+ coderay (~> 1.1)
66
+ method_source (~> 1.0)
67
+ pry-awesome_print (9.6.11)
68
+ awesome_print (>= 1.1.0, < 999)
69
+ pry (>= 0.9.0, < 999)
70
+ pry-byebug (3.9.0)
71
+ byebug (~> 11.0)
72
+ pry (~> 0.13.0)
73
+ public_suffix (4.0.6)
74
+ racc (1.5.2)
75
+ rainbow (3.0.0)
76
+ rake (13.0.3)
77
+ regexp_parser (2.0.3)
78
+ reverse_markdown (2.0.0)
79
+ nokogiri
80
+ rexml (3.2.4)
81
+ rspec (3.10.0)
82
+ rspec-core (~> 3.10.0)
83
+ rspec-expectations (~> 3.10.0)
84
+ rspec-mocks (~> 3.10.0)
85
+ rspec-core (3.10.1)
86
+ rspec-support (~> 3.10.0)
87
+ rspec-expectations (3.10.1)
88
+ diff-lcs (>= 1.2.0, < 2.0)
89
+ rspec-support (~> 3.10.0)
90
+ rspec-mocks (3.10.1)
91
+ diff-lcs (>= 1.2.0, < 2.0)
92
+ rspec-support (~> 3.10.0)
93
+ rspec-support (3.10.1)
94
+ rubocop (0.92.0)
95
+ parallel (~> 1.10)
96
+ parser (>= 2.7.1.5)
97
+ rainbow (>= 2.2.2, < 4.0)
98
+ regexp_parser (>= 1.7)
99
+ rexml
100
+ rubocop-ast (>= 0.5.0)
101
+ ruby-progressbar (~> 1.7)
102
+ unicode-display_width (>= 1.4.0, < 2.0)
103
+ rubocop-ast (1.4.0)
104
+ parser (>= 2.7.1.5)
105
+ rubocop-rake (0.5.1)
106
+ rubocop
107
+ rubocop-rspec (1.44.1)
108
+ rubocop (~> 0.87)
109
+ rubocop-ast (>= 0.7.1)
110
+ ruby-progressbar (1.11.0)
111
+ simple_oauth (0.3.1)
112
+ simplecov (0.21.1)
113
+ docile (~> 1.1)
114
+ simplecov-html (~> 0.11)
115
+ simplecov_json_formatter (~> 0.1)
116
+ simplecov-html (0.12.3)
117
+ simplecov_json_formatter (0.1.2)
118
+ solargraph (0.40.1)
119
+ backport (~> 1.1)
120
+ benchmark
121
+ bundler (>= 1.17.2)
122
+ e2mmap
123
+ jaro_winkler (~> 1.5)
124
+ kramdown (~> 2.3)
125
+ kramdown-parser-gfm (~> 1.1)
126
+ parser (~> 2.3)
127
+ reverse_markdown (>= 1.0.5, < 3)
128
+ rubocop (>= 0.52)
129
+ thor (~> 1.0)
130
+ tilt (~> 2.0)
131
+ yard (~> 0.9, >= 0.9.24)
132
+ thor (1.0.1)
133
+ thread_safe (0.3.6)
134
+ tilt (2.0.10)
135
+ twitter (7.0.0)
136
+ addressable (~> 2.3)
137
+ buftok (~> 0.2.0)
138
+ equalizer (~> 0.0.11)
139
+ http (~> 4.0)
140
+ http-form_data (~> 2.0)
141
+ http_parser.rb (~> 0.6.0)
142
+ memoizable (~> 0.4.0)
143
+ multipart-post (~> 2.0)
144
+ naught (~> 1.0)
145
+ simple_oauth (~> 0.3.0)
146
+ unf (0.1.4)
147
+ unf_ext
148
+ unf_ext (0.0.7.7)
149
+ unicode-display_width (1.7.0)
150
+ vcr (6.0.0)
151
+ webmock (3.11.0)
152
+ addressable (>= 2.3.6)
153
+ crack (>= 0.3.2)
154
+ hashdiff (>= 0.4.0, < 2.0.0)
155
+ yard (0.9.26)
156
+
157
+ PLATFORMS
158
+ ruby
159
+
160
+ DEPENDENCIES
161
+ augury!
162
+ pry
163
+ pry-awesome_print
164
+ pry-byebug
165
+ rake
166
+ rspec (~> 3.0)
167
+ rubocop (= 0.92)
168
+ rubocop-rake
169
+ rubocop-rspec
170
+ simplecov
171
+ solargraph
172
+ vcr
173
+ webmock
174
+
175
+ BUNDLED WITH
176
+ 2.1.4
data/README.md CHANGED
@@ -1,31 +1,35 @@
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
10
  <blockquote>
7
11
  Augury is the practice from ancient Roman religion of<br>
8
12
  interpreting omens from the observed flight of birds.<br><br>
9
- As per [Wikipedia](https://en.wikipedia.org/wiki/Augury)
13
+ As per <a href="https://en.wikipedia.org/wiki/Augury">Wikipedia</a>
10
14
  </blockquote>
11
15
 
12
16
  There are a lot of really funny twitter accounts out there.
13
17
  Let's just pick one and get started.
14
18
 
15
- ```
19
+ ```sh
16
20
  $ augury generate seinfeldtoday
17
21
  ```
18
22
 
19
23
  This just created the fortune files in the current directory:
20
24
 
21
- ```
25
+ ```sh
22
26
  $ ls
23
27
  seinfeldtoday seinfeldtoday.dat
24
28
  ```
25
29
 
26
30
  You can now read the new fortunes!
27
31
 
28
- ```
32
+ ```sh
29
33
  $ fortune seinfeldtoday
30
34
  Elaine has no idea what her BF does for a living and it's now too
31
35
  late to ask. E:"Teacher, I think. Or a doctor? Wait Is
@@ -51,13 +55,13 @@ gem 'augury'
51
55
 
52
56
  And then execute:
53
57
 
54
- ```
58
+ ```sh
55
59
  $ bundle
56
60
  ```
57
61
 
58
62
  Or install it yourself as:
59
63
 
60
- ```
64
+ ```sh
61
65
  $ gem install augury
62
66
  ```
63
67
 
@@ -69,7 +73,7 @@ The fortune program ships with a `strfile` program that converts the plain text
69
73
  For example,
70
74
  if you are using Homebrew on OS X:
71
75
 
72
- ```
76
+ ```sh
73
77
  $ brew install fortune
74
78
  ```
75
79
 
@@ -86,62 +90,66 @@ $ chmod 600 ~/.augury.cfg
86
90
 
87
91
  Set any of these settings in the `augury` section of the config like this:
88
92
 
89
- ```ini
90
- [augury]
91
- example_option = "An interesting value"
93
+ ```yaml
94
+ count: 20
95
+ attribution: true
92
96
  ```
93
97
 
94
98
  ### Option list
95
99
 
96
- These are the available options for the `~/.augury.cfg`
100
+ These are the available options for the `~/.augury.yml` config file.
97
101
 
98
102
  Option | Description | Default
99
103
  ------ | :---------- | -------
100
104
  `append` | Make the script add more entries to the specified file instead of re-writing it | `false`
101
105
  `width` | Set the default width used if none is given on the command line. | `72`
102
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`
103
111
 
104
112
  ### Twitter Setup
105
113
 
106
114
  First, you will need to create a new Twitter application by going here:
107
- https://apps.twitter.com
115
+ https://developer.twitter.com
108
116
 
109
117
  This will give you the ability to generate the consumer and access information used below.
110
118
 
111
- Add the following to your `~/.augury.cfg` file.
119
+ Add the following to your `~/.augury.yml` config.
112
120
 
113
- ```ini
114
- [twitter]
115
- consumer_key = "YOUR_CONSUMER_KEY"
116
- consumer_secret = "YOUR_CONSUMER_SECRET"
117
- access_token = "YOUR_ACCESS_TOKEN"
118
- 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
119
127
  ```
120
128
 
121
129
  ## Usage
122
130
 
123
131
  Create a fortune for the latest *seinfeldtoday* tweets.
124
132
 
125
- ```
133
+ ```sh
126
134
  $ augury generate seinfeldtoday
127
135
  ```
128
136
 
129
137
  Now you have some fortunes.
130
138
 
131
- ```
139
+ ```sh
132
140
  $ fortune seinfeldtoday
133
141
  ```
134
142
 
135
143
  Specify a width and a different path to use:
136
144
 
137
- ```
145
+ ```sh
138
146
  $ augury generate -w 120 seinfeldtoday /usr/local/share/games/fortune/Modern\ Seinfeld
139
147
  ```
140
148
 
141
149
  If this is where your fortune program looks for fortunes,
142
150
  you can now use the new fortune.
143
151
 
144
- ```
152
+ ```sh
145
153
  $ fortune "Modern Seinfeld"
146
154
  ```
147
155
 
@@ -149,9 +157,9 @@ $ fortune "Modern Seinfeld"
149
157
 
150
158
  Run the help to get more details about what the program can do
151
159
 
152
- ```
153
- $ bin/augury help
154
- $ bin/augury help generate
160
+ ```sh
161
+ $ augury help
162
+ $ augury help generate
155
163
  ```
156
164
 
157
165
  ## Development
@@ -161,7 +169,7 @@ do the following.
161
169
 
162
170
  Create a fork, then get the code
163
171
 
164
- ```
172
+ ```sh
165
173
  $ git clone git@github.com:YOUR_USERNAME/augury.git
166
174
  $ cd augury
167
175
  ```
@@ -171,29 +179,29 @@ Run the setup script to get everything installed:
171
179
  **NOTE**: This requires having bundler available.
172
180
  That is beyond the scope of this README.
173
181
 
174
- ```
182
+ ```sh
175
183
  $ bin/setup
176
184
  ```
177
185
 
178
186
  Once that is finished, there is a console available.
179
187
  This gives you access to all the code via Pry.
180
188
 
181
- ```
189
+ ```sh
182
190
  $ bin/console
183
191
  ```
184
192
 
185
- The `augury` command will be available in bin:
193
+ The `augury` command will be available in `exe`:
186
194
 
187
- ```
188
- $ bin/augury help
195
+ ```sh
196
+ $ bundle exec ruby exe/augury help
189
197
  ```
190
198
 
191
199
  ### Run the tests
192
200
 
193
201
  You can run the tests with the rake task:
194
202
 
195
- ```
196
- $ rake spec
203
+ ```sh
204
+ $ bundle exec rake spec
197
205
  ```
198
206
 
199
207
  ## Contributing
@@ -209,7 +217,7 @@ The gem is available as open source under the terms of the [MIT License](http://
209
217
  Thanks to [TinderBox](http://gettinderbox.com) for giving us time to make cool things happen!
210
218
 
211
219
  This was an excellent learning experience for the author,
212
- who is new at programming in Ruby.
220
+ who was new at programming in Ruby.
213
221
 
214
222
  The [Developing a RubyGem using Bundler][gemdocs] documentation was fun to read and informative.
215
223
  It helped get the skeleton of the code set up and extra goodies in the development profile.
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
data/TODO.md CHANGED
@@ -5,7 +5,6 @@ Some ideas for things that could be added:
5
5
  - Add an option to limit the tweets from a certain date forward.
6
6
  This would allow for adding the latest tweets via cron.
7
7
  - Ask user for twitter config on first start, save it out
8
- - Sign each entry with the name of the twitter account
9
8
  - Series of regex that could be applied.
10
9
  This would be a way to make SeinfeldToday dialog get put on their own lines.
11
10
  - Different word wrapping options. To a width, or by sentence, or whatever.
@@ -1,45 +1,28 @@
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'
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 'equalizer', '~>0.0'
27
+ spec.add_dependency 'facets', '~>3.0'
45
28
  end
@@ -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,35 +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'
10
+
7
11
  option :width,
8
- :type => :numeric, :aliases => '-w',
9
- :desc => 'The maximum number of columns that will be written on a line. DEFAULT: 72'
12
+ type: :numeric,
13
+ aliases: '-w',
14
+ desc: 'The maximum number of columns that will be written on a line. DEFAULT: 72'
15
+
10
16
  option :append,
11
- :type => :boolean, :aliases => '-a',
12
- :desc => 'If set, the target path will be appended to instead of overwritten'
17
+ type: :boolean,
18
+ aliases: '-a',
19
+ desc: 'If set, the target path will be appended to instead of overwritten'
20
+
13
21
  option :count,
14
- :type => :numeric, :aliases => '-c',
15
- :desc => 'The number of tweets to get. Set to 0 to get all. DEFAULT: 200'
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
+
16
46
  def generate(username, *path)
17
- begin
18
- path = File.expand_path(path[0] || username)
19
- augury = Augury::Fortune.new(
20
- username,
21
- path,
22
- options['width'],
23
- options['append'],
24
- options['count'],
25
- )
26
- augury.write_fortune
27
- self.say "Fortune written out to #{path}"
28
- rescue => e
29
- self.say "There was an error running the command. Details below:"
30
- self.say e.message
31
- exit 1
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)
32
79
  end
80
+
81
+ Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
33
82
  end
34
83
  end
35
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,81 +1,78 @@
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, count=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).to_i
19
- @append = (append || augury_config['append'] || false).to_b
20
- @count = (count || augury_config['count'] || 200).to_i
21
-
22
- twitter_config = @config.params['twitter']
23
- raise Augury::TwitterConfigError unless twitter_config
24
- @twitter = Twitter::REST::Client.new do |config|
25
- config.consumer_key = twitter_config['consumer_key']
26
- config.consumer_secret = twitter_config['consumer_secret']
27
- config.access_token = twitter_config['access_token']
28
- config.access_token_secret = twitter_config['access_token_secret']
29
- end
12
+ @config = config
13
+ @tweets = []
30
14
  end
31
15
 
32
- def collect_with_max_id(collection=[], max_id=nil, &block)
16
+ def collect_with_max_id(collection = [], max_id = nil, &block)
33
17
  response = yield(max_id)
34
18
  collection += response
35
19
  if response.empty?
36
20
  collection.flatten
37
- elsif ! @count.zero? && collection.length >= @count
21
+ elsif !@config[:count].zero? && collection.length >= @config[:count]
38
22
  collection.flatten
39
23
  else
40
24
  collect_with_max_id(collection, response.last.id - 1, &block)
41
25
  end
42
26
  end
43
27
 
44
- def tweets
45
- begin
46
- collect_with_max_id do |max_id|
47
- options = {
48
- count: @count.zero? ? 200 : @count,
49
- include_rts: true,
50
- }
51
- options[:max_id] = max_id unless max_id.nil?
52
- @twitter.user_timeline(@username, options)
53
- end
54
- rescue Twitter::Error::TooManyRequests => e
55
- reset_length = e.rate_limit.reset_in + 1
56
- puts "Twitter rate limit exceeded. Waiting #{reset_length} minute(s)"
57
- sleep reset_length
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)
58
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
59
42
  end
60
43
 
61
44
  def format_fortune
62
- tweet_texts = self.tweets.flat_map { |tweet| tweet.full_text }
63
- tweet_texts.flat_map { |tweet| tweet.word_wrap(@width) }.join("%\n")
45
+ filtered = @tweets.flat_map(&:full_text).reject do |tweet|
46
+ tweet.match(/https?:/) unless @config[:links]
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")
64
51
  end
65
52
 
66
53
  def write_fortune
67
- text = self.format_fortune
68
54
  # Write out the file
69
55
  begin
70
- mode = @append ? 'a' : 'w'
56
+ mode = @config[:append] ? 'a' : 'w'
71
57
  file = File.open(@path, mode)
72
- file.write("%\n") if @append
73
- file.write(text)
58
+ file.write("%\n") if @config[:append]
59
+ file.write(format_fortune)
74
60
  ensure
75
- file.close unless file.nil?
61
+ file&.close
76
62
  end
77
63
  # Create the dat file too
78
64
  `strfile '#{@path}' '#{@path}.dat'`
79
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
76
+ end
80
77
  end
81
78
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Augury
2
- VERSION = "0.3.0"
4
+ VERSION = '1.0.0'
3
5
  end
metadata CHANGED
@@ -1,225 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: augury
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clayton Parker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-21 00:00:00.000000000 Z
11
+ date: 2021-01-08 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'
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'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: twitter
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  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
- - - ">="
31
+ - - "~>"
74
32
  - !ruby/object:Gem::Version
75
- version: '0'
33
+ version: '7.0'
76
34
  type: :runtime
77
35
  prerelease: false
78
36
  version_requirements: !ruby/object:Gem::Requirement
79
37
  requirements:
80
- - - ">="
38
+ - - "~>"
81
39
  - !ruby/object:Gem::Version
82
- version: '0'
40
+ version: '7.0'
83
41
  - !ruby/object:Gem::Dependency
84
- name: bundler
42
+ name: equalizer
85
43
  requirement: !ruby/object:Gem::Requirement
86
44
  requirements:
87
45
  - - "~>"
88
46
  - !ruby/object:Gem::Version
89
- version: '1.10'
90
- type: :development
47
+ version: '0.0'
48
+ type: :runtime
91
49
  prerelease: false
92
50
  version_requirements: !ruby/object:Gem::Requirement
93
51
  requirements:
94
52
  - - "~>"
95
53
  - !ruby/object:Gem::Version
96
- version: '1.10'
54
+ version: '0.0'
97
55
  - !ruby/object:Gem::Dependency
98
- name: rake
56
+ name: facets
99
57
  requirement: !ruby/object:Gem::Requirement
100
58
  requirements:
101
59
  - - "~>"
102
60
  - !ruby/object:Gem::Version
103
- version: '10.0'
104
- type: :development
61
+ version: '3.0'
62
+ type: :runtime
105
63
  prerelease: false
106
64
  version_requirements: !ruby/object:Gem::Requirement
107
65
  requirements:
108
66
  - - "~>"
109
67
  - !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'
68
+ version: '3.0'
223
69
  description: This gem turns a twitter feed into a fortune file that you can use with
224
70
  the fortune program
225
71
  email:
@@ -229,11 +75,15 @@ executables:
229
75
  extensions: []
230
76
  extra_rdoc_files: []
231
77
  files:
78
+ - ".codeclimate.yml"
232
79
  - ".gitignore"
233
80
  - ".rspec"
81
+ - ".rubocop.yml"
82
+ - ".solargraph.yml"
234
83
  - ".travis.yml"
235
84
  - CHANGELOG.md
236
85
  - Gemfile
86
+ - Gemfile.lock
237
87
  - LICENSE.txt
238
88
  - README.md
239
89
  - Rakefile
@@ -259,17 +109,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
259
109
  requirements:
260
110
  - - ">="
261
111
  - !ruby/object:Gem::Version
262
- version: '0'
112
+ version: 2.6.0
263
113
  required_rubygems_version: !ruby/object:Gem::Requirement
264
114
  requirements:
265
115
  - - ">="
266
116
  - !ruby/object:Gem::Version
267
117
  version: '0'
268
118
  requirements: []
269
- rubyforge_project:
270
- rubygems_version: 2.4.5
119
+ rubygems_version: 3.1.4
271
120
  signing_key:
272
121
  specification_version: 4
273
122
  summary: Turn a twitter feed into a fortune file
274
123
  test_files: []
275
- has_rdoc: