twitterpunch 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.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/twitterpunch.rb +1 -1
- data/lib/twitterpunch/streamer.rb +43 -37
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 389d8553b798ec507b247c3d177531c901d001ce
|
4
|
+
data.tar.gz: d387564f4bc18b59b340051e9fe8aa7ef5da441f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b805d4d94c23e3f380c723f6f2a3b0c88b2cca1867a993af89363871442e37e4c7c5c25dfcbf31009810222cc2c9ebe4996547e0a70541ae2f26ab851a4115
|
7
|
+
data.tar.gz: 5b05a187c7524c52b524cb8235517a6d33378cf6c94d7c13dafa62ab0b00872dbea1c22c81ba8c6e29ed9b3070ff656cfaf9e221d589c5a79916507a9be08eeb
|
data/README.md
CHANGED
@@ -98,6 +98,13 @@ There are currently two decent viewing options I am aware of.
|
|
98
98
|
* Drawbacks: The screensaver doesn't reload dynamically, so I have to kick it
|
99
99
|
and you'll see it reloading each time a new tweet comes in.
|
100
100
|
|
101
|
+
### Running the remote web app
|
102
|
+
|
103
|
+
1. Run the app with `twitterpunch --remote`
|
104
|
+
1. Browse to the app with http://<address>:8080
|
105
|
+
1. [optional] If on an iOS device, add to your homescreen
|
106
|
+
* This will give you "app behaviour", such as full screen, and a nice icon
|
107
|
+
|
101
108
|
Limitations
|
102
109
|
===========
|
103
110
|
|
data/lib/twitterpunch.rb
CHANGED
@@ -35,57 +35,63 @@ module Twitterpunch
|
|
35
35
|
|
36
36
|
def stream
|
37
37
|
begin
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
if @config[:hashtag]
|
39
|
+
@client.filter(:track => @config[:hashtag]) { |tweet| handle(tweet) }
|
40
|
+
else
|
41
|
+
@client.user { |tweet| handle(tweet) }
|
42
|
+
end
|
43
|
+
rescue Interrupt => e
|
44
|
+
@logger.error "Exiting: #{e.message}"
|
45
|
+
end
|
46
|
+
end
|
42
47
|
|
43
|
-
|
48
|
+
def handle(tweet)
|
49
|
+
if tweet.is_a?(Twitter::Tweet)
|
50
|
+
@logger.info(tweet.text)
|
51
|
+
@logger.log(tweet.user.screen_name, tweet.text)
|
44
52
|
|
45
|
-
|
46
|
-
uri = tweet.media.first.media_uri
|
53
|
+
content = tweet.text.gsub(/http\S*/,'').gsub(/#\S*/,'').gsub(/@#{@config[:handle]}/, '')
|
47
54
|
|
48
|
-
|
49
|
-
|
50
|
-
response = http.request(request)
|
55
|
+
if tweet.media?
|
56
|
+
uri = tweet.media.first.media_uri
|
51
57
|
|
52
|
-
|
58
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
59
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
60
|
+
response = http.request(request)
|
53
61
|
|
54
|
-
|
55
|
-
file.write(response.body)
|
56
|
-
end
|
62
|
+
image = File.basename uri.path
|
57
63
|
|
58
|
-
|
59
|
-
|
60
|
-
|
64
|
+
File.open("#{@output}/#{image}", 'wb') do |file|
|
65
|
+
file.write(response.body)
|
66
|
+
end
|
61
67
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
# OS X screensaver doesn't reload images dynamically. This kinda sucks.
|
66
|
-
if RUBY_PLATFORM =~ /darwin/ and system('pgrep ScreenSaverEngine >/dev/null')
|
67
|
-
system('osascript', '-e', 'tell application "System Events" to stop current screen saver')
|
68
|
-
system('osascript', '-e', 'tell application "System Events" to start current screen saver')
|
69
|
-
end
|
70
|
-
end
|
68
|
+
unless tweet.user.screen_name == @handle
|
69
|
+
@config[:state][image] = content
|
70
|
+
end
|
71
71
|
|
72
|
+
if @viewer
|
73
|
+
@viewer.pop(image, content)
|
74
|
+
else
|
75
|
+
# OS X screensaver doesn't reload images dynamically. This kinda sucks.
|
76
|
+
if RUBY_PLATFORM =~ /darwin/ and system('pgrep ScreenSaverEngine >/dev/null')
|
77
|
+
system('osascript', '-e', 'tell application "System Events" to stop current screen saver')
|
78
|
+
system('osascript', '-e', 'tell application "System Events" to start current screen saver')
|
72
79
|
end
|
80
|
+
end
|
73
81
|
|
74
|
-
|
75
|
-
message = "#{tweet.user.name} says #{content}"
|
82
|
+
end
|
76
83
|
|
77
|
-
|
78
|
-
|
79
|
-
system('cscript', "#{@config[:resources]}/say.vbs", message)
|
80
|
-
when /darwin/
|
81
|
-
system('say', message)
|
82
|
-
end
|
83
|
-
end
|
84
|
+
unless tweet.user.screen_name == @handle
|
85
|
+
message = "#{tweet.user.name} says #{content}"
|
84
86
|
|
87
|
+
case RUBY_PLATFORM
|
88
|
+
when /mingw|cygwin/
|
89
|
+
system('cscript', "#{@config[:resources]}/say.vbs", message)
|
90
|
+
when /darwin/
|
91
|
+
system('say', message)
|
85
92
|
end
|
86
93
|
end
|
87
|
-
|
88
|
-
@logger.error "Exiting: #{e.message}"
|
94
|
+
|
89
95
|
end
|
90
96
|
end
|
91
97
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitterpunch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Ford
|
@@ -118,7 +118,10 @@ description: "Twitterpunch\n===============\n\nTwitterpunch is designed to work
|
|
118
118
|
sexy screensavers and configure it to show photos from the `:photodir`\n * Set
|
119
119
|
screensaver to a super short timeout.\n * Disable power savings.\n * Drawbacks:
|
120
120
|
The screensaver doesn't reload dynamically, so I have to kick it\n and you'll
|
121
|
-
see it reloading each time a new tweet comes in.\n\
|
121
|
+
see it reloading each time a new tweet comes in.\n\n### Running the remote web app\n\n1.
|
122
|
+
Run the app with `twitterpunch --remote`\n1. Browse to the app with http://<address>:8080\n1.
|
123
|
+
[optional] If on an iOS device, add to your homescreen\n * This will give you
|
124
|
+
\"app behaviour\", such as full screen, and a nice icon\n\nLimitations\n===========\n\n*
|
122
125
|
It currently requires manual setup for Folder Actions.\n* Rubygame is kind of a
|
123
126
|
pain to set up.\n\n\nContact\n=======\n\n* Author: Ben Ford\n* Email: binford2k@gmail.com\n*
|
124
127
|
Twitter: @binford2k\n* IRC (Freenode): binford2k\n"
|