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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a27a6c6a854887062351e5a362482a44990ce35e
4
- data.tar.gz: 455730fbf37e619f747cfe89d0612fb42ee85999
3
+ metadata.gz: a14d4d97d6bee17bf6a0889212efae784e929d64
4
+ data.tar.gz: 6bcc28a685bc84d70b81031d71023bd8ed5c1413
5
5
  SHA512:
6
- metadata.gz: 0192a3e9a130603f28698edc216007c30321a921c4b66a6a3cea5368a02262f0be2037802408b5a7576552c1d625e246da06447f4f5ac37ccd735695b18c86c0
7
- data.tar.gz: 532da7ab24471befe059573f39d99dd65b214de408783215f0e3e73272088550d03d531834b882a4af14349b7904c1c3e50ce371947ae3bf562f61cf96acb07b
6
+ metadata.gz: 88e2f94f3c5e2f668338f853e64f61dae962ea75f26b91b72f4485dbf645b3d52975dc88a7f9eaae7363aab6cabf01f160bcee533c7c6ff524b3e3fb397b786f
7
+ data.tar.gz: 063b79775485aae8282c2e783d44dc485bbdfaa661be142a1aa5461764355ca6d3c5997a884ba3cb1ed1685b0a34b254c87d85c3f5fadf5dd413a149b9b2e628
data/NEWS.md CHANGED
@@ -1,4 +1,13 @@
1
- ## 0.0.1 (unreleased)
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}"
@@ -11,8 +11,8 @@ module Pipio
11
11
 
12
12
  attr_reader :messages
13
13
 
14
- def start_time_xmlschema
15
- @metadata.start_time.xmlschema
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
- map(&:to_s).join("\n")
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>\n)
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
@@ -17,7 +17,7 @@ module Pipio
17
17
  private
18
18
 
19
19
  def adium_formatted_time
20
- @time.xmlschema
20
+ @time.xmlschema.sub(/:00$/, "00")
21
21
  end
22
22
  end
23
23
  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}"/>\n)
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>\n)
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.split(',')
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
@@ -1,3 +1,3 @@
1
1
  module Pipio
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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>
@@ -37,12 +37,12 @@ describe Pipio::Chat do
37
37
  end
38
38
  end
39
39
 
40
- describe '#start_time_xmlschema' do
41
- it 'is the start time of the chat in xmlschema format' do
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.start_time_xmlschema).to eq(time.xmlschema)
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
 
@@ -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: 'aim')
5
- expect(metadata.service).to eq('aim')
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
 
@@ -1,5 +1,5 @@
1
1
  describe Pipio::ParserFactory do
2
- let(:aliases) { '' }
2
+ let(:aliases) { [] }
3
3
 
4
4
  %w(html htm HTML).each do |html_extension|
5
5
  context "when passed a .#{html_extension} file" do
@@ -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
@@ -58,6 +58,6 @@ describe Pipio, ".parse" do
58
58
  end
59
59
 
60
60
  def aliases
61
- ''
61
+ []
62
62
  end
63
63
  end
@@ -9,6 +9,8 @@ require 'mocha/api'
9
9
 
10
10
  Dir['spec/support/**/*.rb'].each { |f| require File.expand_path(f) }
11
11
 
12
+ SPEC_ROOT = File.dirname(__FILE__)
13
+
12
14
  RSpec.configure do |config|
13
15
  config.mock_with :mocha
14
16
 
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.1
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-07-23 00:00:00.000000000 Z
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