diff --git a/plugins/community_hub/lib/community_hub_plugin/hub.rb b/plugins/community_hub/lib/community_hub_plugin/hub.rb index 5aa0069..c109181 100644 --- a/plugins/community_hub/lib/community_hub_plugin/hub.rb +++ b/plugins/community_hub/lib/community_hub_plugin/hub.rb @@ -3,6 +3,8 @@ require File.dirname(__FILE__) + '/../../facebook_stream/lib_facebook_stream' class CommunityHubPlugin::Hub < Folder + attr_accessible :last_changed_by_id, :integer + settings_items :twitter_enabled, :type => :boolean, :default => false settings_items :twitter_hashtags, :type => :string, :default => "" settings_items :twitter_consumer_key, :type => :string, :default => "" diff --git a/plugins/community_hub/lib/community_hub_plugin/listener.rb b/plugins/community_hub/lib/community_hub_plugin/listener.rb index 737be86..3abca31 100644 --- a/plugins/community_hub/lib/community_hub_plugin/listener.rb +++ b/plugins/community_hub/lib/community_hub_plugin/listener.rb @@ -32,8 +32,8 @@ class CommunityHubPlugin::Listener end def initialize_logger - logdir = File.join(RAILS_ROOT, 'log', CommunityHubPlugin::Listener.name.underscore) - File.makedirs(logdir) if !File.exist?(logdir) + logdir = File.join(Rails.root, 'log', CommunityHubPlugin::Listener.name.underscore) + FileUtils.makedirs(logdir) if !File.exist?(logdir) logpath = File.join(logdir, "#{ENV['RAILS_ENV']}_#{Time.now.strftime('%F')}.log") @logger = Logger.new(logpath) end diff --git a/plugins/community_hub/test/unit/community_hub_plugin/listener_test.rb b/plugins/community_hub/test/unit/community_hub_plugin/listener_test.rb index 565b8bf..4eb231e 100644 --- a/plugins/community_hub/test/unit/community_hub_plugin/listener_test.rb +++ b/plugins/community_hub/test/unit/community_hub_plugin/listener_test.rb @@ -10,7 +10,7 @@ class ListenerTest < ActiveSupport::TestCase end should 'log message' do - logdir = File.join(RAILS_ROOT, 'log', CommunityHubPlugin::Listener.name.underscore) + logdir = File.join(Rails.root, 'log', CommunityHubPlugin::Listener.name.underscore) if File.exists?(logdir) Dir.foreach(logdir) { |f| diff --git a/plugins/community_hub/twitter/stream.rb b/plugins/community_hub/twitter/stream.rb index 87e8aa5..72f7660 100644 --- a/plugins/community_hub/twitter/stream.rb +++ b/plugins/community_hub/twitter/stream.rb @@ -30,15 +30,13 @@ def listen_twitter_stream(hub, author_id) sleep (10 + 2 ** tries) end end - + tries = 0 while true begin tries += 1 client.filter(:track => hub.twitter_hashtags) do |object| if object.is_a?(Twitter::Tweet) -# puts '@' + object.user.screen_name + ' said: ' + object.text -# puts object.user.profile_image_url comment = Comment.new comment.title = 'hub-message-twitter' comment.source = hub @@ -48,16 +46,16 @@ def listen_twitter_stream(hub, author_id) comment.name = UTF8Filter(object.user.screen_name) comment.email = 'admin@localhost.local' - tries = 0 + tries = 0 begin comment.save! rescue => e - puts "Erro gravando comentário twitter #{e.inspect}" + puts "Error writing twitter comment #{e.inspect}" end end end rescue => e - puts "Erro lendo stream #{e.inspect}" + puts "Error reading twitter stream #{e.inspect}" sleep (10 + 2 ** tries) break end -- libgit2 0.21.2