alltweets 1.1.3 → 2.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: afdb6ffada5c2f392b6f688516d6aaa9e4b2442f
4
- data.tar.gz: 55b92feec7640055f5b1a0bbb9939426df016210
2
+ SHA256:
3
+ metadata.gz: 92146e6194c50c37002547794b336da5feaf3997909799fb2dc74ff1d1f0bab3
4
+ data.tar.gz: c36a5f0e5275cb84cb6ce09021e5ea56f7ad4132c04d5a6da20d0140a260f402
5
5
  SHA512:
6
- metadata.gz: 275ba472d8dc176c1d0d6b53a2cbcdcb90e7742bfc335a16508505c3f691c636c4c3bbfc64556864090145bdd60f46a212fa7df83813896c70a1ddb5d087360e
7
- data.tar.gz: 3fe5265bc5cdf12735ccf54347345e9a36e4687c7d931fc858519e90368cf8441ddb0f1abc64b12f4601be93ff2af9f35488112451c3ec770e1ff5a8699fbdee
6
+ metadata.gz: a91de2daddb3406b1b2978ae0b09b1bb0dde4a95b5908df89b695fa314e79a16384185c175778874ae1151d1ec745fab621b2d49a64063b0e5cd9c722c4d7abc
7
+ data.tar.gz: df0c149c0261c221b975d0f9036490939ae71022ff52fde833e16be5ae5494f89594211bce0c1b3920f1d79310259f40093cd524b8cc5d70cce0d46804046100
data/CHANGELOG.md ADDED
@@ -0,0 +1,101 @@
1
+ ## [Unreleased]
2
+
3
+ ## [2.0.0] - 2021-06-27
4
+ ### Added
5
+ - Detail the token/secret pair message
6
+ - Add error handling when invalid options are specified
7
+ - Rewrite README
8
+ - We finally added CHANGELOG!
9
+
10
+ ### Changed
11
+ - Include retweets
12
+ - Update dependencies
13
+ - Use rainbow instead of colorize
14
+
15
+ ### Removed
16
+ - Remove `-r, --retweets` options
17
+ - Remove `-y, --yaml` options
18
+ - Remove Ruby code description from README
19
+
20
+ ### Fixed
21
+ - Change the author name
22
+ - Fix failed spec
23
+ - Added standard gem to run lint
24
+
25
+ ## [1.1.3] - 2016-12-10
26
+ ### Changed
27
+ - Update dependencies
28
+
29
+ ## [1.1.2] - 2016-12-10
30
+ ### Changed
31
+ - Update description
32
+
33
+ ### Removed
34
+ - Remove additional dependency and using optparse standard library
35
+
36
+ ### Fixed
37
+ - Add missing requirements
38
+
39
+ ## [1.1.1] - 2016-09-13
40
+ ### Fixed
41
+ - Change settings file permissions to `0600`
42
+
43
+ ## [1.1.0] - 2016-05-11
44
+ ### Added
45
+ - Add Ruby code example to README
46
+
47
+ ### Changed
48
+ - Don't open the browser automatically
49
+ - Rename class name: `Collector` => `Fetcher`
50
+ - Rename method name: `Fetcher#get_all_tweets` => `Fetcher#fetch_all_tweets`
51
+ - Allow `Fetcher#initialize` to be passed `Twitter::REST::Client` as an argument
52
+ - Change default `include_rts` from `false` to `true`. Note that only the default values have been changed when running the Ruby code directly, not when running alltweets from the command line
53
+
54
+ ## [1.0.2] - 2016-03-15
55
+ ### Changed
56
+ - Update description
57
+
58
+ ### Fixed
59
+ - Continue processing even if opening browser is failed
60
+
61
+ ## [1.0.1] - 2016-03-08
62
+ ### Changed
63
+ - Update description
64
+
65
+ ### Removed
66
+ - Remove Oj dependency
67
+
68
+ ### Fixed
69
+ - Fix typo of gemfile homepage URL
70
+
71
+ ## [1.0.0] - 2016-02-04
72
+ ### Changed
73
+ - Update dependencies
74
+ - Print result to stdout instead of a file
75
+ - Change default format from YAML to JSON
76
+ - Print system messages to stderr instead of stdout
77
+
78
+ ### Fixed
79
+ - Show an error if multiple username is given
80
+ - Return a status code 1 if an error occurs
81
+ - Support old Ruby 2.0 syntax
82
+
83
+ ## [0.1.3] - 2015-12-17
84
+ ### Changed
85
+ - Change consumer key/secret
86
+ - Update description
87
+ - Update dependencies
88
+
89
+ ## [0.1.2] - 2015-11-10
90
+ ### Changed
91
+ - Update description
92
+
93
+ ## [0.1.1] - 2015-10-30
94
+ ### Fixed
95
+ - Show an error if username is not specified
96
+ - Change the author name
97
+
98
+
99
+ ## [0.1.0] - 2015-07-29
100
+ ### Added
101
+ - Initial release
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in alltweets.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,62 +1,36 @@
1
- # AllTweets
1
+ # alltweets
2
2
 
3
3
  Downloads someone's all tweets.
4
4
 
5
5
  ## Installation
6
6
 
7
- ```
7
+ ```zsh
8
8
  $ gem install alltweets
9
9
  ```
10
10
 
11
11
  ## Usage
12
12
 
13
- ### Commands
13
+ Just specify the username. The results will be retrieved as JSON data and displayed on the stdout.
14
14
 
15
- * `alltweets [options] SCREEN_NAME`: Download SCREEN_NAME's all tweets.
15
+ ```zsh
16
+ $ alltweets tatzyr > tweets.json
17
+ ```
16
18
 
17
- ### Options
19
+ ## Options
18
20
 
19
- * `-r`, `--retweets`: Include retweets
20
- * `-y`, `--yaml`: Use YAML instead of JSON
21
21
  * `-v`, `--version`: Print version and exit
22
22
  * `-h`, `--help`: Show help message
23
23
 
24
- ### Example
25
-
26
- * `alltweets tatzyr`: Download @tatzyr's all tweets.
27
- * `alltweets -r tatzyr`: Download @tatzyr's all tweets including retweets.
28
- * `alltweets -y tatzyr`: Download @tatzyr's all tweets as YAML instead of JSON.
29
-
30
- ### Using AllTweets from Ruby
31
-
32
- ```ruby
33
- require "alltweets"
24
+ ## Limitations
34
25
 
35
- fetcher = AllTweets::Fetcher.new(
36
- consumer_key: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
37
- consumer_secret: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
38
- access_token: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
39
- access_token_secret: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
40
- )
41
-
42
- # # alternatively
43
- # require "twitter"
44
- # client = Twitter::REST::Client.new(...)
45
- # fetcher = AllTweets::Fetcher.new(client)
46
-
47
- fetcher.fetch_all_tweets("tatzyr")
48
- # => [#<Twitter::Tweet id=...>, #<Twitter::Tweet id=...>, ...]
49
-
50
- fetcher.fetch_all_tweets("tatzyr", include_retweets: false)
51
- # => [#<Twitter::Tweet id=...>, #<Twitter::Tweet id=...>, ...]
52
- ```
26
+ alltweets can only retrieve 3200 tweets due to Twitter API limitations.
53
27
 
54
28
  ## Development
55
29
 
56
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec alltweets` to use the gem in this directory, ignoring other installed copies of this gem.
30
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` and `rake standard` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec alltweets` to use the gem in this directory, ignoring other installed copies of this gem.
57
31
 
58
32
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
59
33
 
60
34
  ## Contributing
61
35
 
62
- Bug reports and pull requests are welcome on GitHub at https://github.com/Tatzyr/alltweets.
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tatzyr/alltweets.
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "standard/rake"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
6
- task :default => :spec
7
+ task default: :spec
data/alltweets.gemspec CHANGED
@@ -1,27 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'alltweets/version'
3
+ require "alltweets/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "alltweets"
8
- spec.version = AllTweets::VERSION
9
- spec.authors = ["Tatsuya Otsuka"]
10
- spec.email = ["tatzyr@gmail.com"]
6
+ spec.name = "alltweets"
7
+ spec.version = AllTweets::VERSION
8
+ spec.authors = ["Tatsuya Otsuka"]
9
+ spec.email = ["tatzyr@gmail.com"]
11
10
 
12
- spec.summary = %q{Downloads someone's all tweets.}
13
- spec.homepage = "https://github.com/Tatzyr/alltweets"
11
+ spec.summary = "Downloads someone's all tweets."
12
+ spec.homepage = "https://github.com/tatzyr/alltweets"
14
13
 
15
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
- spec.bindir = "exe"
17
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
15
+ spec.bindir = "exe"
16
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
17
  spec.require_paths = ["lib"]
19
18
 
20
- spec.add_dependency "colorize", "~> 0.8.1"
21
- spec.add_dependency "oauth", "~> 0.5.1"
22
- spec.add_dependency "twitter", "~> 6.0"
19
+ spec.add_dependency "oauth", "~> 0.5"
20
+ spec.add_dependency "rainbow", "~> 3.0"
21
+ spec.add_dependency "twitter", "~> 7.0"
23
22
 
24
- spec.add_development_dependency "bundler", "~> 1.10"
25
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "bundler", "~> 2.2"
24
+ spec.add_development_dependency "rake", "~> 13.0"
26
25
  spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "standard"
27
27
  end
data/lib/alltweets/cli.rb CHANGED
@@ -1,58 +1,39 @@
1
- require "colorize"
2
1
  require "json"
3
2
  require "optparse"
4
- require "yaml"
3
+ require "rainbow/ext/string"
5
4
  require "alltweets/fetcher"
6
5
  require "alltweets/settings"
7
6
  require "alltweets/version"
8
7
 
9
8
  module AllTweets
10
9
  class CLI
11
- def initialize
10
+ def run
11
+ Rainbow.enabled = true # forcing coloring even when stdout/stderr is not a tty
12
12
  @screen_name, @opts = parse_args
13
13
  @settings = Settings.new
14
14
  update_access_token
15
- @fetcher = Fetcher.new(
16
- consumer_key: @settings.consumer_key,
17
- consumer_secret: @settings.consumer_secret,
18
- access_token: @settings.access_token,
19
- access_token_secret: @settings.access_token_secret
20
- )
21
- end
22
-
23
- def run
24
- warn "Downloading @#{@screen_name}'s all tweets"
25
- result = @fetcher.fetch_all_tweets(@screen_name, include_retweets: @opts["retweets"]).map(&:to_h)
26
-
27
- if @opts["yaml"]
28
- dump_data = YAML.dump(result)
29
- else
30
- dump_data = JSON.dump(result)
31
- end
32
-
33
- puts dump_data
15
+ fetch_and_print
34
16
  rescue
35
- warn "Error: #{$!}".colorize(:red)
17
+ warn "Error: #{$!}".color(:red)
36
18
  exit 1
37
19
  end
38
20
 
39
21
  private
22
+
40
23
  def parse_args
41
- opts = ARGV.getopts("", "retweets", "yaml", "help", "version")
24
+ opts = ARGV.getopts("", "help", "version")
42
25
 
43
26
  if opts["help"]
44
- puts <<EOS
45
- alltweets #{VERSION}
46
-
47
- Usage:
48
- alltweets [options] SCREEN_NAME
49
-
50
- Options:
51
- -r, --retweets Include retweets
52
- -y, --yaml Use YAML instead of JSON
53
- -v, --version Print version and exit
54
- -h, --help Show this message
55
- EOS
27
+ puts <<~EOS
28
+ alltweets #{VERSION}
29
+
30
+ Usage:
31
+ alltweets [options] SCREEN_NAME
32
+
33
+ Options:
34
+ -v, --version Print version and exit
35
+ -h, --help Show this message
36
+ EOS
56
37
  exit
57
38
  end
58
39
 
@@ -80,15 +61,31 @@ EOS
80
61
  )
81
62
  request_token = consumer.get_request_token
82
63
 
83
- warn "1) Open: #{request_token.authorize_url}".colorize(:cyan)
84
- $stderr.print "2) Enter the PIN: ".colorize(:cyan)
64
+ warn "You need to get token/secret pair of Twitter OAuth.".color(:cyan)
65
+ warn "The token/secret pair will be saved to #{@settings.filename}".color(:cyan)
66
+ warn "".color(:cyan)
67
+ warn "1) Open: #{request_token.authorize_url}".color(:cyan)
68
+ $stderr.print "2) Enter the PIN: ".color(:cyan)
85
69
  pin = $stdin.gets.strip
86
70
 
87
71
  access_token = request_token.get_access_token(oauth_verifier: pin)
88
72
 
89
- warn "Saving access token and access token secret to #{@settings.filename}"
90
73
  @settings.add_access_tokens(access_token.token, access_token.secret)
74
+ warn "Saved the token/secret pair to #{@settings.filename}".color(:cyan)
91
75
  end
92
76
  end
77
+
78
+ def fetch_and_print
79
+ fetcher = Fetcher.new(
80
+ consumer_key: @settings.consumer_key,
81
+ consumer_secret: @settings.consumer_secret,
82
+ access_token: @settings.access_token,
83
+ access_token_secret: @settings.access_token_secret
84
+ )
85
+
86
+ warn "Downloading @#{@screen_name}'s all tweets..."
87
+ result = fetcher.fetch_all_tweets(@screen_name).map(&:to_h)
88
+ puts JSON.dump(result)
89
+ end
93
90
  end
94
91
  end
@@ -3,24 +3,25 @@ require "twitter"
3
3
  module AllTweets
4
4
  class Fetcher
5
5
  def initialize(arg)
6
- case arg
6
+ @client = case arg
7
7
  when Hash
8
- @client = Twitter::REST::Client.new(arg)
8
+ Twitter::REST::Client.new(arg)
9
9
  else
10
- @client = arg
10
+ arg
11
11
  end
12
12
  end
13
13
 
14
14
  def fetch_all_tweets(user, include_retweets: true)
15
15
  collect_with_max_id do |max_id|
16
- options = { count: 200, include_rts: include_retweets }
16
+ options = {count: 200, include_rts: include_retweets}
17
17
  options[:max_id] = max_id unless max_id.nil?
18
18
  @client.user_timeline(user, options)
19
19
  end
20
20
  end
21
21
 
22
22
  private
23
- def collect_with_max_id(collection=[], max_id = nil, &block)
23
+
24
+ def collect_with_max_id(collection = [], max_id = nil, &block)
24
25
  response = yield(max_id)
25
26
  collection += response
26
27
  if response.empty?
@@ -5,10 +5,10 @@ module AllTweets
5
5
  class Settings
6
6
  INITIAL_SETTINGS = {
7
7
  consumer_key: "GyRoi6Jx4T4olW1Rfwgfaa5kv",
8
- consumer_secret: "OHx2XugBhtg7kuI4yaPANXh3rplREN0Si8CoLzVWYpkeDyH3NJ",
8
+ consumer_secret: "OHx2XugBhtg7kuI4yaPANXh3rplREN0Si8CoLzVWYpkeDyH3NJ"
9
9
  }
10
10
 
11
- def initialize(filename = File.expand_path('~/.alltweets'))
11
+ def initialize(filename = File.expand_path("~/.alltweets"))
12
12
  @filename = filename
13
13
  @settings = load_file
14
14
  end
@@ -32,6 +32,7 @@ module AllTweets
32
32
  end
33
33
 
34
34
  private
35
+
35
36
  def load_file
36
37
  return INITIAL_SETTINGS unless exist?
37
38
 
@@ -39,7 +40,7 @@ module AllTweets
39
40
  end
40
41
 
41
42
  def dump_file
42
- open(@filename, "w", 0600) do |f|
43
+ File.open(@filename, "w", 0o600) do |f|
43
44
  YAML.dump(@settings, f)
44
45
  end
45
46
  end
@@ -1,3 +1,3 @@
1
1
  module AllTweets
2
- VERSION = "1.1.3"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,85 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alltweets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tatsuya Otsuka
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-10 00:00:00.000000000 Z
11
+ date: 2021-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: colorize
14
+ name: oauth
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.1
19
+ version: '0.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.1
26
+ version: '0.5'
27
27
  - !ruby/object:Gem::Dependency
28
- name: oauth
28
+ name: rainbow
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.5.1
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.5.1
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: twitter
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '6.0'
47
+ version: '7.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '6.0'
54
+ version: '7.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.10'
61
+ version: '2.2'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.10'
68
+ version: '2.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +94,21 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description:
97
+ - !ruby/object:Gem::Dependency
98
+ name: standard
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
+ description:
98
112
  email:
99
113
  - tatzyr@gmail.com
100
114
  executables:
@@ -104,7 +118,7 @@ extra_rdoc_files: []
104
118
  files:
105
119
  - ".gitignore"
106
120
  - ".rspec"
107
- - ".travis.yml"
121
+ - CHANGELOG.md
108
122
  - Gemfile
109
123
  - LICENSE
110
124
  - README.md
@@ -118,10 +132,10 @@ files:
118
132
  - lib/alltweets/fetcher.rb
119
133
  - lib/alltweets/settings.rb
120
134
  - lib/alltweets/version.rb
121
- homepage: https://github.com/Tatzyr/alltweets
135
+ homepage: https://github.com/tatzyr/alltweets
122
136
  licenses: []
123
137
  metadata: {}
124
- post_install_message:
138
+ post_install_message:
125
139
  rdoc_options: []
126
140
  require_paths:
127
141
  - lib
@@ -136,9 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
150
  - !ruby/object:Gem::Version
137
151
  version: '0'
138
152
  requirements: []
139
- rubyforge_project:
140
- rubygems_version: 2.6.8
141
- signing_key:
153
+ rubygems_version: 3.2.21
154
+ signing_key:
142
155
  specification_version: 4
143
156
  summary: Downloads someone's all tweets.
144
157
  test_files: []
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.2
4
- before_install: gem install bundler -v 1.10.6