From 8ba19f7a1addabd0c850de9f7963e8ab4c6b3523 Mon Sep 17 00:00:00 2001 From: Samual Black Date: Sun, 23 Feb 2020 15:21:54 +0000 Subject: [PATCH 1/3] Fixes up to Crystal 0.31.1 --- shard.yml | 2 +- spec/twitter/user_spec.cr | 2 +- src/twitter/rest/friends_and_followers.cr | 4 ++-- src/twitter/rest/users.cr | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/shard.yml b/shard.yml index d8132f4..b0d5c52 100644 --- a/shard.yml +++ b/shard.yml @@ -4,6 +4,6 @@ version: 0.2.1 authors: - Erik Michaels-Ober -crystal: 0.23.1 +crystal: 0.31.1 license: Apache diff --git a/spec/twitter/user_spec.cr b/spec/twitter/user_spec.cr index 3d94ca0..1bf81ab 100644 --- a/spec/twitter/user_spec.cr +++ b/spec/twitter/user_spec.cr @@ -6,7 +6,7 @@ describe Twitter::User 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) diff --git a/src/twitter/rest/friends_and_followers.cr b/src/twitter/rest/friends_and_followers.cr index 8e173fd..4164615 100644 --- a/src/twitter/rest/friends_and_followers.cr +++ b/src/twitter/rest/friends_and_followers.cr @@ -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 diff --git a/src/twitter/rest/users.cr b/src/twitter/rest/users.cr index a81d4bc..36c12d6 100644 --- a/src/twitter/rest/users.cr +++ b/src/twitter/rest/users.cr @@ -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 From 73f4dc113ae17adaa3639c2d0e506fed2b5c5fb5 Mon Sep 17 00:00:00 2001 From: Samual Black Date: Sun, 23 Feb 2020 15:38:02 +0000 Subject: [PATCH 2/3] Removed deprecated fields --- .../rest/friends_and_followers_spec.cr | 8 ------- spec/twitter/user_spec.cr | 21 ------------------- src/twitter/user.cr | 21 ------------------- 3 files changed, 50 deletions(-) diff --git a/spec/twitter/rest/friends_and_followers_spec.cr b/spec/twitter/rest/friends_and_followers_spec.cr index 301dda0..4b5ada8 100644 --- a/spec/twitter/rest/friends_and_followers_spec.cr +++ b/spec/twitter/rest/friends_and_followers_spec.cr @@ -9,7 +9,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 context "called with Int64" do @@ -17,7 +16,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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/spec/twitter/user_spec.cr b/spec/twitter/user_spec.cr index 1bf81ab..92f9c95 100644 --- a/spec/twitter/user_spec.cr +++ b/spec/twitter/user_spec.cr @@ -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", 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 diff --git a/src/twitter/user.cr b/src/twitter/user.cr index 5d1b440..bcf1129 100644 --- a/src/twitter/user.cr +++ b/src/twitter/user.cr @@ -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?, }) From 544a5bb0d65e1907105916d3e6554fc010efaf1f Mon Sep 17 00:00:00 2001 From: Samual Black Date: Thu, 27 Feb 2020 14:16:30 +0000 Subject: [PATCH 3/3] Version 0.2.2 --- shard.yml | 2 +- src/twitter/version.cr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shard.yml b/shard.yml index b0d5c52..5bb8d13 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: twitter-crystal -version: 0.2.1 +version: 0.2.2 authors: - Erik Michaels-Ober diff --git a/src/twitter/version.cr b/src/twitter/version.cr index 073b557..ee77e13 100644 --- a/src/twitter/version.cr +++ b/src/twitter/version.cr @@ -2,7 +2,7 @@ module Twitter module Version Major = 0 Minor = 2 - Patch = 1 + Patch = 2 def self.to_s [Major, Minor, Patch].join('.')