twitter-vanity-suite 0.2.0 → 0.3.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 +4 -4
- data/bin/twitter-algebra +42 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbd02cf81a60ba76aeb715ef2115218f27e763e3
|
4
|
+
data.tar.gz: 9f4b6a591e71bcc7b6044a5a237b044335a4db51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae8beb95085b0b3c7feeb12052c6a81b2775020a243a75c6d4e25bc718266ec116ab62f4efd62f55d691a7e2dc7c9e56f0706942be7d1655f429fac3aa5d2716
|
7
|
+
data.tar.gz: 2dde746691b773122a20cacc62563b5de7b3e35bbddc58ad171c6c9ba8fac7acebe663207142a414b26fc53027ccbe031218a70d41c45e2cd164cdea7ba49467
|
data/bin/twitter-algebra
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
#
|
9
9
|
# A.followers - returns the set of users that follow @A on twitter
|
10
10
|
#
|
11
|
+
# A/B - returns the set of users in the @A/B list
|
12
|
+
#
|
11
13
|
# {A, B, C} - returns a set containing the users @A, @B, and @C
|
12
14
|
#
|
13
15
|
# You may use the following operators in your expression:
|
@@ -50,8 +52,9 @@ end
|
|
50
52
|
|
51
53
|
class Lexer
|
52
54
|
TOKENS = [
|
53
|
-
[:BAREWORD, /[a-z0-9_]+/],
|
55
|
+
[:BAREWORD, /[a-z0-9_-]+/],
|
54
56
|
[:DOT, /\./],
|
57
|
+
[:SLASH, /\//],
|
55
58
|
[:INTERSECTION, /&/],
|
56
59
|
[:UNION, /\|/],
|
57
60
|
[:COMPLEMENT, /~/],
|
@@ -214,6 +217,25 @@ module AST
|
|
214
217
|
end
|
215
218
|
end
|
216
219
|
|
220
|
+
class ListMembers
|
221
|
+
include LoadableSet
|
222
|
+
|
223
|
+
attr_reader :handle, :list_name
|
224
|
+
|
225
|
+
def initialize(handle, list_name)
|
226
|
+
@handle = handle
|
227
|
+
@list_name = list_name
|
228
|
+
end
|
229
|
+
|
230
|
+
def key
|
231
|
+
"#{handle}/#{list_name}"
|
232
|
+
end
|
233
|
+
|
234
|
+
def fetch_data
|
235
|
+
$client.list_members(handle, list_name).map(&:id)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
217
239
|
class Binary
|
218
240
|
attr_reader :left, :right
|
219
241
|
|
@@ -351,6 +373,16 @@ private
|
|
351
373
|
|
352
374
|
def handle_expression
|
353
375
|
handle = expect_token(:BAREWORD).value
|
376
|
+
if peek_token.type == :DOT
|
377
|
+
handle_command_expression(handle)
|
378
|
+
elsif peek_token.type == :SLASH
|
379
|
+
list_expression(handle)
|
380
|
+
else
|
381
|
+
raise SyntaxError, "Unexpected #{peek_token.value.inspect}"
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
def handle_command_expression(handle)
|
354
386
|
expect_token(:DOT)
|
355
387
|
command = expect_token(:BAREWORD).value
|
356
388
|
if klass = COMMANDS[command]
|
@@ -359,6 +391,12 @@ private
|
|
359
391
|
raise SyntaxError, "Unknown command #{command.inspect}"
|
360
392
|
end
|
361
393
|
end
|
394
|
+
|
395
|
+
def list_expression(handle)
|
396
|
+
expect_token(:SLASH)
|
397
|
+
list_name = expect_token(:BAREWORD).value
|
398
|
+
AST::ListMembers.new(handle, list_name)
|
399
|
+
end
|
362
400
|
end
|
363
401
|
|
364
402
|
expr = ARGV.first
|
@@ -384,7 +422,9 @@ if result_set.values.empty?
|
|
384
422
|
$stderr.puts "(nobody)"
|
385
423
|
end
|
386
424
|
else
|
387
|
-
$client.users(result_set.values).
|
425
|
+
$client.users(result_set.values).sort_by { |user|
|
426
|
+
user.screen_name.downcase
|
427
|
+
}.each do |user|
|
388
428
|
puts "#{complement ? "NOT " : ""}#{user.screen_name}"
|
389
429
|
end
|
390
430
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter-vanity-suite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Somerville
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: twitter
|