gd_duraflame 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +36 -0
- data/MIT-LICENSE +20 -0
- data/README.md +35 -0
- data/Rakefile +128 -0
- data/bin/duraflame +41 -0
- data/duraflame.gemspec +47 -0
- data/lib/duraflame.rb +30 -0
- data/lib/duraflame/client.rb +20 -0
- data/lib/duraflame/message.rb +46 -0
- data/lib/duraflame/processor.rb +25 -0
- data/lib/duraflame/transcript.rb +26 -0
- data/lib/duraflame/translator.rb +36 -0
- data/lib/duraflame/user_lookup.rb +14 -0
- data/spec/fixtures/transcript.json +41 -0
- data/spec/fixtures/user1.json +1 -0
- data/spec/fixtures/user2.json +1 -0
- data/spec/helper.rb +6 -0
- data/spec/integration_spec.rb +45 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 63c0065db5c807ed364535f4875013939d223bf9
|
4
|
+
data.tar.gz: efcd09e44ba4694fec55ec07042ebe3e4a8db69b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e1d7fde32e8fabc48069643dbfea399e70f4a8e07849afbf910dadda77b0edadb2e42b24db57522dca24cce267194709d2e84dd0195b2a646ddf7d2b938bd796
|
7
|
+
data.tar.gz: 04cd58b92d91f47afc160e5e9660f433a42237750d1871ac825c01d4d5e2717f4871e900310614ad2f015e058c6dbd0342f1d05c74b6ee482eaa7a1411c1bb64
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
duraflame (0.2.0)
|
5
|
+
httpclient (~> 2.6)
|
6
|
+
yajl-ruby (~> 1.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.2.8)
|
12
|
+
crack (0.3.1)
|
13
|
+
diff-lcs (1.1.3)
|
14
|
+
httpclient (2.6.0.1)
|
15
|
+
rake (0.9.2.2)
|
16
|
+
rspec (2.10.0)
|
17
|
+
rspec-core (~> 2.10.0)
|
18
|
+
rspec-expectations (~> 2.10.0)
|
19
|
+
rspec-mocks (~> 2.10.0)
|
20
|
+
rspec-core (2.10.1)
|
21
|
+
rspec-expectations (2.10.0)
|
22
|
+
diff-lcs (~> 1.1.3)
|
23
|
+
rspec-mocks (2.10.1)
|
24
|
+
webmock (1.8.7)
|
25
|
+
addressable (>= 2.2.7)
|
26
|
+
crack (>= 0.1.7)
|
27
|
+
yajl-ruby (1.2.1)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
duraflame!
|
34
|
+
rake
|
35
|
+
rspec (~> 2)
|
36
|
+
webmock
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Duraflame
|
2
|
+
|
3
|
+
A command line tool that converts Campfire transcripts to an IRC log format. Allows you to run [pisg](http://pisg.sourceforge.net/) (Perl IRC Statistics Generator) on your Campfire conversations.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
`gem install duraflame`
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
```
|
12
|
+
duraflame [arguments]
|
13
|
+
-c, --company=COMPANY As in http://{company}.campfirenow.com
|
14
|
+
-t, --token=TOKEN Authentication token
|
15
|
+
-r, --room=ROOM Room ID
|
16
|
+
-o, --output-dir=DIRECTORY Directory where log files will be written
|
17
|
+
-s, --start-date=DATE Start date, defaults to today
|
18
|
+
-e, --end-date=DATE End date, defaults to today
|
19
|
+
```
|
20
|
+
|
21
|
+
All arguments are required except for start and end dates, which default to today's date.
|
22
|
+
|
23
|
+
For example:
|
24
|
+
|
25
|
+
`duraflame -c your_company -t your_auth_token96be2812d5367c97f2c87e545 -r 1234 -o campfire_logs --start-date 2012-05-25`
|
26
|
+
|
27
|
+
This command will download transcripts from May 25, 2012 through today.
|
28
|
+
|
29
|
+
Then run pisg:
|
30
|
+
|
31
|
+
`pisg -ch 'Room 1' -d campfire_logs -f irssi`
|
32
|
+
|
33
|
+
## Todo
|
34
|
+
* Improve performance (fetch transcripts concurrently, operate on streams)
|
35
|
+
* Fetch transcripts for multiple rooms
|
data/Rakefile
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
#############################################################################
|
6
|
+
#
|
7
|
+
# Helper functions
|
8
|
+
#
|
9
|
+
#############################################################################
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
def date
|
21
|
+
Date.today.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def rubyforge_project
|
25
|
+
name
|
26
|
+
end
|
27
|
+
|
28
|
+
def gemspec_file
|
29
|
+
"#{name}.gemspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
def gem_file
|
33
|
+
"#{name}-#{version}.gem"
|
34
|
+
end
|
35
|
+
|
36
|
+
def replace_header(head, header_name)
|
37
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
38
|
+
end
|
39
|
+
|
40
|
+
#############################################################################
|
41
|
+
#
|
42
|
+
# Standard tasks
|
43
|
+
#
|
44
|
+
#############################################################################
|
45
|
+
|
46
|
+
desc "Open an irb session preloaded with this library"
|
47
|
+
task :console do
|
48
|
+
sh "irb -rubygems -r ./lib/#{name}.rb"
|
49
|
+
end
|
50
|
+
|
51
|
+
#############################################################################
|
52
|
+
#
|
53
|
+
# Custom tasks (add your own tasks here)
|
54
|
+
#
|
55
|
+
#############################################################################
|
56
|
+
|
57
|
+
task :default => :spec
|
58
|
+
|
59
|
+
desc "Run specs"
|
60
|
+
RSpec::Core::RakeTask.new
|
61
|
+
|
62
|
+
#############################################################################
|
63
|
+
#
|
64
|
+
# Packaging tasks
|
65
|
+
#
|
66
|
+
#############################################################################
|
67
|
+
|
68
|
+
desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
|
69
|
+
task :release => :build do
|
70
|
+
unless `git branch` =~ /^\* master$/
|
71
|
+
puts "You must be on the master branch to release!"
|
72
|
+
exit!
|
73
|
+
end
|
74
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
75
|
+
sh "git tag v#{version}"
|
76
|
+
sh "git push origin master"
|
77
|
+
sh "git push origin v#{version}"
|
78
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Build #{gem_file} into the pkg directory"
|
82
|
+
task :build => :gemspec do
|
83
|
+
sh "mkdir -p pkg"
|
84
|
+
sh "gem build #{gemspec_file}"
|
85
|
+
sh "mv #{gem_file} pkg"
|
86
|
+
end
|
87
|
+
|
88
|
+
desc "Generate #{gemspec_file}"
|
89
|
+
task :gemspec => :validate do
|
90
|
+
# read spec file and split out manifest section
|
91
|
+
spec = File.read(gemspec_file)
|
92
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
93
|
+
|
94
|
+
# replace name version and date
|
95
|
+
replace_header(head, :name)
|
96
|
+
replace_header(head, :version)
|
97
|
+
replace_header(head, :date)
|
98
|
+
#comment this out if your rubyforge_project has a different name
|
99
|
+
replace_header(head, :rubyforge_project)
|
100
|
+
|
101
|
+
# determine file list from git ls-files
|
102
|
+
files = `git ls-files`.
|
103
|
+
split("\n").
|
104
|
+
sort.
|
105
|
+
reject { |file| file =~ /^\./ }.
|
106
|
+
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
107
|
+
map { |file| " #{file}" }.
|
108
|
+
join("\n")
|
109
|
+
|
110
|
+
# piece file back together and write
|
111
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
112
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
113
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
114
|
+
puts "Updated #{gemspec_file}"
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "Validate #{gemspec_file}"
|
118
|
+
task :validate do
|
119
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
|
120
|
+
unless libfiles.empty?
|
121
|
+
puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
|
122
|
+
exit!
|
123
|
+
end
|
124
|
+
unless Dir['VERSION*'].empty?
|
125
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
126
|
+
exit!
|
127
|
+
end
|
128
|
+
end
|
data/bin/duraflame
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'optparse/date'
|
5
|
+
require 'duraflame'
|
6
|
+
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: duraflame [options]"
|
11
|
+
|
12
|
+
opts.on("-c", "--company=COMPANY", "As in http://{company}.campfirenow.com") do |company|
|
13
|
+
options[:company] = company
|
14
|
+
end
|
15
|
+
|
16
|
+
opts.on("-t", "--token=TOKEN", "Authentication token") do |token|
|
17
|
+
options[:token] = token
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on("-r","--room=ROOM", "Room ID") do |room|
|
21
|
+
options[:room] = room
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on("-o", "--output-dir=DIRECTORY", "Directory where log files will be written") do |dir|
|
25
|
+
options[:output_dir] = dir
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-s", "--start-date=DATE", Date, "Start date, defaults to today") do |start_date|
|
29
|
+
options[:start_date] = start_date
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.on("-e", "--end-date=DATE", Date, "End date, defaults to today") do |end_date|
|
33
|
+
options[:end_date] = end_date
|
34
|
+
end
|
35
|
+
end.parse!
|
36
|
+
|
37
|
+
begin
|
38
|
+
Duraflame.execute(options)
|
39
|
+
rescue Interrupt
|
40
|
+
abort
|
41
|
+
end
|
data/duraflame.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'gd_duraflame'
|
3
|
+
s.version = '0.2.1'
|
4
|
+
s.date = '2015-02-09'
|
5
|
+
|
6
|
+
s.summary = "A command line tool that converts Campfire transcripts to an IRC log format"
|
7
|
+
s.description = "Generate pisg (Perl IRC Statistics Generator) stats on Campfire conversations"
|
8
|
+
|
9
|
+
s.authors = ["Alex Kahn"]
|
10
|
+
s.email = 'alexanderkahn@gmail.com'
|
11
|
+
s.homepage = 'http://github.com/akahn/duraflame'
|
12
|
+
|
13
|
+
s.require_paths = %w[lib]
|
14
|
+
|
15
|
+
s.executables = ["duraflame"]
|
16
|
+
|
17
|
+
s.extra_rdoc_files = %w[README.md MIT-LICENSE]
|
18
|
+
|
19
|
+
s.add_dependency('httpclient', '~>2.6')
|
20
|
+
s.add_dependency('yajl-ruby', '~>1.1')
|
21
|
+
|
22
|
+
# = MANIFEST =
|
23
|
+
s.files = %w[
|
24
|
+
Gemfile
|
25
|
+
Gemfile.lock
|
26
|
+
MIT-LICENSE
|
27
|
+
README.md
|
28
|
+
Rakefile
|
29
|
+
bin/duraflame
|
30
|
+
duraflame.gemspec
|
31
|
+
lib/duraflame.rb
|
32
|
+
lib/duraflame/client.rb
|
33
|
+
lib/duraflame/message.rb
|
34
|
+
lib/duraflame/processor.rb
|
35
|
+
lib/duraflame/transcript.rb
|
36
|
+
lib/duraflame/translator.rb
|
37
|
+
lib/duraflame/user_lookup.rb
|
38
|
+
spec/fixtures/transcript.json
|
39
|
+
spec/fixtures/user1.json
|
40
|
+
spec/fixtures/user2.json
|
41
|
+
spec/helper.rb
|
42
|
+
spec/integration_spec.rb
|
43
|
+
]
|
44
|
+
# = MANIFEST =
|
45
|
+
|
46
|
+
s.test_files = s.files.select { |path| path =~ /^spec\/.*_spec\.rb/ }
|
47
|
+
end
|
data/lib/duraflame.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'duraflame/processor'
|
2
|
+
require 'duraflame/user_lookup'
|
3
|
+
require 'duraflame/client'
|
4
|
+
|
5
|
+
module Duraflame
|
6
|
+
VERSION = '0.2.0'
|
7
|
+
|
8
|
+
extend self
|
9
|
+
|
10
|
+
def execute(options)
|
11
|
+
%w[company token output_dir room].each do |option|
|
12
|
+
if !options.has_key?(option.to_sym)
|
13
|
+
abort "Error: Missing option --#{option}. See duraflame --help."
|
14
|
+
end
|
15
|
+
instance_variable_set('@' + option, options[option.to_sym])
|
16
|
+
end
|
17
|
+
|
18
|
+
start_date = options.fetch(:start_date, Date.today)
|
19
|
+
end_date = options.fetch(:end_date, Date.today)
|
20
|
+
Processor.new(@room, start_date..end_date, @output_dir, http_client).execute
|
21
|
+
end
|
22
|
+
|
23
|
+
def http_client
|
24
|
+
@http_client ||= Client.new(@company, @token)
|
25
|
+
end
|
26
|
+
|
27
|
+
def user_names
|
28
|
+
@user_lookup ||= UserLookup.new(http_client)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'httpclient'
|
2
|
+
require 'yajl'
|
3
|
+
|
4
|
+
module Duraflame
|
5
|
+
# Wraps HTTPClient with knowledge of hostname and authentication
|
6
|
+
class Client
|
7
|
+
def initialize(company, token)
|
8
|
+
@http_client = HTTPClient.new
|
9
|
+
@http_client.set_auth(nil, token, nil)
|
10
|
+
@uri = URI.parse("https://#{company}.campfirenow.com")
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(path)
|
14
|
+
uri = @uri.dup
|
15
|
+
uri.path = path
|
16
|
+
body = @http_client.get_content(uri)
|
17
|
+
Yajl::Parser.parse(body)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Duraflame
|
2
|
+
# Converts a timestamp, user_id and possible body into irssi log format
|
3
|
+
class Message
|
4
|
+
def initialize(timestamp, user_id, body)
|
5
|
+
@timestamp = timestamp
|
6
|
+
@user_id = user_id
|
7
|
+
@body = body
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def name
|
13
|
+
Duraflame.user_names[@user_id]
|
14
|
+
end
|
15
|
+
|
16
|
+
def time
|
17
|
+
Time.parse(@timestamp).strftime('%R')
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :body
|
21
|
+
end
|
22
|
+
|
23
|
+
class TextMessage < Message
|
24
|
+
def to_s
|
25
|
+
[time, "< #{name}>", body].join(' ')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class EnterMessage < Message
|
30
|
+
def to_s
|
31
|
+
[time, '-!-' , name, '[hostname] has joined #campfire'].join(' ')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class KickMessage < Message
|
36
|
+
def to_s
|
37
|
+
[time, '-!-' , name, '[hostname] has left #campfire'].join(' ')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class TopicChangeMessage < Message
|
42
|
+
def to_s
|
43
|
+
[time, '-!-' , name, 'changed the topic of #campfire to:', body].join(' ')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'duraflame/message'
|
2
|
+
require 'duraflame/transcript'
|
3
|
+
|
4
|
+
module Duraflame
|
5
|
+
class Processor
|
6
|
+
def initialize(room, date_range, output_directory, http_client)
|
7
|
+
@room = room
|
8
|
+
@date_range = date_range
|
9
|
+
@output_directory = output_directory
|
10
|
+
@http_client = http_client
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute
|
14
|
+
@date_range.each do |date|
|
15
|
+
File.open(@output_directory + "/#{date}-#{@room}.log", 'w') do |file|
|
16
|
+
puts "Writing to #{file.path}"
|
17
|
+
|
18
|
+
Transcript.new(@room, date, @http_client).each_message do |message|
|
19
|
+
file.puts message.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Duraflame
|
2
|
+
class Transcript
|
3
|
+
def initialize(room, date, http_client)
|
4
|
+
@room = room
|
5
|
+
@date = date
|
6
|
+
@http_client = http_client
|
7
|
+
end
|
8
|
+
|
9
|
+
def each_message
|
10
|
+
@http_client.get(url)['messages'].each do |message|
|
11
|
+
if Duraflame.const_defined?(message['type']) # e.g. TextMessage
|
12
|
+
message_class = Duraflame.const_get(message['type'])
|
13
|
+
args = message.values_at('created_at', 'user_id', 'body')
|
14
|
+
yield message_class.new(*args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def url
|
22
|
+
"/room/%s/transcript/%s/%s/%s.json" %
|
23
|
+
[@room, @date.year, @date.month, @date.day]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Duraflame
|
2
|
+
module Translator
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def text_message(message)
|
6
|
+
date, user, body = message.values_at('created_at', 'user_id', 'body')
|
7
|
+
time = date.split(' ')[1].split(':')[0..1].join(':')
|
8
|
+
"#{time} <#{user}> #{body}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def enter_message(message)
|
12
|
+
time = message['created_at'].split(' ')[1].split(':')[0..1].join(':')
|
13
|
+
"#{time} <#{message['user_id']}> has joined"
|
14
|
+
end
|
15
|
+
|
16
|
+
def kick_message(message)
|
17
|
+
time = message['created_at'].split(' ')[1].split(':')[0..1].join(':')
|
18
|
+
"#{time} <#{message['user_id']}> has left"
|
19
|
+
end
|
20
|
+
|
21
|
+
def upload_message(*)
|
22
|
+
end
|
23
|
+
|
24
|
+
def sound_message(*)
|
25
|
+
end
|
26
|
+
|
27
|
+
def tweet_message(*)
|
28
|
+
end
|
29
|
+
|
30
|
+
def paste_message(*)
|
31
|
+
end
|
32
|
+
|
33
|
+
def timestamp_message(*)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
{ "messages" : [ { "body" : null,
|
2
|
+
"created_at" : "2012/05/25 04:04:19 +0000",
|
3
|
+
"id" : 577169389,
|
4
|
+
"room_id" : 1,
|
5
|
+
"starred" : false,
|
6
|
+
"type" : "EnterMessage",
|
7
|
+
"user_id" : 1
|
8
|
+
},
|
9
|
+
{ "body" : "ok, deploying to production",
|
10
|
+
"created_at" : "2012/05/25 05:01:23 +0000",
|
11
|
+
"id" : 577557437,
|
12
|
+
"room_id" : 1,
|
13
|
+
"starred" : false,
|
14
|
+
"type" : "TextMessage",
|
15
|
+
"user_id" : 2
|
16
|
+
},
|
17
|
+
{ "body" : null,
|
18
|
+
"created_at" : "2012/05/25 06:20:29 +0000",
|
19
|
+
"id" : 577214413,
|
20
|
+
"room_id" : 1,
|
21
|
+
"starred" : false,
|
22
|
+
"type" : "KickMessage",
|
23
|
+
"user_id" : 1
|
24
|
+
},
|
25
|
+
{ "body" : null,
|
26
|
+
"created_at" : "2012/05/25 07:10:00 +0000",
|
27
|
+
"id" : 577173940,
|
28
|
+
"room_id" : 1,
|
29
|
+
"starred" : false,
|
30
|
+
"type" : "TimestampMessage",
|
31
|
+
"user_id" : null
|
32
|
+
},
|
33
|
+
{ "type":"TopicChangeMessage",
|
34
|
+
"room_id": 1,
|
35
|
+
"created_at":"2012/05/25 08:31:47 +0000",
|
36
|
+
"starred":false,
|
37
|
+
"id":579912121,
|
38
|
+
"user_id":1,
|
39
|
+
"body":"prime directive"
|
40
|
+
}
|
41
|
+
] }
|
@@ -0,0 +1 @@
|
|
1
|
+
{"user":{"type":"Member","created_at":"2010/06/14 14:25:24 +0000","admin":true,"id":1,"email_address":"sisko@ds9.starfleet","name":"Benjamin Sisko"}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"user":{"type":"Member","created_at":"2012/05/20 12:00:00 +0000","admin":true,"id":2,"email_address":"obrien@ds9.starfleet","name":"Miles O'Brien"}}
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
describe 'Duraflame under integration' do
|
5
|
+
before(:all) do
|
6
|
+
dir = File.dirname(__FILE__)
|
7
|
+
stub_request(:any, /transcript/).to_return(:body => File.open(dir + '/fixtures/transcript.json'))
|
8
|
+
stub_request(:any, /users\/1/).to_return(:body => File.open(dir + '/fixtures/user1.json'))
|
9
|
+
stub_request(:any, /users\/2/).to_return(:body => File.open(dir + '/fixtures/user2.json'))
|
10
|
+
|
11
|
+
options = {
|
12
|
+
:company => 'paperlesspost',
|
13
|
+
:token => 'aoeu',
|
14
|
+
:room => 4321,
|
15
|
+
:output_dir => Dir.tmpdir,
|
16
|
+
:start_date => Date.parse('2012-01-01'),
|
17
|
+
:end_date => Date.parse('2012-01-01')
|
18
|
+
}
|
19
|
+
Duraflame.execute(options)
|
20
|
+
|
21
|
+
ENV['TZ'] = 'UTC'
|
22
|
+
|
23
|
+
@log = File.readlines(Dir.tmpdir + "/2012-01-01-#{options[:room]}.log")
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should output three lines' do
|
27
|
+
@log.length.should == 4
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should contain Sisko joining' do
|
31
|
+
@log[0].should include('0:04 -!- Benjamin Sisko [hostname] has joined')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should contain O'Brien's message joining" do
|
35
|
+
@log[1].should include("1:01 < Miles O'Brien> ok")
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should contain Sisko leaving' do
|
39
|
+
@log[2].should include('02:20 -!- Benjamin Sisko [hostname] has left')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should contain the topic changing' do
|
43
|
+
@log[3].should match(/04:31 -!- Benjamin Sisko changed the topic .* to: prime directive/)
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gd_duraflame
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Kahn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httpclient
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yajl-ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
description: Generate pisg (Perl IRC Statistics Generator) stats on Campfire conversations
|
42
|
+
email: alexanderkahn@gmail.com
|
43
|
+
executables:
|
44
|
+
- duraflame
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files:
|
47
|
+
- README.md
|
48
|
+
- MIT-LICENSE
|
49
|
+
files:
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- MIT-LICENSE
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/duraflame
|
56
|
+
- duraflame.gemspec
|
57
|
+
- lib/duraflame.rb
|
58
|
+
- lib/duraflame/client.rb
|
59
|
+
- lib/duraflame/message.rb
|
60
|
+
- lib/duraflame/processor.rb
|
61
|
+
- lib/duraflame/transcript.rb
|
62
|
+
- lib/duraflame/translator.rb
|
63
|
+
- lib/duraflame/user_lookup.rb
|
64
|
+
- spec/fixtures/transcript.json
|
65
|
+
- spec/fixtures/user1.json
|
66
|
+
- spec/fixtures/user2.json
|
67
|
+
- spec/helper.rb
|
68
|
+
- spec/integration_spec.rb
|
69
|
+
homepage: http://github.com/akahn/duraflame
|
70
|
+
licenses: []
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.2.2
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: A command line tool that converts Campfire transcripts to an IRC log format
|
92
|
+
test_files:
|
93
|
+
- spec/integration_spec.rb
|