colander 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ script: bundle exec rspec spec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Colander
1
+ Colander [![Build Status](https://secure.travis-ci.org/mynewsdesk/colander.png?branch=master)](http://travis-ci.org/mynewsdesk/colander)
2
2
  ==============
3
3
  Colander is a gem to collect emails from various file formats.
4
4
 
@@ -6,6 +6,8 @@ Supported formats
6
6
 
7
7
  * "Old" Ms Excel files, ending in .xls
8
8
  * Ms Excel files ending with .xlsx
9
+ * CSV, Comma-separated values
10
+ * Plain text files
9
11
 
10
12
  Usage
11
13
  -----
@@ -0,0 +1,14 @@
1
+ require 'colander/invalid_file'
2
+ require 'colander/parser/base'
3
+ module Colander
4
+ module Parser
5
+ class Plain < Base
6
+
7
+ protected
8
+
9
+ def payload
10
+ File.read(@file_path)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Colander
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/colander.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'colander/invalid_file'
2
2
  require 'colander/parser/xls'
3
3
  require 'colander/parser/xlsx'
4
+ require 'colander/parser/plain'
4
5
 
5
6
  module Colander
6
7
  def self.parse(file_path, file_name = nil)
@@ -9,6 +10,8 @@ module Colander
9
10
  Parser::Xls.new(file_path)
10
11
  when "xlsx"
11
12
  Parser::Xlsx.new(file_path)
13
+ when "csv", "txt"
14
+ Parser::Plain.new(file_path)
12
15
  else
13
16
  raise InvalidFile
14
17
  end
@@ -0,0 +1,3 @@
1
+ name, email, phone
2
+ Jonas, jonas.forsberg@mynewsdesk.com, +460011234567
3
+ Peter, "peter.forsberg@xhockeypro.com", +46 11 2 34567
@@ -0,0 +1,10 @@
1
+ jonas.forsberg@mynewsdesk.com 243toå2bguaenrg kristian.hellquist@mynewsdesk.com fwe
2
+ fw
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ wef wgfaorug nareg richard@mynewsdesk.com
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ describe Colander::Parser::Plain do
3
+
4
+ describe "#parse" do
5
+ it "retreives emails from an csv file" do
6
+ parser = Colander::Parser::Plain.new("spec/fixtures/plain.csv")
7
+ parser.parse
8
+ parser.emails.sort.should eql(["jonas.forsberg@mynewsdesk.com", "peter.forsberg@xhockeypro.com"].sort)
9
+ end
10
+
11
+ it "retreives emails from an txt file" do
12
+ parser = Colander::Parser::Plain.new("spec/fixtures/text.txt")
13
+ parser.parse
14
+ parser.emails.sort.should eql(["jonas.forsberg@mynewsdesk.com", "kristian.hellquist@mynewsdesk.com", "richard@mynewsdesk.com"].sort)
15
+ end
16
+
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-22 00:00:00.000000000 Z
13
+ date: 2012-05-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: zip
17
- requirement: &70167375704040 !ruby/object:Gem::Requirement
17
+ requirement: &70136032687520 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 2.0.2
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70167375704040
25
+ version_requirements: *70136032687520
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &70167375703500 !ruby/object:Gem::Requirement
28
+ requirement: &70136032687100 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70167375703500
36
+ version_requirements: *70136032687100
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: pry
39
- requirement: &70167375702820 !ruby/object:Gem::Requirement
39
+ requirement: &70136032686640 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70167375702820
47
+ version_requirements: *70136032686640
48
48
  description: Exctract an array of emails from various file formats (xls, xlsx)
49
49
  email:
50
50
  - dev@mynewsdesk.com
@@ -55,6 +55,7 @@ files:
55
55
  - .gitignore
56
56
  - .rbenv-version
57
57
  - .rvmrc
58
+ - .travis.yml
58
59
  - Gemfile
59
60
  - README.md
60
61
  - Rakefile
@@ -63,6 +64,7 @@ files:
63
64
  - lib/colander/invalid_file.rb
64
65
  - lib/colander/parser/base.rb
65
66
  - lib/colander/parser/null.rb
67
+ - lib/colander/parser/plain.rb
66
68
  - lib/colander/parser/xls.rb
67
69
  - lib/colander/parser/xlsx.rb
68
70
  - lib/colander/version.rb
@@ -72,7 +74,10 @@ files:
72
74
  - spec/fixtures/excel95.xls
73
75
  - spec/fixtures/new-format.xlsx
74
76
  - spec/fixtures/old-format.xls
77
+ - spec/fixtures/plain.csv
75
78
  - spec/fixtures/samples/golferns.xlsx
79
+ - spec/fixtures/text.txt
80
+ - spec/plain_spec.rb
76
81
  - spec/spec_helper.rb
77
82
  - spec/xls_spec.rb
78
83
  - spec/xlsx_spec.rb
@@ -107,7 +112,10 @@ test_files:
107
112
  - spec/fixtures/excel95.xls
108
113
  - spec/fixtures/new-format.xlsx
109
114
  - spec/fixtures/old-format.xls
115
+ - spec/fixtures/plain.csv
110
116
  - spec/fixtures/samples/golferns.xlsx
117
+ - spec/fixtures/text.txt
118
+ - spec/plain_spec.rb
111
119
  - spec/spec_helper.rb
112
120
  - spec/xls_spec.rb
113
121
  - spec/xlsx_spec.rb