pipio 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS.md +10 -1
- data/README.md +2 -3
- data/lib/pipio/chat.rb +3 -3
- data/lib/pipio/messages/auto_reply_message.rb +1 -1
- data/lib/pipio/messages/message.rb +1 -1
- data/lib/pipio/messages/status_message.rb +1 -1
- data/lib/pipio/messages/xml_message.rb +1 -1
- data/lib/pipio/parsers/basic_parser.rb +1 -1
- data/lib/pipio/version.rb +1 -1
- data/spec/features/parsing_an_html_file_spec.rb +25 -0
- data/spec/fixtures/input.html +3 -0
- data/spec/fixtures/output.xml +2 -0
- data/spec/pipio/chat_spec.rb +3 -3
- data/spec/pipio/messages/auto_reply_message_spec.rb +1 -1
- data/spec/pipio/messages/event_spec.rb +1 -1
- data/spec/pipio/messages/status_message_spec.rb +1 -5
- data/spec/pipio/messages/xml_message_spec.rb +1 -1
- data/spec/pipio/metadata_spec.rb +3 -3
- data/spec/pipio/parser_factory_spec.rb +1 -1
- data/spec/pipio/parsers/html_log_parser_spec.rb +4 -4
- data/spec/pipio/parsers/text_log_parser_spec.rb +2 -2
- data/spec/pipio_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a14d4d97d6bee17bf6a0889212efae784e929d64
|
4
|
+
data.tar.gz: 6bcc28a685bc84d70b81031d71023bd8ed5c1413
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88e2f94f3c5e2f668338f853e64f61dae962ea75f26b91b72f4485dbf645b3d52975dc88a7f9eaae7363aab6cabf01f160bcee533c7c6ff524b3e3fb397b786f
|
7
|
+
data.tar.gz: 063b79775485aae8282c2e783d44dc485bbdfaa661be142a1aa5461764355ca6d3c5997a884ba3cb1ed1685b0a34b254c87d85c3f5fadf5dd413a149b9b2e628
|
data/NEWS.md
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
##
|
1
|
+
## v0.0.2
|
2
|
+
|
3
|
+
* Remove ending newlines from Message subclasses' `to_s` output
|
4
|
+
* Remove `Chat#start_time_xmlschema` in favor of `Chat#start_time`, which
|
5
|
+
returns an actual Time object
|
6
|
+
* Output chat message times using Adium's timezone format (`-0400`, not
|
7
|
+
`-04:00`)
|
8
|
+
* Internal: pass around aliases as an array instead of a comma-delimited string
|
9
|
+
|
10
|
+
## 0.0.1
|
2
11
|
|
3
12
|
Extract Pidgin2Adium, commit hash 96c443fd244b3d2d57564bf17c68d3ec1bcb48ff, into
|
4
13
|
this library, Pipio. There are also other commits in this release that are not in
|
data/README.md
CHANGED
@@ -9,10 +9,9 @@ message objects in `Pipio::Chat#messages`.
|
|
9
9
|
To deal with meta-information about the chat itself:
|
10
10
|
|
11
11
|
path_to_chat_log = File.expand_path('~/path/to/chat_log.html') # or .txt
|
12
|
-
chat = Pipio.parse(path_to_chat_log, "Gabe B-W,Gabe,Other Alias")
|
12
|
+
chat = Pipio.parse(path_to_chat_log, ["Gabe B-W", "Gabe", "Other Alias"])
|
13
13
|
if chat
|
14
14
|
puts "Screen name of the person you chatted with: #{chat.their_screen_name}"
|
15
|
-
puts "Time the chat started: #{chat.start_time_xmlschema}"
|
16
15
|
puts "Chat contents, in adium format:"
|
17
16
|
puts chat.to_s
|
18
17
|
else
|
@@ -23,7 +22,7 @@ To deal with meta-information about the chat itself:
|
|
23
22
|
|
24
23
|
Or, to deal with individual messages in a chat:
|
25
24
|
|
26
|
-
chat = Pipio.parse("/path/to/log/file.html", "gabe,gbw,gabeb-w")
|
25
|
+
chat = Pipio.parse("/path/to/log/file.html", ["gabe", "gbw", "gabeb-w"])
|
27
26
|
chat.each do |message|
|
28
27
|
puts "Screen name of person who sent this message: #{message.sender_screen_name}"
|
29
28
|
puts "Alias of person who sent this message: #{message.sender_alias}"
|
data/lib/pipio/chat.rb
CHANGED
@@ -11,8 +11,8 @@ module Pipio
|
|
11
11
|
|
12
12
|
attr_reader :messages
|
13
13
|
|
14
|
-
def
|
15
|
-
@metadata.start_time
|
14
|
+
def start_time
|
15
|
+
@metadata.start_time
|
16
16
|
end
|
17
17
|
|
18
18
|
def my_screen_name
|
@@ -28,7 +28,7 @@ module Pipio
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def to_s
|
31
|
-
|
31
|
+
messages.join("\n")
|
32
32
|
end
|
33
33
|
|
34
34
|
# Iterate over each Message.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Pipio
|
2
2
|
class AutoReplyMessage < XMLMessage
|
3
3
|
def to_s
|
4
|
-
%(<message sender="#{sender_screen_name}" time="#{adium_formatted_time}" auto="true" alias="#{@sender_alias}">#{@styled_body}</message
|
4
|
+
%(<message sender="#{sender_screen_name}" time="#{adium_formatted_time}" auto="true" alias="#{@sender_alias}">#{@styled_body}</message>)
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
@@ -20,7 +20,7 @@ module Pipio
|
|
20
20
|
attr_reader :status
|
21
21
|
|
22
22
|
def to_s
|
23
|
-
%(<status type="#{@status}" sender="#{@sender_screen_name}" time="#{adium_formatted_time}" alias="#{@sender_alias}"
|
23
|
+
%(<status type="#{@status}" sender="#{@sender_screen_name}" time="#{adium_formatted_time}" alias="#{@sender_alias}"/>)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -11,7 +11,7 @@ module Pipio
|
|
11
11
|
attr_reader :body
|
12
12
|
|
13
13
|
def to_s
|
14
|
-
%(<message sender="#{@sender_screen_name}" time="#{adium_formatted_time}" alias="#{@sender_alias}">#{@styled_body}</message
|
14
|
+
%(<message sender="#{@sender_screen_name}" time="#{adium_formatted_time}" alias="#{@sender_alias}">#{@styled_body}</message>)
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Pipio
|
2
2
|
class BasicParser
|
3
3
|
def initialize(source_file_path, my_aliases, line_regex, line_regex_status, cleaner)
|
4
|
-
@my_aliases = my_aliases
|
4
|
+
@my_aliases = my_aliases
|
5
5
|
@line_regex = line_regex
|
6
6
|
@line_regex_status = line_regex_status
|
7
7
|
@my_alias = @my_aliases.first
|
data/lib/pipio/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Parse a Pidgin HTML log file" do
|
4
|
+
it "outputs the correct data" do
|
5
|
+
chat = Pipio.parse(path_to_input_fixture, ["Gabe B-W"])
|
6
|
+
|
7
|
+
expect(chat.to_s).to eq expected_output_with_current_timezone_offset.strip
|
8
|
+
end
|
9
|
+
|
10
|
+
def path_to_output_fixture
|
11
|
+
File.join(SPEC_ROOT, "fixtures", "output.xml")
|
12
|
+
end
|
13
|
+
|
14
|
+
def expected_output_with_current_timezone_offset
|
15
|
+
File.read(path_to_output_fixture).gsub("-0400", timezone_offset)
|
16
|
+
end
|
17
|
+
|
18
|
+
def timezone_offset
|
19
|
+
Time.now.strftime("%z")
|
20
|
+
end
|
21
|
+
|
22
|
+
def path_to_input_fixture
|
23
|
+
File.join(SPEC_ROOT, "fixtures", "input.html")
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Conversation with them@gmail.com at 3/16/2014 11:55:43 PM on jiggerificbug (aim)</title></head><h3>Conversation with them@gmail.com at 3/16/2014 11:55:43 PM on jiggerificbug (aim)</h3>
|
2
|
+
<font color="#A82F2F"><font size="2">(2014-03-16 23:55:48)</font> <b>Some Rando:</b></font> Hi<br/>
|
3
|
+
<font color="#16569E"><font size="2">(2014-03-16 23:55:50)</font> <b>Gabe B-W:</b></font> Hi back<br/>
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<message sender="them@gmail.com" time="2014-03-16T23:55:48-0400" alias="Some Rando"><div><span style="font-family: Helvetica; font-size: 12pt;">Hi</span></div></message>
|
2
|
+
<message sender="jiggerificbug" time="2014-03-16T23:55:50-0400" alias="Gabe B-W"><div><span style="font-family: Helvetica; font-size: 12pt;">Hi back</span></div></message>
|
data/spec/pipio/chat_spec.rb
CHANGED
@@ -37,12 +37,12 @@ describe Pipio::Chat do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
describe '#
|
41
|
-
it 'is the start time of the chat
|
40
|
+
describe '#start_time' do
|
41
|
+
it 'is the start time of the chat' do
|
42
42
|
time = Time.now
|
43
43
|
chat = Pipio::Chat.new([], metadata(start_time: time))
|
44
44
|
|
45
|
-
expect(chat.
|
45
|
+
expect(chat.start_time).to eq(time)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -9,7 +9,7 @@ describe Pipio::AutoReplyMessage, '#to_s' do
|
|
9
9
|
|
10
10
|
it 'has the correct time' do
|
11
11
|
time = Time.now
|
12
|
-
formatted_time = time.xmlschema
|
12
|
+
formatted_time = time.xmlschema.sub(/:00$/, "00")
|
13
13
|
expect(auto_reply_message(time: time).to_s).to include %(time="#{formatted_time}")
|
14
14
|
end
|
15
15
|
|
@@ -7,7 +7,7 @@ describe Pipio::Event, '#to_s' do
|
|
7
7
|
|
8
8
|
it 'has the correct time' do
|
9
9
|
time = Time.now
|
10
|
-
formatted_time = time.xmlschema
|
10
|
+
formatted_time = time.xmlschema.sub(/:00$/, "00")
|
11
11
|
result = create_event(time: time).to_s
|
12
12
|
expect(result).to include %(time="#{formatted_time}")
|
13
13
|
end
|
@@ -7,7 +7,7 @@ describe Pipio::StatusMessage, '#to_s' do
|
|
7
7
|
|
8
8
|
it 'has the correct time' do
|
9
9
|
time = Time.now
|
10
|
-
formatted_time = time.xmlschema
|
10
|
+
formatted_time = time.xmlschema.sub(/:00$/, "00")
|
11
11
|
result = create_status_message(time: time).to_s
|
12
12
|
expect(result).to include %(time="#{formatted_time}")
|
13
13
|
end
|
@@ -28,10 +28,6 @@ describe Pipio::StatusMessage, '#to_s' do
|
|
28
28
|
expect(create_status_message.to_s).to match(/^<status/)
|
29
29
|
end
|
30
30
|
|
31
|
-
it 'ends in a newline' do
|
32
|
-
expect(create_status_message.to_s).to match(/\n$/)
|
33
|
-
end
|
34
|
-
|
35
31
|
def create_status_message(opts = {})
|
36
32
|
opts[:sender_screen_name] ||= 'jim_sender'
|
37
33
|
opts[:time] ||= Time.now
|
@@ -9,7 +9,7 @@ describe Pipio::XMLMessage, '#to_s' do
|
|
9
9
|
|
10
10
|
it 'has the correct time' do
|
11
11
|
time = Time.now
|
12
|
-
formatted_time = time.xmlschema
|
12
|
+
formatted_time = time.xmlschema.sub(/:00$/, "00")
|
13
13
|
expect(create_xml_message(time: time).to_s).to include %(time="#{formatted_time}")
|
14
14
|
end
|
15
15
|
|
data/spec/pipio/metadata_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
describe Pipio::Metadata do
|
2
2
|
context '#service' do
|
3
|
-
it "returns the service" do
|
4
|
-
metadata = Pipio::Metadata.new(service:
|
5
|
-
expect(metadata.service).to eq
|
3
|
+
it "returns the service name" do
|
4
|
+
metadata = Pipio::Metadata.new(service: "aim")
|
5
|
+
expect(metadata.service).to eq "aim"
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -149,12 +149,12 @@ describe Pipio::HtmlLogParser do
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
def build_chat(aliases = 'Gabe B-W', &block)
|
152
|
+
def build_chat(aliases = ['Gabe B-W'], &block)
|
153
153
|
file = create_chat_file('file.html', &block)
|
154
|
-
Pipio::HtmlLogParser.new(file.path, aliases).parse
|
154
|
+
Pipio::HtmlLogParser.new(file.path, Array(aliases)).parse
|
155
155
|
end
|
156
156
|
|
157
|
-
def first_line_of_chat(aliases = 'Gabe B-W', &block)
|
158
|
-
build_chat(aliases, &block).messages.first
|
157
|
+
def first_line_of_chat(aliases = ['Gabe B-W'], &block)
|
158
|
+
build_chat(Array(aliases), &block).messages.first
|
159
159
|
end
|
160
160
|
end
|
@@ -30,8 +30,8 @@ describe Pipio::TextLogParser do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def build_chat(aliases = 'Gabe B-W', &block)
|
33
|
+
def build_chat(aliases = ['Gabe B-W'], &block)
|
34
34
|
path = create_chat_file('file.txt', &block).path
|
35
|
-
Pipio::TextLogParser.new(path, aliases).parse
|
35
|
+
Pipio::TextLogParser.new(path, Array(aliases)).parse
|
36
36
|
end
|
37
37
|
end
|
data/spec/pipio_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabe Berke-Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mocha
|
@@ -106,6 +106,9 @@ files:
|
|
106
106
|
- lib/pipio/time_parser.rb
|
107
107
|
- lib/pipio/version.rb
|
108
108
|
- pipio.gemspec
|
109
|
+
- spec/features/parsing_an_html_file_spec.rb
|
110
|
+
- spec/fixtures/input.html
|
111
|
+
- spec/fixtures/output.xml
|
109
112
|
- spec/pipio/alias_registry_spec.rb
|
110
113
|
- spec/pipio/chat_spec.rb
|
111
114
|
- spec/pipio/cleaners/html_cleaner_spec.rb
|
@@ -161,6 +164,9 @@ signing_key:
|
|
161
164
|
specification_version: 4
|
162
165
|
summary: A fast, easy way to parse Pidgin (gaim) logs
|
163
166
|
test_files:
|
167
|
+
- spec/features/parsing_an_html_file_spec.rb
|
168
|
+
- spec/fixtures/input.html
|
169
|
+
- spec/fixtures/output.xml
|
164
170
|
- spec/pipio/alias_registry_spec.rb
|
165
171
|
- spec/pipio/chat_spec.rb
|
166
172
|
- spec/pipio/cleaners/html_cleaner_spec.rb
|