Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Crystal 0.31.1 & remove deprecated fields #60

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: twitter-crystal
version: 0.2.1
version: 0.2.2

authors:
- Erik Michaels-Ober <[email protected]>

crystal: 0.23.1
crystal: 0.31.1

license: Apache
8 changes: 0 additions & 8 deletions spec/twitter/rest/friends_and_followers_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ describe Twitter::REST::FriendsAndFollowers do
it "returns Twitter::User" do
user.should be_a Twitter::User
user.name.should eq "Doug Williams"
user.following.should be_truthy
end
end
context "called with Int64" do
user = client.follow(1234512345123451234)
it "returns Twitter::User" do
user.should be_a Twitter::User
user.name.should eq "Doug Williams"
user.following.should be_truthy
end
end

Expand All @@ -26,7 +24,6 @@ describe Twitter::REST::FriendsAndFollowers do
it "returns Twitter::User" do
user.should be_a Twitter::User
user.name.should eq "Doug Williams"
user.following.should be_truthy
end
end

Expand All @@ -36,7 +33,6 @@ describe Twitter::REST::FriendsAndFollowers do
it "returns Twitter::User" do
user.should be_a Twitter::User
user.name.should eq "Doug Williams"
user.following.should be_truthy
end
end
end
Expand All @@ -47,7 +43,6 @@ describe Twitter::REST::FriendsAndFollowers do
it "returns Twitter::User" do
user.should be_a Twitter::User
user.name.should eq "Doug Williams"
user.following.should be_falsey
end
end

Expand All @@ -56,7 +51,6 @@ describe Twitter::REST::FriendsAndFollowers do
it "returns Twitter::User" do
user.should be_a Twitter::User
user.name.should eq "Doug Williams"
user.following.should be_falsey
end
end

Expand All @@ -65,7 +59,6 @@ describe Twitter::REST::FriendsAndFollowers do
it "returns Twitter::User" do
user.should be_a Twitter::User
user.name.should eq "Doug Williams"
user.following.should be_falsey
end
end

Expand All @@ -75,7 +68,6 @@ describe Twitter::REST::FriendsAndFollowers do
it "returns Twitter::User" do
user.should be_a Twitter::User
user.name.should eq "Doug Williams"
user.following.should be_falsey
end
end
end
Expand Down
23 changes: 1 addition & 22 deletions spec/twitter/user_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,25 @@ describe Twitter::User do
it "parses all attributes correctly" do
json = JSON.parse(File.read("./spec/fixtures/users.json"))[0].to_json
user = Twitter::User.from_json(json)
user.contributors_enabled.should eq(false)
user.created_at.should eq(Time.parse("Mon Jul 16 12:59:01 +0000 2007", "%a %b %d %T +0000 %Y"))
user.created_at.should eq(Time.parse("Mon Jul 16 12:59:01 +0000 2007", "%a %b %d %T +0000 %Y", Time::Location::UTC))
user.default_profile.should eq(false)
user.default_profile_image.should eq(false)
user.favourites_count.should eq(14447)
user.follow_request_sent.should eq(false)
user.followers_count.should eq(5945)
user.following.should eq(false)
user.friends_count.should eq(881)
user.geo_enabled.should eq(true)
user.id.should eq(7505382)
user.is_translation_enabled.should eq(false)
user.is_translator.should eq(false)
user.lang.should eq("en")
user.listed_count.should eq(339)
user.location.should eq("Berlin")
user.name.should eq("Erik Michaels-Ober")
user.needs_phone_verification.should eq(false)
user.notifications.should eq(false)
user.profile_background_color.should eq("000000")
user.profile_background_image_url.should eq("http://pbs.twimg.com/profile_background_images/677717672/bb0b3653dcf0644e344823e0a2eb3382.png")
user.profile_background_image_url_https.should eq("https://pbs.twimg.com/profile_background_images/677717672/bb0b3653dcf0644e344823e0a2eb3382.png")
user.profile_background_tile.should eq(false)
user.profile_banner_url.should eq("https://pbs.twimg.com/profile_banners/7505382/1425238640")
user.profile_image_url.should eq("http://pbs.twimg.com/profile_images/583426225605058560/dO_rpWw1_normal.jpg")
user.profile_image_url_https.should eq("https://pbs.twimg.com/profile_images/583426225605058560/dO_rpWw1_normal.jpg")
user.profile_link_color.should eq("393740")
user.profile_location.should eq(nil)
user.profile_sidebar_border_color.should eq("000000")
user.profile_sidebar_fill_color.should eq("DDEEF6")
user.profile_text_color.should eq("333333")
user.profile_use_background_image.should eq(true)
user.protected.should eq(false)
user.screen_name.should eq("sferik")
user.status.should be_a(Twitter::Tweet)
user.statuses_count.should eq(17358)
user.suspended.should eq(false)
user.time_zone.should eq("Berlin")
user.url.should eq("https://t.co/L2xIBazeZH")
user.utc_offset.should eq(7200)
user.verified.should eq(false)
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/twitter/rest/friends_and_followers.cr
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ module Twitter

def friend_ids(options = {} of String => String) : Array(Int64)
response = get("/1.1/friends/ids.json", options)
JSON.parse(response)["ids"].map { |friend_id| friend_id.as_i64 }
JSON.parse(response)["ids"].as_a.map { |friend_id| friend_id.as_i64 }
end

def follower_ids(options = {} of String => String) : Array(Int64)
response = get("/1.1/followers/ids.json", options)
JSON.parse(response)["ids"].map { |follower_id| follower_id.as_i64 }
JSON.parse(response)["ids"].as_a.map { |follower_id| follower_id.as_i64 }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/twitter/rest/users.cr
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module Twitter

def blocked_ids(options = {} of String => String) : Array(Int64)
response = get("/1.1/blocks/ids.json", options)
JSON.parse(response)["ids"].map { |id| id.as_i64 }
JSON.parse(response)["ids"].as_a.map { |id| id.as_i64 }
end

def block?(user_id : Int32 | Int64, options = {} of String => String) : Bool
Expand Down
21 changes: 0 additions & 21 deletions src/twitter/user.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,25 @@ require "json"
module Twitter
class User
JSON.mapping({
contributors_enabled: Bool,
created_at: {type: Time, converter: Time::Format.new("%a %b %d %T +0000 %Y")},
default_profile: Bool,
default_profile_image: Bool,
favourites_count: Int32,
follow_request_sent: Bool?,
followers_count: Int32,
following: Bool?,
friends_count: Int32,
geo_enabled: Bool,
id: Int64,
is_translation_enabled: Bool?,
is_translator: Bool,
lang: String,
listed_count: Int32,
location: String?,
name: String,
needs_phone_verification: Bool?,
notifications: Bool?,
profile_background_color: String,
profile_background_image_url: String?,
profile_background_image_url_https: String?,
profile_background_tile: Bool,
profile_banner_url: String?,
profile_image_url: String?,
profile_image_url_https: String?,
profile_link_color: String,
profile_location: String | Location | Nil,
profile_sidebar_border_color: String,
profile_sidebar_fill_color: String,
profile_text_color: String,
profile_use_background_image: Bool,
protected: Bool,
screen_name: String,
status: Twitter::Tweet?,
statuses_count: Int32,
suspended: Bool?,
time_zone: String?,
url: String?,
utc_offset: Int32?,
verified: Bool,
description: String?,
})
Expand Down
2 changes: 1 addition & 1 deletion src/twitter/version.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Twitter
module Version
Major = 0
Minor = 2
Patch = 1
Patch = 2

def self.to_s
[Major, Minor, Patch].join('.')
Expand Down