brdata 2.1.15 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -13,11 +13,6 @@ PKG_NAME = "brdata"
13
13
  PKG_VERSION = BrData::VERSION::STRING + PKG_BUILD
14
14
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
15
15
 
16
- RELEASE_NAME = "REL #{PKG_VERSION}"
17
-
18
- RUBY_FORGE_PROJECT = "brdata"
19
- RUBY_FORGE_USER = "tapajos"
20
-
21
16
  desc "Default Task"
22
17
  task :default => [ :test ]
23
18
 
@@ -48,13 +43,16 @@ spec = Gem::Specification.new do |s|
48
43
  s.description = %q{brdata é uma das gems que compoem o Brazilian Rails}
49
44
  s.version = PKG_VERSION
50
45
 
51
- s.authors = ["Marcos Tapajós", "Celestino Gomes", "Andre Kupkosvki", "Vinícius Teles"]
52
- s.email = "tapajos@gmail.com"
46
+ s.authors = ["Marcos Tapajós", "Celestino Gomes", "Andre Kupkosvki", "Vinícius Teles", "Felipe Barreto", "Rafael Walter", "Cassio Marques"]
47
+ s.email = %w"tapajos@gmail.com tinorj@gmail.com kupkovski@gmail.com vinicius.m.teles@gmail.com felipebarreto@gmail.com rafawalter@gmail.com cassiommc@gmail.com"
53
48
  s.rubyforge_project = "brdata"
54
49
  s.homepage = "http://www.improveit.com.br/software_livre/brazilian_rails"
55
50
 
56
- s.add_dependency("actionpack", ">= 2.3.2", "< 3.0.0")
57
- s.add_dependency("activesupport", ">= 2.3.2", "< 3.0.0")
51
+ s.add_dependency("actionpack", ">= 3.0.0")
52
+ s.add_dependency("activesupport", ">= 3.0.0")
53
+
54
+ s.add_development_dependency "rake"
55
+ s.add_development_dependency "mocha"
58
56
 
59
57
  s.has_rdoc = true
60
58
  s.requirements << "none"
@@ -72,5 +70,5 @@ end
72
70
 
73
71
  desc "Publish the release files to RubyForge."
74
72
  task :release => [ :package ] do
75
- `gem push pkg/#{PKG_NAME}-#{PKG_VERSION}.gem`
73
+ `gem push pkg/#{PKG_FILE_NAME}.gem`
76
74
  end
@@ -1,19 +1,21 @@
1
- module ActiveSupport::CoreExtensions::String::Conversions
1
+ class String
2
2
  # Cria a data no padrao brasileiro e permanece aceitando no formato tradicional.
3
3
  #
4
4
  # Exemplo:
5
5
  # "27/09/2007".to_date
6
+ alias_method :_original_to_date, :to_date
7
+
6
8
  def to_date
7
- if /(\d{1,2})\W(\d{1,2})\W(\d{4})/ =~ self
9
+ if /^(0[1-9]|[12]\d|3[01])\W(0[1-9]|1[012])\W(\d{4})$/ =~ self
8
10
  ::Date.new($3.to_i, $2.to_i, $1.to_i)
9
11
  else
10
- ::Date.new(*::Date._parse(self, false).values_at(:year, :mon, :mday))
12
+ _original_to_date
11
13
  end
12
14
  end
13
15
  end
14
16
 
15
17
  class Date
16
-
18
+
17
19
  # Retorna a data no padrao brasileiro
18
20
  #
19
21
  # Exemplo:
@@ -22,7 +24,7 @@ class Date
22
24
  def to_s_br
23
25
  strftime("%d/%m/%Y")
24
26
  end
25
-
27
+
26
28
  # Valida se uma string eh uma data valida
27
29
  #
28
30
  # Exemplo:
@@ -31,13 +33,13 @@ class Date
31
33
  def self.valid?(date)
32
34
  begin
33
35
  date = date.to_date
34
- Date.valid_civil?(date.year, date.month, date.day)
36
+ Date.valid_civil?(date.year, date.month, date.day)
35
37
  rescue
36
38
  return false
37
39
  end
38
40
  true
39
41
  end
40
-
42
+
41
43
  end
42
44
 
43
45
  class NilClass
@@ -45,3 +47,4 @@ class NilClass
45
47
  ""
46
48
  end
47
49
  end
50
+
@@ -1,14 +1,15 @@
1
- module ActiveSupport::CoreExtensions::String::Conversions
1
+ class String
2
2
  # Cria a data com horário no padrao brasileiro e permanece aceitando no formato tradicional.
3
3
  #
4
4
  # Exemplo:
5
5
  # "27/09/2007 01:23".to_date
6
-
6
+ alias_method :_original_to_time, :to_time
7
+
7
8
  def to_time
8
- if /(\d{1,2})\W(\d{1,2})\W(\d{4})(\s((\d{1,2}):(\d{2})))?/ =~ self
9
- ::Time.mktime($3.to_i, $2.to_i, $1.to_i, $6.to_i, $7.to_i)
9
+ if /^(0?[1-9]|[12]\d|3[01])\W(0?[1-9]|1[012])\W(\d{4})(\W([01]?\d|2[0123])\W([0-5]?\d)\W?([0-5]\d)?)?$/ =~ self
10
+ ::Time.mktime($3.to_i, $2.to_i, $1.to_i, $5.to_i, $6.to_i, $7.to_i)
10
11
  else
11
- ::Time.parse self
12
+ _original_to_time
12
13
  end
13
14
  end
14
15
  end
@@ -25,7 +26,7 @@ class Time
25
26
  def to_s_br
26
27
  self.strftime("%d/%m/%Y %H:%M")
27
28
  end
28
-
29
+
29
30
  # Formata a hora usando nomes de dias e meses em Portugues
30
31
  # Exemplo:
31
32
  # hora = Time.new
@@ -39,4 +40,5 @@ class Time
39
40
  format.gsub!(/%B/, Date::MONTHNAMES[self.mon])
40
41
  self.strftime_nolocale(format)
41
42
  end
42
- end
43
+ end
44
+
@@ -1,9 +1,10 @@
1
1
  module BrData
2
2
  module VERSION #:nodoc:
3
- MAJOR = 2
4
- MINOR = 1
5
- TINY = 15
3
+ MAJOR = 3
4
+ MINOR = 0
5
+ TINY = 0
6
6
 
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{TINY}"
8
8
  end
9
9
  end
10
+
@@ -1,38 +1,40 @@
1
1
  # encoding: UTF-8
2
2
  require File.dirname(__FILE__) + '/test_helper'
3
+ require 'rubygems'
4
+ require 'active_support/all'
3
5
 
4
6
  class FeriadoTest < Test::Unit::TestCase
5
-
7
+
6
8
  ATRIBUTOS = %w(dia mes nome)
7
-
8
- # feriado
9
+
10
+ # feriado
9
11
  def test_feriado_quando_feriado
10
12
  assert "25/12/2007".to_date.feriado?
11
13
  end
12
-
14
+
13
15
  def test_feriado_quando_nao_eh_feriado
14
16
  assert !"01/12/2007".to_date.feriado?
15
17
  end
16
-
18
+
17
19
  def test_feriado_quando_feriado_eh_pascoa
18
20
  assert "08/04/2007".to_date.feriado?
19
21
  end
20
-
22
+
21
23
  def test_feriado_quando_feriado_eh_corpus_christi
22
24
  assert "07/06/2007".to_date.feriado?
23
25
  end
24
-
26
+
25
27
  # pascoa
26
28
  def test_pascoa
27
29
  assert_equal "08/04/2007", "01/01/2007".to_date.pascoa.to_s_br
28
30
  end
29
-
31
+
30
32
  # corpus_christi
31
33
  def test_corpus_christi
32
34
  assert_equal "07/06/2007", "01/01/2007".to_date.corpus_christi.to_s_br
33
35
  end
34
-
35
-
36
+
37
+
36
38
  def test_attributes
37
39
  feriado = Feriado.new("nome", "01", "01")
38
40
  ATRIBUTOS.each do |atributo|
@@ -40,7 +42,7 @@ class FeriadoTest < Test::Unit::TestCase
40
42
  assert_respond_to feriado, "#{atributo}=", "Deveria existir o método #{atributo}="
41
43
  end
42
44
  end
43
-
45
+
44
46
  def test_initialize
45
47
  feriado = Feriado.new("nome", "01", "01")
46
48
  assert feriado, "deveria ter criado um feriado"
@@ -48,7 +50,7 @@ class FeriadoTest < Test::Unit::TestCase
48
50
  assert_equal 1, feriado.dia
49
51
  assert_equal 1, feriado.mes
50
52
  end
51
-
53
+
52
54
  def test_initialize_com_dia_invalido
53
55
  ['a', 0, -1, 32, '32', '-1', '0'].each do |invalid_day|
54
56
  assert_raise FeriadoDiaInvalidoError do
@@ -57,22 +59,23 @@ class FeriadoTest < Test::Unit::TestCase
57
59
  end
58
60
  end
59
61
  end
60
-
62
+
61
63
  def test_initialize_com_mes_invalido
62
- ['a', '13', 13, -1, '-1', '0'].each do |invalid_month|
64
+ ['a', '13', 13, -1, '-1', '0'].each do |invalid_month|
63
65
  assert_raise FeriadoMesInvalidoError do
64
- Feriado.new("nome", "01", invalid_month)
66
+ Feriado.new("nome", "01", invalid_month)
65
67
  raise "Deveria retornar FeriadoMesInvalidoError para mês #{invalid_month}"
66
68
  end
67
69
  end
68
70
  end
69
-
71
+
70
72
  def test_igualdade
71
73
  assert_equal Feriado.new("nome", "01", "01"), Feriado.new("nome2", "01", "01")
72
74
  end
73
-
75
+
74
76
  def test_igualdade_quando_nao_eh_igual
75
77
  assert_not_equal Feriado.new("nome", "01", "01"), Feriado.new("nome2", "01", "02")
76
78
  end
77
79
 
78
80
  end
81
+
metadata CHANGED
@@ -1,24 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brdata
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
- - 2
8
- - 1
9
- - 15
10
- version: 2.1.15
7
+ - 3
8
+ - 0
9
+ - 0
10
+ version: 3.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Marcos Tapaj\xC3\xB3s"
14
14
  - Celestino Gomes
15
15
  - Andre Kupkosvki
16
16
  - "Vin\xC3\xADcius Teles"
17
+ - Felipe Barreto
18
+ - Rafael Walter
19
+ - Cassio Marques
17
20
  autorequire:
18
21
  bindir: bin
19
22
  cert_chain: []
20
23
 
21
- date: 2010-11-05 00:00:00 -02:00
24
+ date: 2010-10-23 00:00:00 -02:00
22
25
  default_executable:
23
26
  dependencies:
24
27
  - !ruby/object:Gem::Dependency
@@ -28,14 +31,6 @@ dependencies:
28
31
  none: false
29
32
  requirements:
30
33
  - - ">="
31
- - !ruby/object:Gem::Version
32
- hash: 7
33
- segments:
34
- - 2
35
- - 3
36
- - 2
37
- version: 2.3.2
38
- - - <
39
34
  - !ruby/object:Gem::Version
40
35
  hash: 7
41
36
  segments:
@@ -52,14 +47,6 @@ dependencies:
52
47
  none: false
53
48
  requirements:
54
49
  - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 7
57
- segments:
58
- - 2
59
- - 3
60
- - 2
61
- version: 2.3.2
62
- - - <
63
50
  - !ruby/object:Gem::Version
64
51
  hash: 7
65
52
  segments:
@@ -69,8 +56,43 @@ dependencies:
69
56
  version: 3.0.0
70
57
  type: :runtime
71
58
  version_requirements: *id002
59
+ - !ruby/object:Gem::Dependency
60
+ name: rake
61
+ prerelease: false
62
+ requirement: &id003 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ type: :development
72
+ version_requirements: *id003
73
+ - !ruby/object:Gem::Dependency
74
+ name: mocha
75
+ prerelease: false
76
+ requirement: &id004 !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ type: :development
86
+ version_requirements: *id004
72
87
  description: "brdata \xC3\xA9 uma das gems que compoem o Brazilian Rails"
73
- email: tapajos@gmail.com
88
+ email:
89
+ - tapajos@gmail.com
90
+ - tinorj@gmail.com
91
+ - kupkovski@gmail.com
92
+ - vinicius.m.teles@gmail.com
93
+ - felipebarreto@gmail.com
94
+ - rafawalter@gmail.com
95
+ - cassiommc@gmail.com
74
96
  executables: []
75
97
 
76
98
  extensions: []