embratel 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@bell --create
data/Gemfile.lock CHANGED
@@ -1,13 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- embratel (0.0.1)
5
- fastercsv (= 1.5.3)
4
+ embratel (0.0.2)
6
5
 
7
6
  GEM
8
7
  remote: http://rubygems.org/
9
8
  specs:
10
- fastercsv (1.5.3)
11
9
  rake (0.8.7)
12
10
 
13
11
  PLATFORMS
@@ -16,5 +14,4 @@ PLATFORMS
16
14
  DEPENDENCIES
17
15
  bundler (>= 1.0.0)
18
16
  embratel!
19
- fastercsv (= 1.5.3)
20
17
  rake (= 0.8.7)
data/README.org CHANGED
@@ -1,7 +1,7 @@
1
1
  * embratel
2
2
  ** Instalando
3
3
  #+BEGIN_SRC
4
- gem install embratel
4
+ $ gem install embratel
5
5
  #+END_SRC
6
6
  Você precisa ter o ruby e o rubygems instalados.
7
7
 
@@ -25,13 +25,14 @@ Embratel::Call
25
25
 
26
26
  *** Com o arquivo da fatura você pode
27
27
  #+BEGIN_SRC
28
- phone_bill = Embratel::PhoneBill.new("/path/to/fatura.csv")
28
+ # Instancie uma fatura.
29
+ >> phone_bill = Embratel::PhoneBill.new("/path/to/fatura.csv")
29
30
 
30
- # array com todas as ligações da fatura (array de objetos Embratel::Call)
31
- phone_bill.calls
31
+ # PhoneBill#calls retorna um array com todas as ligações da fatura (objetos Embratel::Call).
32
+ >> phone_bill.calls
32
33
 
33
- # custo total da fatura
34
- phone_bill.total
34
+ # PhoneBill#total retorna o custo total da fatura.
35
+ >> phone_bill.total
35
36
  #+END_SRC
36
37
 
37
38
  *** attr_accessors disponíveis para objetos Embratel::Call
@@ -55,23 +56,23 @@ cost
55
56
  ** Para rodar os testes
56
57
  *** Pegue o código
57
58
  #+BEGIN_SRC
58
- git clone git://github.com/murilasso/embratel.git
59
- cd embratel
59
+ $ git clone git://github.com/murilasso/embratel.git
60
+ $ cd embratel
60
61
  #+END_SRC
61
62
 
62
63
  *** Instale o bundler e as dependências (se já não estiverem instaladas)
63
64
  #+BEGIN_SRC
64
- gem install bundler
65
- bundle install
65
+ $ gem install bundler
66
+ $ bundle install
66
67
  #+END_SRC
67
68
 
68
69
  *** Rode os testes
69
70
  #+BEGIN_SRC
70
- rake test
71
+ $ rake test
71
72
  #+END_SRC
72
73
 
73
74
  ** Autor
74
- [[http://www.comp.ufscar.br/~murilo][Murilo Soares Pereira]]
75
+ [[http://murilopereira.com][Murilo Pereira]]
75
76
 
76
77
  ** Licença
77
78
  Distribuído sob a [[http://github.com/murilasso/embratel/blob/master/MIT-LICENSE][licença MIT]].
data/embratel.gemspec CHANGED
@@ -1,22 +1,23 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path("../lib/embratel", __FILE__)
2
+
3
+ require File.expand_path('../lib/embratel', __FILE__)
3
4
 
4
5
  Gem::Specification.new do |s|
5
- s.name = "embratel"
6
+ s.name = 'embratel'
6
7
  s.version = Embratel::VERSION
7
8
  s.platform = Gem::Platform::RUBY
8
- s.authors = ["Murilo Soares Pereira"]
9
- s.email = ["murilo.soares3@gmail.com"]
10
- s.homepage = "http://github.com/murilasso/embratel"
11
- s.summary = "Extract calls information from Embratel's phone bill files."
9
+ s.author = 'Murilo Pereira'
10
+ s.email = 'murilo@murilopereira.com'
11
+ s.homepage = 'https://github.com/murilasso/embratel'
12
+ s.summary = "Easily extract data from Embratel's phone bill files."
12
13
 
13
- s.required_rubygems_version = ">= 1.3.6"
14
- s.rubyforge_project = "embratel"
14
+ s.required_rubygems_version = '>= 1.3.6'
15
+ s.rubyforge_project = 'embratel'
15
16
 
16
- s.add_development_dependency "bundler", ">= 1.0.0"
17
- s.add_development_dependency "rake", "0.8.7"
17
+ s.add_development_dependency 'bundler', '>= 1.0.0'
18
+ s.add_development_dependency 'rake', '0.8.7'
18
19
 
19
- s.add_dependency "fastercsv", "1.5.3"
20
+ s.add_dependency('fastercsv', '1.5.3') if RUBY_VERSION < '1.9'
20
21
 
21
22
  s.files = `git ls-files`.split("\n")
22
23
  s.require_path = 'lib'
data/lib/embratel.rb CHANGED
@@ -1,8 +1,15 @@
1
- require 'embratel/phone_bill'
2
- require 'embratel/call'
1
+ if RUBY_VERSION < '1.9'
2
+ require 'fastercsv'
3
+ CSV = FasterCSV
4
+ else
5
+ require 'csv'
6
+ end
7
+
8
+ require 'embratel/call.rb'
9
+ require 'embratel/phone_bill.rb'
3
10
 
4
11
  module Embratel
5
- VERSION = "0.0.2"
12
+ VERSION = '1.0.0'
6
13
 
7
14
  class InvalidPhoneBillFileError < StandardError; end
8
15
  end
data/lib/embratel/call.rb CHANGED
@@ -2,8 +2,7 @@ module Embratel
2
2
  class Call
3
3
  NUMBER_CALLED_REGEXP = /^\d{10}$/
4
4
  COST_REGEXP = /^\d*(\.\d+)?$/
5
- FIELDS = %w[
6
- id
5
+ FIELDS = %w[id
7
6
  caller
8
7
  description
9
8
  date
@@ -16,8 +15,7 @@ module Embratel
16
15
  country
17
16
  quantity
18
17
  unit
19
- cost
20
- ]
18
+ cost]
21
19
 
22
20
  FIELDS.each { |field| attr_accessor field.to_sym }
23
21
 
@@ -1,15 +1,13 @@
1
- require 'fastercsv'
2
-
3
1
  module Embratel
4
2
  class PhoneBill
5
3
  def initialize(path)
6
4
  begin
7
- @csv = FasterCSV.read(path, { :skip_blanks => true })
5
+ @csv = CSV.read(path, { :skip_blanks => true })
8
6
  rescue Errno::ENOENT
9
7
  raise
10
8
  rescue Errno::EISDIR
11
9
  raise
12
- rescue FasterCSV::MalformedCSVError
10
+ rescue CSV::MalformedCSVError
13
11
  raise
14
12
  else
15
13
  raise InvalidPhoneBillFileError if (invalid_rows? || non_csv?(path))
@@ -2,8 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class CallTest < Test::Unit::TestCase
4
4
  def row_with_a_missing_field
5
- [
6
- '1',
5
+ ['1',
7
6
  '1634125644-FRANQUIA 01',
8
7
  '04 - LIGACOES DDD PARA CELULARES',
9
8
  '11/08/10 A 99/99/99',
@@ -15,13 +14,11 @@ class CallTest < Test::Unit::TestCase
15
14
  '',
16
15
  '500',
17
16
  'MIN',
18
- '0.73'
19
- ]
17
+ '0.73']
20
18
  end
21
19
 
22
20
  def row_with_invalid_number_called
23
- [
24
- '1',
21
+ ['1',
25
22
  '1634125644-FRANQUIA 01',
26
23
  '04 - LIGACOES DDD PARA CELULARES',
27
24
  '11/08/10 A 99/99/99',
@@ -34,13 +31,11 @@ class CallTest < Test::Unit::TestCase
34
31
  '',
35
32
  '500',
36
33
  'MIN',
37
- '0.73'
38
- ]
34
+ '0.73']
39
35
  end
40
36
 
41
37
  def row_with_invalid_cost
42
- [
43
- '1',
38
+ ['1',
44
39
  '1634125644-FRANQUIA 01',
45
40
  '04 - LIGACOES DDD PARA CELULARES',
46
41
  '11/08/10 A 99/99/99',
@@ -53,13 +48,11 @@ class CallTest < Test::Unit::TestCase
53
48
  '',
54
49
  '500',
55
50
  'MIN',
56
- '.73'
57
- ]
51
+ '.73']
58
52
  end
59
53
 
60
54
  def valid_row
61
- [
62
- '1',
55
+ ['1',
63
56
  '1634125644-FRANQUIA 01',
64
57
  '04 - LIGACOES DDD PARA CELULARES',
65
58
  '11/08/10 A 99/99/99',
@@ -72,8 +65,7 @@ class CallTest < Test::Unit::TestCase
72
65
  '',
73
66
  '500',
74
67
  'MIN',
75
- '0.73'
76
- ]
68
+ '0.73']
77
69
  end
78
70
 
79
71
  def test_call_instantiated_with_a_row_with_a_missing_field
data/test/test_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
2
  require 'rubygems'
4
3
  require 'embratel'
metadata CHANGED
@@ -1,21 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embratel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
4
+ prerelease:
5
+ version: 1.0.0
11
6
  platform: ruby
12
7
  authors:
13
- - Murilo Soares Pereira
8
+ - Murilo Pereira
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-11-05 00:00:00 -02:00
13
+ date: 2011-03-20 00:00:00 -03:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,11 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ">="
28
23
  - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 1
32
- - 0
33
- - 0
34
24
  version: 1.0.0
35
25
  type: :development
36
26
  version_requirements: *id001
@@ -42,33 +32,11 @@ dependencies:
42
32
  requirements:
43
33
  - - "="
44
34
  - !ruby/object:Gem::Version
45
- hash: 49
46
- segments:
47
- - 0
48
- - 8
49
- - 7
50
35
  version: 0.8.7
51
36
  type: :development
52
37
  version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: fastercsv
55
- prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - "="
60
- - !ruby/object:Gem::Version
61
- hash: 5
62
- segments:
63
- - 1
64
- - 5
65
- - 3
66
- version: 1.5.3
67
- type: :runtime
68
- version_requirements: *id003
69
38
  description:
70
- email:
71
- - murilo.soares3@gmail.com
39
+ email: murilo@murilopereira.com
72
40
  executables: []
73
41
 
74
42
  extensions: []
@@ -77,6 +45,7 @@ extra_rdoc_files: []
77
45
 
78
46
  files:
79
47
  - .gitignore
48
+ - .rvmrc
80
49
  - Gemfile
81
50
  - Gemfile.lock
82
51
  - MIT-LICENSE
@@ -94,7 +63,7 @@ files:
94
63
  - test/fixtures/valid_phone_bill_file.csv
95
64
  - test/test_helper.rb
96
65
  has_rdoc: true
97
- homepage: http://github.com/murilasso/embratel
66
+ homepage: https://github.com/murilasso/embratel
98
67
  licenses: []
99
68
 
100
69
  post_install_message:
@@ -107,27 +76,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
76
  requirements:
108
77
  - - ">="
109
78
  - !ruby/object:Gem::Version
110
- hash: 3
111
- segments:
112
- - 0
113
79
  version: "0"
114
80
  required_rubygems_version: !ruby/object:Gem::Requirement
115
81
  none: false
116
82
  requirements:
117
83
  - - ">="
118
84
  - !ruby/object:Gem::Version
119
- hash: 23
120
- segments:
121
- - 1
122
- - 3
123
- - 6
124
85
  version: 1.3.6
125
86
  requirements: []
126
87
 
127
88
  rubyforge_project: embratel
128
- rubygems_version: 1.3.7
89
+ rubygems_version: 1.6.2
129
90
  signing_key:
130
91
  specification_version: 3
131
- summary: Extract calls information from Embratel's phone bill files.
92
+ summary: Easily extract data from Embratel's phone bill files.
132
93
  test_files: []
133
94