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.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tweetkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Foo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-11 00:00:00.000000000 Z
11
+ date: 2022-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -60,10 +60,14 @@ executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - ".env.example"
63
64
  - ".gitignore"
65
+ - ".ruby-version"
64
66
  - ".travis.yml"
67
+ - CHANGELOG.md
65
68
  - Gemfile
66
69
  - Gemfile.lock
70
+ - LICENSE
67
71
  - README.md
68
72
  - Rakefile
69
73
  - bin/console
@@ -71,12 +75,24 @@ files:
71
75
  - lib/tweetkit.rb
72
76
  - lib/tweetkit/auth.rb
73
77
  - lib/tweetkit/client.rb
78
+ - lib/tweetkit/client/response/annotations.rb
79
+ - lib/tweetkit/client/response/attachments.rb
80
+ - lib/tweetkit/client/response/expansions.rb
81
+ - lib/tweetkit/client/response/fields.rb
82
+ - lib/tweetkit/client/response/geo.rb
83
+ - lib/tweetkit/client/response/meta.rb
84
+ - lib/tweetkit/client/response/metrics.rb
85
+ - lib/tweetkit/client/response/response.rb
86
+ - lib/tweetkit/client/response/tweet.rb
87
+ - lib/tweetkit/client/response/tweets.rb
88
+ - lib/tweetkit/client/search/conjunctions.rb
89
+ - lib/tweetkit/client/search/search.rb
74
90
  - lib/tweetkit/client/tweets.rb
75
91
  - lib/tweetkit/configurable.rb
76
92
  - lib/tweetkit/connection.rb
77
93
  - lib/tweetkit/default.rb
94
+ - lib/tweetkit/pagination.rb
78
95
  - lib/tweetkit/response.rb
79
- - lib/tweetkit/search.rb
80
96
  - lib/tweetkit/version.rb
81
97
  - tweetkit.gemspec
82
98
  homepage: https://github.com/julianfssen/tweetkit
@@ -100,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
116
  - !ruby/object:Gem::Version
101
117
  version: '0'
102
118
  requirements: []
103
- rubygems_version: 3.1.2
119
+ rubygems_version: 3.2.22
104
120
  signing_key:
105
121
  specification_version: 4
106
122
  summary: 'WIP: Simple API wrapper for Twitter''s V2 API'
@@ -1,121 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Tweetkit
4
- class Search
5
- attr_accessor :search_term
6
-
7
- def initialize(term)
8
- @search_term = term + ' '
9
- end
10
-
11
- def opts
12
- @opts ||= {}
13
- end
14
-
15
- def connectors
16
- @connectors ||= opts[:connectors] = []
17
- end
18
-
19
- def update_search_term(term)
20
- @search_term += term
21
- end
22
-
23
- def setup(&block)
24
- instance_eval(&block)
25
- end
26
-
27
- def combined_query
28
- @combined_query = "#{@search_term.strip} #{combine_connectors}"
29
- end
30
-
31
- def combine_connectors
32
- connectors.join(' ')
33
- end
34
-
35
- def add_connector(term, grouped: true)
36
- grouped ? connectors.push("(#{term})") : connectors.push(term)
37
- end
38
-
39
- def build_connector(connector, terms, &block)
40
- query = ''
41
- connector =
42
- connector
43
- .to_s
44
- .delete_prefix('and_')
45
- .delete_prefix('or_')
46
- .delete_suffix('_one_of')
47
- .to_sym
48
- if connector.match?('contains')
49
- terms.each do |term|
50
- term = term.to_s.strip
51
- if term.split.length > 1
52
- query += "\"#{term}\" "
53
- else
54
- query += "#{term} "
55
- end
56
- end
57
- update_search_term(query)
58
- elsif connector.match?('without')
59
- terms.each do |term|
60
- term = term.to_s.strip
61
- if term.split.length > 1
62
- query += "-\"#{term}\" "
63
- else
64
- query += "-#{term} "
65
- end
66
- end
67
- add_connector(query.rstrip, grouped: false)
68
- elsif connector.match?('is_not')
69
- connector = connector.to_s.delete_suffix('_not').to_sym
70
- terms.each do |term|
71
- term = term.to_s.strip
72
- query += "-#{connector}:#{term} "
73
- end
74
- add_connector(query.rstrip)
75
- else
76
- terms.each do |term|
77
- term = term.to_s.strip
78
- query += "#{connector}:#{term} "
79
- end
80
- add_connector(query.rstrip, grouped: false)
81
- end
82
- block_given? ? yield : self
83
- end
84
-
85
- def build_one_of_connector(connector, terms, &block)
86
- query = []
87
- connector =
88
- connector
89
- .to_s
90
- .delete_prefix('and_')
91
- .delete_prefix('or_')
92
- .delete_suffix('_one_of')
93
- .to_sym
94
- if connector.match?('contains')
95
- terms.each do |term|
96
- term = term.to_s.strip
97
- query << term
98
- end
99
- else
100
- terms.each do |term|
101
- term = term.to_s.strip
102
- query << "#{connector}: #{term}"
103
- end
104
- end
105
- add_connector(query.join(' OR '))
106
- block_given? ? yield : self
107
- end
108
-
109
- def method_missing(connector, *terms, &block)
110
- if connector.match?('one_of')
111
- build_one_of_connector(connector, terms, &block)
112
- else
113
- build_connector(connector, terms, &block)
114
- end
115
- end
116
-
117
- def respond_to_missing?(method)
118
- method.match?('one_of') || super
119
- end
120
- end
121
- end