twitterpunch 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f713d6cb1c1e707769c09897f11913046bbffbd4
4
- data.tar.gz: c37e34a59d06f4e0f6edfcfee3d23e0d87af4b77
3
+ metadata.gz: 389d8553b798ec507b247c3d177531c901d001ce
4
+ data.tar.gz: d387564f4bc18b59b340051e9fe8aa7ef5da441f
5
5
  SHA512:
6
- metadata.gz: 840fce97e3c6a0b6b55d34aea8080a2bc82873bcb528b6e108036544e6427b48b542eac7509b1cbce852fb0dd108c0dba010df85bb261da23efa3eed4642e7cd
7
- data.tar.gz: 789cc9841fb3bf2b22f0184ff425fca27b8bf8b33aeaf76312efba604d07bbdecb041063ff1cc4cdf2f5508037c5676e4d1644cde99056ef6850a4c80942cd6e
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
@@ -1,5 +1,5 @@
1
1
  module Twitterpunch
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
 
4
4
  # Twitter application credentials
5
5
  API_KEY = 'STurW17Tj7HuoZ7dSzS0uSoIP'
@@ -35,57 +35,63 @@ module Twitterpunch
35
35
 
36
36
  def stream
37
37
  begin
38
- @client.filter(:track => @config[:hashtag]) do |tweet|
39
- if tweet.is_a?(Twitter::Tweet)
40
- @logger.info(tweet.text)
41
- @logger.log(tweet.user.screen_name, tweet.text)
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
- content = tweet.text.gsub(/ http\S*/,'').gsub(/#\S*/,'')
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
- if tweet.media?
46
- uri = tweet.media.first.media_uri
53
+ content = tweet.text.gsub(/http\S*/,'').gsub(/#\S*/,'').gsub(/@#{@config[:handle]}/, '')
47
54
 
48
- http = Net::HTTP.new(uri.host, uri.port)
49
- request = Net::HTTP::Get.new(uri.request_uri)
50
- response = http.request(request)
55
+ if tweet.media?
56
+ uri = tweet.media.first.media_uri
51
57
 
52
- image = File.basename uri.path
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
- File.open("#{@output}/#{image}", 'wb') do |file|
55
- file.write(response.body)
56
- end
62
+ image = File.basename uri.path
57
63
 
58
- unless tweet.user.screen_name == @handle
59
- @config[:state][image] = content
60
- end
64
+ File.open("#{@output}/#{image}", 'wb') do |file|
65
+ file.write(response.body)
66
+ end
61
67
 
62
- if @viewer
63
- @viewer.pop(image, content)
64
- else
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
- unless tweet.user.screen_name == @handle
75
- message = "#{tweet.user.name} says #{content}"
82
+ end
76
83
 
77
- case RUBY_PLATFORM
78
- when /mingw|cygwin/
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
- rescue Interrupt => e
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.6
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\nLimitations\n===========\n\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"