twail 0.0.6 → 0.0.7
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.
- data/README.markdown +5 -2
- data/lib/twail.rb +23 -4
- data/twail.gemspec +1 -1
- metadata +1 -1
data/README.markdown
CHANGED
@@ -25,7 +25,7 @@ for instructions.
|
|
25
25
|
|
26
26
|
or
|
27
27
|
|
28
|
-
twail s [search args]
|
28
|
+
twail s [max pages] [search args]
|
29
29
|
|
30
30
|
## Tailing your timelines
|
31
31
|
|
@@ -93,7 +93,6 @@ want. One pipeline I like to use is
|
|
93
93
|
Lots of other pipelines are possible. Knock yourself out. To stop
|
94
94
|
`twail`, press `CTRL-C`.
|
95
95
|
|
96
|
-
|
97
96
|
## Search for tweets
|
98
97
|
|
99
98
|
You can run a Twitter search with `twail s [search args]`.
|
@@ -104,6 +103,10 @@ query.
|
|
104
103
|
`twail` will print each page of search results as it fetches them and keep
|
105
104
|
going backward in time until the results are exhausted.
|
106
105
|
|
106
|
+
To stop fetching results after n pages, use this form:
|
107
|
+
|
108
|
+
twail s [n] [search args]
|
109
|
+
|
107
110
|
The output of `twail` in search mode looks like this:
|
108
111
|
|
109
112
|
$ twail s vitunes itunes
|
data/lib/twail.rb
CHANGED
@@ -22,7 +22,7 @@ Assuming you've done that, read on.
|
|
22
22
|
|
23
23
|
Usage: twail [timeline]
|
24
24
|
|
25
|
-
twail s [search args]
|
25
|
+
twail s [max pages] [search args]
|
26
26
|
|
27
27
|
[timeline] can be any of these:
|
28
28
|
|
@@ -41,7 +41,13 @@ You can use these abbreviations:
|
|
41
41
|
|
42
42
|
p h f u m by to of
|
43
43
|
|
44
|
-
twail will perform a Twitter search if you use
|
44
|
+
twail will perform a Twitter search if you use
|
45
|
+
|
46
|
+
twail s [search args]
|
47
|
+
|
48
|
+
To stop returning search results after n pages, use
|
49
|
+
|
50
|
+
twail s [n] [search args]
|
45
51
|
|
46
52
|
For more help, see the README at
|
47
53
|
|
@@ -60,8 +66,16 @@ end
|
|
60
66
|
|
61
67
|
# search is different
|
62
68
|
if ARGV.first =~ /^s/ # search
|
63
|
-
|
64
|
-
|
69
|
+
ARGV.shift
|
70
|
+
max_pages = if ARGV[0] =~ /\d+/
|
71
|
+
ARGV.shift
|
72
|
+
end
|
73
|
+
|
74
|
+
query = "?q=#{ARGV.join(' ')}"
|
75
|
+
$stderr.puts "Search query: #{ARGV.join(' ')}"
|
76
|
+
if max_pages
|
77
|
+
$stderr.puts "Max pages: #{max_pages}"
|
78
|
+
end
|
65
79
|
|
66
80
|
while query
|
67
81
|
url = "http://search.twitter.com/search.json#{query}"
|
@@ -72,6 +86,11 @@ if ARGV.first =~ /^s/ # search
|
|
72
86
|
puts "%s | %s | %s" % [time.to_s.gsub(/\s\S+$/,''), x['from_user'].rjust(18), x['text'].gsub(/\n/, ' ')]
|
73
87
|
end
|
74
88
|
query = res['next_page']
|
89
|
+
if max_pages
|
90
|
+
if query[/page=(\d+)/, 1].to_i > max_pages.to_i
|
91
|
+
exit
|
92
|
+
end
|
93
|
+
end
|
75
94
|
end
|
76
95
|
exit
|
77
96
|
end
|
data/twail.gemspec
CHANGED