Skip to content
This repository has been archived by the owner on Apr 4, 2018. It is now read-only.

Commit

Permalink
Rename from leader to narrative
Browse files Browse the repository at this point in the history
@author Rob
@author Seema
  • Loading branch information
ssatish committed Aug 3, 2012
1 parent 5c8a2d1 commit 9698db7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
## About

This collector forms part of the Data Insight Platform. It collects the
latest content for the leader for the public dashboard and broadcasts
latest content for the narrative for the public dashboard and broadcasts
that message on a message bus.

## Key

The key for the topic exchange that this collector broadcasts to is:

googledrive.leader
googledrive.narrative

## Format

Expand All @@ -17,7 +17,7 @@ The message is JSON and follows the following strcuture.
{
"envelope":{
"collected_at":"2012-07-31T10:46:25+01:00",
"collector":"leader"
"collector":"narrative"
},
"payload":{
"content":"Some content of interest went up 20%",
Expand All @@ -40,14 +40,14 @@ overridden with the AMQP environment variable.
The first run requires the Oauth token from Google for the given
application. Once you have that you can run:

bundle exec bin/leader-collector --token={auth token from Google} print
bundle exec bin/narrative-collector --token={auth token from Google} print

Following runs just require the following, as the refresh token will
have been stored. Repassing the original auth token will fail as it's
now invalid.

bundle exec bin/leader-collector print
bundle exec bin/narrative-collector print

Full help details can be found with:

bundle exec bin/leader-collector help
bundle exec bin/narrative-collector help
6 changes: 3 additions & 3 deletions bin/leader-collector → bin/collector
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'rubygems'
require 'gli'

require_relative '../lib/leader'
require_relative '../lib/narrative'

include GLI

Expand All @@ -19,14 +19,14 @@ flag [:t,:token]
desc 'Print out the collected content'
command :print do |c|
c.action do |global_options, options, args|
puts Collectors::LeaderCollector.new(global_options[:token]).print
puts Collectors::NarrativeCollector.new(global_options[:token]).print
end
end

desc 'Publish the collected content to the queue'
command :broadcast do |c|
c.action do |global_options, options, args|
Collectors::LeaderCollector.new(global_options[:token]).broadcast
Collectors::NarrativeCollector.new(global_options[:token]).broadcast
end
end

Expand Down
8 changes: 4 additions & 4 deletions lib/leader.rb → lib/narrative.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
require_relative 'google_authentication'

module Collectors
class LeaderCollector
class NarrativeCollector

def initialize(authorization_code=nil)
@authorization_code = authorization_code
Expand All @@ -25,15 +25,15 @@ def broadcast
client = Bunny.new ENV['AMQP']
client.start
exchange = client.exchange("datainsight", :type => :topic)
exchange.publish(response.to_json, :key => 'googledrive.leader')
exchange.publish(response.to_json, :key => 'googledrive.narrative')
client.stop
end

def create_message(content, author)
{
:envelope => {
:collected_at => DateTime.now,
:collector => "leader",
:collector => "narrative",
},
:payload => {
:content => content,
Expand All @@ -46,7 +46,7 @@ def create_exception_message(message, current_date)
{
:envelope => {
:collected_at => DateTime.now,
:collector => "leader",
:collector => "narrative",
},
:payload => {
:error => message
Expand Down
8 changes: 4 additions & 4 deletions test/leader_spec.rb → test/narrative_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'bunny'
require_relative '../lib/leader'
require_relative '../lib/narrative'
require_relative 'spec_helper'

describe "a leader collector" do
describe "a narrative collector" do
before(:each) do
@collector = Collectors::LeaderCollector.new
@collector = Collectors::NarrativeCollector.new
end

it "when printed should contains a valid JSON document" do
Expand All @@ -24,7 +24,7 @@
@collector.stubs(:response)

exchange= mock('exchange')
exchange.expects(:publish).with("null", :key => 'googledrive.leader')
exchange.expects(:publish).with("null", :key => 'googledrive.narrative')

rabbit = mock('bunny')
rabbit.expects(:start)
Expand Down

0 comments on commit 9698db7

Please sign in to comment.