tweetkit 0.1.1 → 0.2.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
2
  SHA256:
3
- metadata.gz: c9fe5ece4cef00bc50ac604a61d38321fb9aeeef648f6586696d0c1b1e14391c
4
- data.tar.gz: bafdeeda01397333a669aa4dc5eb9021b3c934995a82b1116de74e5f8a7202f9
3
+ metadata.gz: 20539d0c3da14a28107d1fdf85fffcbe6c092b0ec885162ccd487baeb7e2976e
4
+ data.tar.gz: 95eab7a0384b95895fafe9371235ea9192603f66db6a722fa0842872d2014939
5
5
  SHA512:
6
- metadata.gz: e832b0ac7583b4604eca6db1a79615ea86d984191cdd03efcae7fa44215b5a8d1bd78b760312d7e544c595f6c24843983b54e87b4d8f58dfee6e4fa828ea6f9f
7
- data.tar.gz: '045117388ada745f039095a51a0e59583509d984eb8bdab308366b14e27dc8908a5849d7f5da436c480ea1fd1b415e87201ee0174298d6ce2f150f4bc7925bd8'
6
+ metadata.gz: 7caa31d80a32d88968f1f0cb8945ff9dbaf960e363f2572e4a3cde7c41cf19797f74cd99a6699372bed3725e3f39e67121270a83409fb7ad467dd2b732bff99a
7
+ data.tar.gz: a8f3085fc4e221036c08fc3aba617847d693a4494520abd55c8a4262ac03e659dd944e139557856c59379bdb4a8382f7a0de131e0a461c9f50b14cc895aa32db
data/.env.example ADDED
@@ -0,0 +1,5 @@
1
+ BEARER_TOKEN=<your-bearer-token>
2
+ CONSUMER_KEY=<your-consumer-key>
3
+ CONSUMER_SECRET=<your-consumer-secret>
4
+ ACCESS_TOKEN=<your-access-token>
5
+ ACCESS_TOKEN_SECRET=<your-access-token-secret>
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .env
10
+ !.env.example
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+ All notable changes to `tweetkit` will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.2.0] - 2022-01-09
8
+ ### Added
9
+ - Added the ability to add OAuth tokens when setting up the client instance. Credit to @rofreg
10
+ - Added OAuth as an option to authenticate requests. Credit to @rofreg
11
+ - Added the `post_tweet` method to post tweets via OAuth. Credit to @rofreg
12
+ - Added the `delete_tweet` method to delete tweets via OAuth. Credit to @rofreg
13
+ - Added tests for the `Tweets` module.
14
+ - Added tests for the `Search` module.
15
+ - Added tests for search building and cleaning in the `Conjunctions` class.
16
+ ### Changed
17
+ - Updated client responses to return a `Tweetkit::Response` object. The `Tweetkit::Response` object contains a `Tweets` object that is made up of `Tweet` objects that contain the data for each respective tweet. `Fields` and `Expansions` objects are also available depending on the fields and expansions made in the request.
18
+ - Moved search building and cleaning logic to the `Conjunctions` class.
19
+ - Fixed wrong config key names when setting up the client. Credit to @dewey
20
+ ### Removed
21
+ - No changes
data/Gemfile CHANGED
@@ -5,10 +5,15 @@ gemspec
5
5
 
6
6
  gem 'faraday'
7
7
  gem 'faraday_middleware'
8
- gem "minitest", "~> 5.0"
9
8
  gem "rake", "~> 12.0"
10
9
  gem 'simple_oauth', "~> 0.3.0"
11
10
 
11
+ group :development do
12
+ gem 'yard'
13
+ end
14
+
12
15
  group :test, :development do
16
+ gem 'dotenv'
13
17
  gem 'pry', '~> 0.13.1'
18
+ gem 'rspec'
14
19
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tweetkit (0.1.0)
4
+ tweetkit (0.1.4)
5
5
  faraday (>= 0.9)
6
6
  faraday_middleware (~> 1.0.0)
7
7
  simple_oauth (~> 0.3.0)
@@ -10,42 +10,63 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  coderay (1.1.3)
13
- faraday (1.4.2)
13
+ diff-lcs (1.4.4)
14
+ dotenv (2.7.6)
15
+ faraday (1.5.1)
14
16
  faraday-em_http (~> 1.0)
15
17
  faraday-em_synchrony (~> 1.0)
16
18
  faraday-excon (~> 1.1)
19
+ faraday-httpclient (~> 1.0.1)
17
20
  faraday-net_http (~> 1.0)
18
21
  faraday-net_http_persistent (~> 1.1)
22
+ faraday-patron (~> 1.0)
19
23
  multipart-post (>= 1.2, < 3)
20
24
  ruby2_keywords (>= 0.0.4)
21
25
  faraday-em_http (1.0.0)
22
26
  faraday-em_synchrony (1.0.0)
23
27
  faraday-excon (1.1.0)
28
+ faraday-httpclient (1.0.1)
24
29
  faraday-net_http (1.0.1)
25
30
  faraday-net_http_persistent (1.1.0)
31
+ faraday-patron (1.0.0)
26
32
  faraday_middleware (1.0.0)
27
33
  faraday (~> 1.0)
28
34
  method_source (1.0.0)
29
- minitest (5.14.4)
30
35
  multipart-post (2.1.1)
31
36
  pry (0.13.1)
32
37
  coderay (~> 1.1)
33
38
  method_source (~> 1.0)
34
39
  rake (12.3.3)
40
+ rspec (3.10.0)
41
+ rspec-core (~> 3.10.0)
42
+ rspec-expectations (~> 3.10.0)
43
+ rspec-mocks (~> 3.10.0)
44
+ rspec-core (3.10.1)
45
+ rspec-support (~> 3.10.0)
46
+ rspec-expectations (3.10.1)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.10.0)
49
+ rspec-mocks (3.10.1)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.10.0)
52
+ rspec-support (3.10.1)
35
53
  ruby2_keywords (0.0.4)
36
54
  simple_oauth (0.3.1)
55
+ yard (0.9.26)
37
56
 
38
57
  PLATFORMS
39
58
  ruby
40
59
 
41
60
  DEPENDENCIES
61
+ dotenv
42
62
  faraday
43
63
  faraday_middleware
44
- minitest (~> 5.0)
45
64
  pry (~> 0.13.1)
46
65
  rake (~> 12.0)
66
+ rspec
47
67
  simple_oauth (~> 0.3.0)
48
68
  tweetkit!
69
+ yard
49
70
 
50
71
  BUNDLED WITH
51
- 2.1.4
72
+ 2.2.22
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Julian Foo Siang Sen
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -37,13 +37,13 @@ Or install it yourself as:
37
37
  client = Tweetkit::Client.new(bearer_token: 'YOUR_BEARER_TOKEN_HERE')
38
38
 
39
39
  # Initializing via options with OAuth 1.0 credentials
40
- client = Tweetkit::Client.new(bearer_token: 'YOUR_BEARER_TOKEN_HERE', consumer_key: 'YOUR_API_KEY_HERE', consumer_token: 'YOUR_API_TOKEN_HERE')
40
+ client = Tweetkit::Client.new(bearer_token: 'YOUR_BEARER_TOKEN_HERE', consumer_key: 'YOUR_CONSUMER_KEY_HERE', consumer_secret: 'YOUR_CONSUMER_SECRET_HERE')
41
41
 
42
42
  # You can also initialize the client with a block
43
43
  client = Tweetkit::Client.new do |config|
44
44
  config.bearer_token = 'YOUR_BEARER_TOKEN_HERE'
45
- config.consumer_key = 'YOUR_API_KEY_HERE'
46
- config.consumer_token = 'YOUR_API_TOKEN_HERE'
45
+ config.consumer_key = 'YOUR_CONSUMER_KEY_HERE'
46
+ config.consumer_secret = 'YOUR_CONSUMER_SECRET_HERE'
47
47
  end
48
48
  ```
49
49
 
@@ -59,7 +59,9 @@ Coming soon.
59
59
 
60
60
  ## Development
61
61
 
62
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
62
+ After checking out the repo, run `bin/setup` to install dependencies.
63
+
64
+ To run tests, first copy `.env.example` to `.env`, and modify it to include a valid Bearer token for the Twitter v2 API. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
63
65
 
64
66
  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).
65
67
 
data/Rakefile CHANGED
@@ -2,9 +2,9 @@ require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
4
  Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
5
+ t.libs << "spec"
6
6
  t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
7
+ t.test_files = FileList["spec/**/*_spec.rb"]
8
8
  end
9
9
 
10
10
  task :default => :test
data/bin/console CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "bundler/setup"
4
4
  require "tweetkit"
5
+ require 'dotenv'
6
+ BASE_ENV_FILE_PATH = '.env'
5
7
 
6
8
  # You can add fixtures and/or initialization code here to make experimenting
7
9
  # with your gem easier. You can also use a different console, if you like.
@@ -11,4 +13,21 @@ require "tweetkit"
11
13
  # Pry.start
12
14
 
13
15
  require "irb"
16
+
17
+ Dotenv.load(BASE_ENV_FILE_PATH)
18
+
19
+ def reload!
20
+ puts 'Reloading ...'
21
+ # Main project directory.
22
+ root_dir = File.expand_path('..', __dir__)
23
+ # Directories within the project that should be reloaded.
24
+ reload_dirs = %w{lib}
25
+ # Loop through and reload every file in all relevant project directories.
26
+ reload_dirs.each do |dir|
27
+ Dir.glob("#{root_dir}/#{dir}/**/*.rb").each { |f| load(f) }
28
+ end
29
+ # Return true when complete.
30
+ true
31
+ end
32
+
14
33
  IRB.start(__FILE__)
data/lib/tweetkit/auth.rb CHANGED
@@ -1,11 +1,7 @@
1
1
  module Tweetkit
2
2
  module Auth
3
- def basic_auth?
4
- !!(@login && @password)
5
- end
6
-
7
3
  def token_auth?
8
- !!(@access_token && @access_token_secret)
4
+ !!(@consumer_key && @consumer_secret && @access_token && @access_token_secret)
9
5
  end
10
6
 
11
7
  def bearer_auth?
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes