Permalink
Browse files

Misc. formatting. Moved socket settings to prefs/defaults.rb

  • Loading branch information...
1 parent 3c3c263 commit 7992daab4c06c775b97bb905ee48c48d256aa721 @scowalt scowalt committed Mar 20, 2012
Showing with 22 additions and 12 deletions.
  1. +1 −2 Gemfile
  2. +6 −2 Gemfile.lock
  3. +5 −5 app.rb
  4. +3 −3 lib/twitter-sentiment/output/send.rb
  5. +7 −0 lib/twitter-sentiment/prefs/defaults.rb
View
@@ -8,5 +8,4 @@ gem "twitter"
gem "face"
gem "paint"
gem "progressbar"
-gem "linguistics"
-
+gem "linguistics"
View
@@ -14,7 +14,7 @@ GEM
term-ansicolor (>= 1.0.6)
daemons (1.1.8)
diff-lcs (1.1.3)
- eventmachine (0.12.10)
+ eventmachine (1.0.0.beta.4.1-x86-mingw32)
face (0.0.4)
json (>= 1.4.6)
rest-client (>= 1.6.1)
@@ -24,7 +24,9 @@ GEM
rack (~> 1.1)
gherkin (2.9.0)
json (>= 1.4.6)
- http_parser.rb (0.5.3)
+ gherkin (2.9.0-x86-mingw32)
+ json (>= 1.4.6)
+ http_parser.rb (0.5.3-x86-mingw32)
i18n (0.6.0)
json (1.6.5)
linguistics (1.0.9)
@@ -53,10 +55,12 @@ GEM
http_parser.rb (~> 0.5.1)
simple_oauth (~> 0.1.4)
yajl-ruby (1.1.0)
+ yajl-ruby (1.1.0-x86-mingw32)
yard (0.7.5)
PLATFORMS
ruby
+ x86-mingw32
DEPENDENCIES
cucumber
View
10 app.rb
@@ -13,15 +13,15 @@ class TwitterBeats
@@score_bounds = [-10,10]
attr_reader :parsers
+ # @return [int] Capped and rounded score
def limit_score score
return 0 if score.nil?
score = score > @@score_bounds[1] ? @@score_bounds[1] : score
score = score < @@score_bounds[0] ? @@score_bounds[0] : score
return score.round
end
- def happiness
-
+ def happiness
return limit_score(@parsers[:text_mood][:result][:score]*0.7+@parsers[:user_image][:result][:score]*0.2+@parsers[:user_stats][:result][:description_score]*0.1) \
unless @parsers[:text_mood][:result][:score].nil? \
or @parsers[:user_image][:result][:score].nil? \
@@ -40,7 +40,7 @@ def happiness
return 0
end
-
+
def paint_score num
return Paint["nil", :italic, :yellow] if num.nil?
return Paint[num.to_s, :bold, :red] if num < 0
@@ -90,8 +90,8 @@ def initialize
out.send_gen weights, status, parsers
},
})
- end
-end
+ end #initialize
+end #class
if __FILE__ == $0
begin
@@ -13,7 +13,6 @@ def initialize
end
# Sends data to the music generator
- # @param [Array] Data in pre-defined form (not in JSON)
# @return [nil]
def send_gen weights, status, parsers
data = {
@@ -36,7 +35,7 @@ def send_gen weights, status, parsers
:negative_score => nil #fix this
},
:tweet => {
- :hash_obnoxiousess => status.entities.hashtags.length, #fix this
+ :hash_obnoxiousess => status.entities.hashtags.length,
:retweet => status.retweeted
},
:face => {
@@ -46,7 +45,8 @@ def send_gen weights, status, parsers
} #sentiment
} #data
payload = Yajl::Encoder.encode(data)
- streamSock = TCPSocket.new( "127.0.0.1", 9133 )
+ prefs = TwitterSentiment::Prefs::Defaults.socket
+ streamSock = TCPSocket.new(prefs[:host], prefs[:port])
streamSock.write(payload)
streamSock.close
rescue Exception
@@ -33,6 +33,13 @@ def self.twitter
:search_phrase => "#sxsw",
}
end
+
+ def self.socket
+ {
+ :host => 'localhost',
+ :port => 9133,
+ }
+ end
end
end
end

0 comments on commit 7992daa

Please sign in to comment.