twiterator 0.1.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 +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/Rakefile +6 -0
- data/bin/console +17 -0
- data/bin/setup +8 -0
- data/lib/.DS_Store +0 -0
- data/lib/twiterator/reply.rb +34 -0
- data/lib/twiterator/tweet.rb +71 -0
- data/lib/twiterator/twiterator-cli.rb +154 -0
- data/lib/twiterator/user.rb +86 -0
- data/lib/twiterator/verification.rb +19 -0
- data/lib/twiterator/version.rb +3 -0
- data/lib/twiterator.rb +11 -0
- data/twiterator.gemspec +42 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 78fa77a41b595a217f16a1cd237218bd27a29265
|
4
|
+
data.tar.gz: e5e48ce49f3f2bb810715d78424513e820adae92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '018fdc8ce330a0b8e099e07d36bd5101a40e6c11a5393d93840385d82489b7acc891d3ae5d710f4007fee7f79f968e64b19d1472963cdfa2551907ad5df1a7a9'
|
7
|
+
data.tar.gz: 5f5242f3a727a13856c4ba276abfaabec3e3b14465091879677212f21722bf0e711ddf716e69966c619caaee3bcc922b60b5a65cb7b2f730f9e1287e323b07bb
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at TODO: Write your email address. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Alexander Glover
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Twiterator
|
2
|
+
|
3
|
+
Welcome to Twiterator, a simple CLI browser for the popular social networking site, twitter.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'twiterator'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install twiterator
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
To use Twiterator, run bin/console and follow whatever instructions show up on the screen. It's pretty simple.
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[gloverab]/twiterator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
28
|
+
|
29
|
+
|
30
|
+
## License
|
31
|
+
|
32
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "twiterator"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
TwiteratorCLI.new
|
14
|
+
|
15
|
+
|
16
|
+
require "irb"
|
17
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Reply
|
2
|
+
attr_accessor :parent_tweet, :reply_number, :author, :content
|
3
|
+
|
4
|
+
def initialize(index, parent_tweet)
|
5
|
+
@index = index
|
6
|
+
@parent_tweet = parent_tweet
|
7
|
+
end
|
8
|
+
|
9
|
+
def author
|
10
|
+
@author = self.parent_tweet.doc.css('.stream-items b')[@index].text
|
11
|
+
end
|
12
|
+
|
13
|
+
def content
|
14
|
+
@content = self.parent_tweet.doc.css('.stream-items p')[@index].text
|
15
|
+
end
|
16
|
+
|
17
|
+
def time
|
18
|
+
#binding.pry
|
19
|
+
self.parent_tweet.doc.css('.stream-items .stream-item-header .time a')[@index].values[2].split(" - ")[0]
|
20
|
+
end
|
21
|
+
|
22
|
+
def date
|
23
|
+
self.parent_tweet.doc.css('.stream-items .stream-item-header .time a')[@index].values[2].split(" - ")[1]
|
24
|
+
end
|
25
|
+
|
26
|
+
def show_five
|
27
|
+
puts "\n#{self.display_name.upcase}'S MOST RECENT TWEETS:\n"
|
28
|
+
@counter = 0
|
29
|
+
until self.counter == 5
|
30
|
+
tweet_cycle
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
class Tweet
|
2
|
+
attr_accessor :replies, :reply_counter
|
3
|
+
attr_reader :html, :doc, :url, :user
|
4
|
+
|
5
|
+
def initialize(url, user=nil)
|
6
|
+
@html = open(url)
|
7
|
+
@doc = Nokogiri::HTML(html)
|
8
|
+
@url = url
|
9
|
+
@user = user
|
10
|
+
# Had these as setter/getters but it was more efficient to scale them down into methods:
|
11
|
+
# @content = doc.css('.js-tweet-text-container p')[0].text
|
12
|
+
# @display_name = doc.css('.permalink-header fullname').text
|
13
|
+
# @user_name = doc.css('.js-action-profile-name b')[0].text.strip
|
14
|
+
# @time = doc.css('.client-and-actions').text.strip.split(" - ")[0]
|
15
|
+
# @date = doc.css('.client-and-actions').text.strip.split(" - ")[1]
|
16
|
+
@replies = []
|
17
|
+
# @retweets = doc.css('.request-retweeted-popup strong').text
|
18
|
+
# @likes = doc.css('.js-stat-favorites strong').text
|
19
|
+
end
|
20
|
+
|
21
|
+
def content
|
22
|
+
doc.css('.js-tweet-text-container p')[0].text
|
23
|
+
end
|
24
|
+
|
25
|
+
def display_name
|
26
|
+
doc.css('.permalink-header fullname').text
|
27
|
+
end
|
28
|
+
|
29
|
+
def user_name
|
30
|
+
doc.css('.js-action-profile-name b')[0].text.strip
|
31
|
+
end
|
32
|
+
|
33
|
+
def time
|
34
|
+
doc.css('.client-and-actions').text.strip.split(" - ")[0]
|
35
|
+
end
|
36
|
+
|
37
|
+
def date
|
38
|
+
doc.css('.client-and-actions').text.strip.split(" - ")[1]
|
39
|
+
end
|
40
|
+
|
41
|
+
def retweets
|
42
|
+
doc.css('.request-retweeted-popup strong').text
|
43
|
+
end
|
44
|
+
|
45
|
+
def likes
|
46
|
+
doc.css('.js-stat-favorites strong').text
|
47
|
+
end
|
48
|
+
|
49
|
+
def reply_count
|
50
|
+
self.doc.css('.ProfileTweet-actionCount')[0].text.strip.gsub(/[^0-9]/, "").to_i
|
51
|
+
end
|
52
|
+
|
53
|
+
def retweeted?
|
54
|
+
self.user_name.downcase != self.user.user_name.downcase || false
|
55
|
+
end
|
56
|
+
|
57
|
+
def set_replies
|
58
|
+
reply_counter = 0
|
59
|
+
#binding.pry
|
60
|
+
# The code snippet in "reply_count" reads off the number of replies that there are, then would have helped this method loop for exactly that many times. Sadly, twitter only displays 15 replies to ruby, so I had to settle for a 15-iteration loop. So now the method just checks to see if the reply count is UNDER 15.
|
61
|
+
(reply_count < 15 ? reply_count : 16).times do
|
62
|
+
parent_tweet = self
|
63
|
+
self.replies << Reply.new(reply_counter, parent_tweet)
|
64
|
+
reply_counter += 1
|
65
|
+
end
|
66
|
+
self.replies.pop
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
#Tweet.new('https://twitter.com/whoisMGMT/status/825122373749841920').set_replies
|
@@ -0,0 +1,154 @@
|
|
1
|
+
class TwiteratorCLI
|
2
|
+
|
3
|
+
attr_accessor :doc, :user, :tweet
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
puts " "
|
7
|
+
puts "************ | TWITERATOR 0.1.0 | ************"
|
8
|
+
puts " "
|
9
|
+
puts "\nHi there! I'm Twiterator, a Ruby cli scraper for"
|
10
|
+
puts "the popular social networking site, Twitter."
|
11
|
+
puts "You can type a twitter handle (or search for one!), and I will"
|
12
|
+
puts "display that user's basic info along with their most"
|
13
|
+
puts "recent tweets. From there, you'll be able to dive into"
|
14
|
+
puts "each tweet and play around until your thirst for"
|
15
|
+
puts "knowledge of the twitterverse is quenched."
|
16
|
+
new_user_menu
|
17
|
+
end
|
18
|
+
|
19
|
+
def new_user_menu
|
20
|
+
puts "\nPlease enter a twitter handle or search for the user you're thinking of."
|
21
|
+
puts "(ex. 'kanyewest' or 'President of Mexico')"
|
22
|
+
user = gets.chomp
|
23
|
+
if not_verified(user)
|
24
|
+
search_possible(user)
|
25
|
+
display_possible
|
26
|
+
new_user_menu
|
27
|
+
else
|
28
|
+
@user = User.new(user)
|
29
|
+
end
|
30
|
+
display_profile
|
31
|
+
end
|
32
|
+
|
33
|
+
def not_verified(user)
|
34
|
+
new_verify = Verification.new(user)
|
35
|
+
new_verify.verify == false
|
36
|
+
end
|
37
|
+
|
38
|
+
def search_possible(user)
|
39
|
+
formatted_user = user.gsub(' ', '%20')
|
40
|
+
html = open("https://twitter.com/search?f=users&q=#{formatted_user}&src=typd")
|
41
|
+
@doc = Nokogiri::HTML(html)
|
42
|
+
end
|
43
|
+
|
44
|
+
def display_possible
|
45
|
+
counter = 0
|
46
|
+
puts " "
|
47
|
+
puts "Hmm, that's not a twitter handle, but here are some users you might have been looking for:"
|
48
|
+
puts "-"
|
49
|
+
until (self.doc.css('.js-action-profile-name')[counter] == nil) || (counter == 4) do
|
50
|
+
|
51
|
+
display_name = self.doc.css('.js-action-profile-name')[counter].text.strip
|
52
|
+
user_name = self.doc.css('.ProfileCard-screenname')[counter].text.strip
|
53
|
+
bio = self.doc.css('.ProfileCard-bio')[counter].text.strip
|
54
|
+
|
55
|
+
puts "For #{display_name.upcase}, type '#{user_name}'"
|
56
|
+
puts bio
|
57
|
+
puts " "
|
58
|
+
counter +=1
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def display_profile
|
63
|
+
puts " "
|
64
|
+
puts "#{self.user.display_name.upcase} - @#{self.user.user_name}"
|
65
|
+
puts "#{self.user.following_count}"
|
66
|
+
puts "#{self.user.follower_count}"
|
67
|
+
puts " "
|
68
|
+
if self.user.private?
|
69
|
+
puts "Out of respect for this user's privacy, I'm not willing to display their tweets at this time."
|
70
|
+
new_user_menu
|
71
|
+
else
|
72
|
+
self.user.show_five
|
73
|
+
give_options
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def give_options
|
78
|
+
puts "-To see more of #{self.user.display_name}'s tweets, type 'more.'"
|
79
|
+
puts "-To check out a different user's tweets, type 'new'"
|
80
|
+
puts "-To learn more about a tweet, simply type the number of the tweet you'd like to learn about."
|
81
|
+
#options_response
|
82
|
+
tweet_response
|
83
|
+
end
|
84
|
+
|
85
|
+
def display_tweet(index)
|
86
|
+
tweet_number = index-1
|
87
|
+
@tweet = self.user.tweets[tweet_number]
|
88
|
+
puts "-------------"
|
89
|
+
puts "On #{tweet.date}, at approximately #{tweet.time} #{tweet.user_name} wrote:"
|
90
|
+
puts "'#{tweet.content}'"
|
91
|
+
puts "-----"
|
92
|
+
puts "#{tweet.reply_count} people replied to this tweet."
|
93
|
+
puts "#{tweet.retweets} people retweeted."
|
94
|
+
puts "#{tweet.likes} people liked it."
|
95
|
+
puts "--"
|
96
|
+
tweet_options
|
97
|
+
end
|
98
|
+
|
99
|
+
def tweet_options
|
100
|
+
puts "To view some of the replies to this tweet, type 'replies'"
|
101
|
+
puts "To see more tweets from #{self.user.display_name}, type 'more'"
|
102
|
+
puts "To check out a different user's tweets, type 'new'"
|
103
|
+
set_replies
|
104
|
+
tweet_response
|
105
|
+
end
|
106
|
+
|
107
|
+
def set_replies
|
108
|
+
self.tweet.set_replies
|
109
|
+
end
|
110
|
+
|
111
|
+
# def options_response
|
112
|
+
# answer = gets.strip.upcase
|
113
|
+
# if answer == "MORE"
|
114
|
+
# self.user.five_more
|
115
|
+
# give_options
|
116
|
+
# elsif answer == "NEW"
|
117
|
+
# new_user_menu
|
118
|
+
# elsif answer.to_i > 0
|
119
|
+
# display_tweet(answer.to_i)
|
120
|
+
# end
|
121
|
+
# end
|
122
|
+
|
123
|
+
def tweet_response
|
124
|
+
answer = gets.strip.upcase
|
125
|
+
if answer == "REPLIES" && self.tweet != nil
|
126
|
+
show_replies
|
127
|
+
elsif answer == "MORE"
|
128
|
+
self.user.five_more
|
129
|
+
give_options
|
130
|
+
elsif answer == "BACK"
|
131
|
+
self.user.redisplay
|
132
|
+
give_options
|
133
|
+
elsif answer == "NEW"
|
134
|
+
new_user_menu
|
135
|
+
elsif answer.to_i > 0
|
136
|
+
display_tweet(answer.to_i)
|
137
|
+
else
|
138
|
+
puts "Uh oh!! I don't know what you're trying to say! Sorry about that."
|
139
|
+
give_options
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def show_replies
|
144
|
+
self.tweet.replies.each_with_index do |reply, index|
|
145
|
+
puts "#{index+1}. #{reply.content}\n"
|
146
|
+
end
|
147
|
+
puts "---"
|
148
|
+
puts "To redisplay #{self.user.display_name}'s tweets, type 'back'"
|
149
|
+
puts "OR"
|
150
|
+
puts "To search for a new tweeter, type 'new'"
|
151
|
+
tweet_response
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
class User
|
2
|
+
attr_accessor :user_name, :doc, :display_name, :counter, :tweets
|
3
|
+
|
4
|
+
def initialize(user_name)
|
5
|
+
html = open("https://twitter.com/#{user_name}")
|
6
|
+
@doc = Nokogiri::HTML(html)
|
7
|
+
@user_name = user_name
|
8
|
+
@display_name = @doc.css('.ProfileHeaderCard-nameLink').text.strip
|
9
|
+
@tweets = []
|
10
|
+
end
|
11
|
+
|
12
|
+
# These methods only ended up working in different classes, so that is where they reside now.
|
13
|
+
# def self.verify_and_create_user(user_name)
|
14
|
+
# html = open("https://twitter.com/#{user_name}")
|
15
|
+
# # @doc = Nokogiri::HTML(html)
|
16
|
+
# rescue OpenURI::HTTPError => error
|
17
|
+
# response = error.io
|
18
|
+
# if !response.status.include?("404" || "Not Found")
|
19
|
+
# self.new(user_name)
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
|
23
|
+
# def real_account?
|
24
|
+
# rescue OpenURI::HTTPError => error
|
25
|
+
# response = error.io
|
26
|
+
# !response.status.include?("404" || "Not Found")
|
27
|
+
# end
|
28
|
+
|
29
|
+
def private?
|
30
|
+
self.doc.css('.ProtectedTimeline h2').text == "This account's Tweets are protected." || false
|
31
|
+
end
|
32
|
+
|
33
|
+
def follower_count
|
34
|
+
self.doc.css('.ProfileNav-item--followers a')[0].attr('title')
|
35
|
+
end
|
36
|
+
|
37
|
+
def following_count
|
38
|
+
self.doc.css('.ProfileNav-item--following a')[0].attr('title')
|
39
|
+
end
|
40
|
+
|
41
|
+
def show_five
|
42
|
+
@counter = 0
|
43
|
+
until self.counter == 5
|
44
|
+
tweet_cycle
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def five_more
|
49
|
+
this_counter = counter + 5
|
50
|
+
until counter == this_counter
|
51
|
+
tweet_cycle
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def redisplay
|
56
|
+
self.tweets.each_with_index do |tweet, index|
|
57
|
+
puts "#{(index+1).to_s}. #{tweet.date} - #{tweet.time} -#{"**RETWEET**" if tweet.retweeted?}- #{tweet.content}"
|
58
|
+
puts " "
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def tweet_cycle
|
63
|
+
get_tweet
|
64
|
+
tweet
|
65
|
+
self.counter += 1
|
66
|
+
end
|
67
|
+
|
68
|
+
def tweet
|
69
|
+
puts "#{(self.counter + 1).to_s}. #{self.tweets[self.counter].date} -#{"**RETWEET**" if tweets[counter].retweeted?}- #{self.tweets[self.counter].content}\n"
|
70
|
+
puts " "
|
71
|
+
end
|
72
|
+
|
73
|
+
def get_tweet
|
74
|
+
user = self
|
75
|
+
path = self.doc.css('.js-stream-tweet')[counter].values[3]
|
76
|
+
url = "https://www.twitter.com#{path}"
|
77
|
+
self.tweets << Tweet.new(url, user)
|
78
|
+
end
|
79
|
+
|
80
|
+
def similar_users
|
81
|
+
binding.pry
|
82
|
+
display_name = self.doc.css('.related-users .fullname')[0].text
|
83
|
+
user_name = self.doc.css('.related-users .username')[0].text
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Verification
|
2
|
+
attr_accessor :user_name
|
3
|
+
|
4
|
+
def initialize(user_name)
|
5
|
+
@user_name = user_name.gsub(' ', '%20')
|
6
|
+
end
|
7
|
+
|
8
|
+
def verify
|
9
|
+
html = open("https://twitter.com/#{self.user_name}")
|
10
|
+
rescue OpenURI::HTTPError => error
|
11
|
+
response = error.io
|
12
|
+
if !response.status.include?("404" || "Not Found")
|
13
|
+
true
|
14
|
+
else
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/twiterator.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative "twiterator/reply.rb"
|
2
|
+
require_relative "twiterator/tweet.rb"
|
3
|
+
require_relative "twiterator/twiterator-cli.rb"
|
4
|
+
require_relative "twiterator/user.rb"
|
5
|
+
require_relative "twiterator/verification.rb"
|
6
|
+
require_relative "twiterator/version"
|
7
|
+
|
8
|
+
module Twiterator
|
9
|
+
# Your code goes here...
|
10
|
+
TwiteratorCLI.new
|
11
|
+
end
|
data/twiterator.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'twiterator/version'
|
5
|
+
require 'open-uri'
|
6
|
+
require 'nokogiri'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "twiterator"
|
10
|
+
spec.version = Twiterator::VERSION
|
11
|
+
spec.authors = ["Alex Glover"]
|
12
|
+
spec.email = ["alexanderbglover@gmail.com"]
|
13
|
+
|
14
|
+
spec.summary = %q{Twitter CLI}
|
15
|
+
spec.description = %q{A simple twitter gem that allows you to explore the popular social networking site from the comfort of your command line.}
|
16
|
+
spec.homepage = "https://rubygems.org/gems/twiterator"
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
20
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
21
|
+
|
22
|
+
# if spec.respond_to?(:metadata)
|
23
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://RubyGems.org'"
|
24
|
+
# else
|
25
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
+
# "public gem pushes."
|
27
|
+
# end
|
28
|
+
|
29
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
30
|
+
f.match(%r{^(test|spec|features)/})
|
31
|
+
end
|
32
|
+
spec.bindir = "exe"
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
|
36
|
+
spec.add_dependency 'nokogiri', '1.7.0'
|
37
|
+
spec.add_dependency 'rest-open-uri'
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twiterator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Glover
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.7.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.7.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-open-uri
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
description: A simple twitter gem that allows you to explore the popular social networking
|
84
|
+
site from the comfort of your command line.
|
85
|
+
email:
|
86
|
+
- alexanderbglover@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".DS_Store"
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".travis.yml"
|
95
|
+
- CODE_OF_CONDUCT.md
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- bin/console
|
101
|
+
- bin/setup
|
102
|
+
- lib/.DS_Store
|
103
|
+
- lib/twiterator.rb
|
104
|
+
- lib/twiterator/reply.rb
|
105
|
+
- lib/twiterator/tweet.rb
|
106
|
+
- lib/twiterator/twiterator-cli.rb
|
107
|
+
- lib/twiterator/user.rb
|
108
|
+
- lib/twiterator/verification.rb
|
109
|
+
- lib/twiterator/version.rb
|
110
|
+
- twiterator.gemspec
|
111
|
+
homepage: https://rubygems.org/gems/twiterator
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.6.10
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Twitter CLI
|
135
|
+
test_files: []
|