brdinheiro 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 +8 -12
- data/lib/brdinheiro.rb +3 -10
- data/lib/brdinheiro/version.rb +4 -3
- data/test/active_record/base_without_table.rb +6 -5
- data/test/dinheiro_active_record_test.rb +10 -9
- data/test/test_helper.rb +3 -3
- metadata +37 -29
data/Rakefile
CHANGED
@@ -13,11 +13,6 @@ PKG_NAME = "brdinheiro"
|
|
13
13
|
PKG_VERSION = BrDinheiro::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 = "brdinheiro"
|
19
|
-
RUBY_FORGE_USER = "tapajos"
|
20
|
-
|
21
16
|
desc "Default Task"
|
22
17
|
task :default => [ :test ]
|
23
18
|
|
@@ -48,19 +43,20 @@ spec = Gem::Specification.new do |s|
|
|
48
43
|
s.description = %q{brdinheiro é 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 = "brdinheiro"
|
54
49
|
s.homepage = "http://www.improveit.com.br/software_livre/brazilian_rails"
|
55
50
|
|
56
|
-
s.add_dependency("actionpack", ">=
|
57
|
-
s.add_dependency("activerecord", ">=
|
58
|
-
s.add_dependency("brnumeros", "
|
51
|
+
s.add_dependency("actionpack", ">= 3.0.0")
|
52
|
+
s.add_dependency("activerecord", ">= 3.0.0")
|
53
|
+
s.add_dependency("brnumeros", ">= #{PKG_VERSION}")
|
54
|
+
|
55
|
+
s.add_development_dependency "rake"
|
59
56
|
|
60
57
|
s.has_rdoc = true
|
61
58
|
s.requirements << "brnumeros"
|
62
59
|
s.require_path = "lib"
|
63
|
-
#s.autorequire = "brnumeros"
|
64
60
|
|
65
61
|
s.files = [ "Rakefile", "README", "CHANGELOG", "MIT-LICENSE" ]
|
66
62
|
s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
@@ -73,5 +69,5 @@ end
|
|
73
69
|
|
74
70
|
desc "Publish the release files to RubyForge."
|
75
71
|
task :release => [ :package ] do
|
76
|
-
`gem push pkg/#{
|
72
|
+
`gem push pkg/#{PKG_FILE_NAME}.gem`
|
77
73
|
end
|
data/lib/brdinheiro.rb
CHANGED
@@ -10,20 +10,13 @@ nil_class).each {|req| require File.dirname(__FILE__) + "/brdinheiro/#{req}"}
|
|
10
10
|
%w(bigdecimal
|
11
11
|
rubygems
|
12
12
|
active_record
|
13
|
-
active_support).each {|req| require req }
|
13
|
+
active_support/all).each {|req| require req }
|
14
14
|
|
15
|
-
|
16
|
-
require 'brnumeros'
|
17
|
-
rescue MissingSourceFile
|
18
|
-
# probably not installed yet as a gem, so load from source
|
19
|
-
begin
|
20
|
-
require File.dirname(__FILE__) + '/../../brnumeros/lib/brnumeros'
|
21
|
-
rescue
|
22
|
-
end
|
23
|
-
end
|
15
|
+
require 'brnumeros'
|
24
16
|
|
25
17
|
String.send(:include, DinheiroUtil)
|
26
18
|
ActiveRecord::Base.send :include, DinheiroActiveRecord
|
27
19
|
|
28
20
|
module BrDinheiro
|
29
21
|
end
|
22
|
+
|
data/lib/brdinheiro/version.rb
CHANGED
@@ -3,11 +3,11 @@ require 'active_record'
|
|
3
3
|
module ActiveRecord
|
4
4
|
class BaseWithoutTable < Base
|
5
5
|
self.abstract_class = true
|
6
|
-
|
6
|
+
|
7
7
|
def create_or_update
|
8
8
|
errors.empty?
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def save
|
12
12
|
self.valid?
|
13
13
|
end
|
@@ -16,17 +16,18 @@ module ActiveRecord
|
|
16
16
|
def columns()
|
17
17
|
@columns ||= []
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def column(name, sql_type = nil, default = nil, null = true)
|
21
21
|
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
|
22
22
|
reset_column_information
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
# Do not reset @columns
|
26
26
|
def reset_column_information
|
27
|
-
|
27
|
+
undefine_attribute_methods
|
28
28
|
@column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = nil
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
@@ -5,33 +5,33 @@ class Carteira < ActiveRecord::BaseWithoutTable
|
|
5
5
|
column :saldo, :decimal
|
6
6
|
usar_como_dinheiro :saldo
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
class DinheiroActiveRecordTest < Test::Unit::TestCase
|
10
|
-
|
10
|
+
|
11
11
|
def setup
|
12
12
|
@carteira = Carteira.new
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def teste_se_aceita_dinheiro
|
16
16
|
@carteira.saldo = 8.reais
|
17
17
|
assert @carteira.save
|
18
18
|
assert_equal 8.reais, @carteira.saldo
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def teste_se_aceita_numero
|
22
22
|
@carteira.saldo = 30
|
23
23
|
assert @carteira.save
|
24
24
|
assert_equal 30.reais, @carteira.saldo
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def teste_se_rejeita_valor_invalido
|
28
28
|
@carteira.saldo = 30
|
29
29
|
assert @carteira.save
|
30
30
|
@carteira.saldo = 'bla'
|
31
31
|
assert_false @carteira.save
|
32
|
-
assert_equal "O valor deve estar preenchido e no formato correto. Ex.: 100.00 .", @carteira.errors['saldo']
|
32
|
+
assert_equal ["O valor deve estar preenchido e no formato correto. Ex.: 100.00 ."], @carteira.errors['saldo']
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def teste_se_trata_nulo_corretamente
|
36
36
|
assert_nil @carteira.saldo
|
37
37
|
@carteira.saldo = nil
|
@@ -39,10 +39,11 @@ class DinheiroActiveRecordTest < Test::Unit::TestCase
|
|
39
39
|
@carteira.save
|
40
40
|
assert_nil @carteira.saldo
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def test_se_cria_carteira_corretamente_quando_recebe_parametros
|
44
44
|
carteira = Carteira.new(:saldo => "1")
|
45
45
|
assert_equal 1.real, carteira.saldo
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
end
|
49
|
+
|
data/test/test_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + '/../../brnumeros/lib/brnumeros'
|
2
3
|
require File.dirname(__FILE__) + '/../lib/brdinheiro'
|
3
4
|
|
4
|
-
|
5
5
|
def tornar_metodos_publicos(clazz)
|
6
6
|
clazz.class_eval do
|
7
7
|
private_instance_methods.each { |instance_method| public instance_method }
|
8
|
-
private_methods.each { |method| public_class_method method }
|
9
|
-
end
|
8
|
+
private_methods.each { |method| public_class_method method }
|
9
|
+
end
|
10
10
|
end
|
11
11
|
|
12
12
|
def p80 text
|
metadata
CHANGED
@@ -1,24 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brdinheiro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version:
|
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-
|
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:
|
@@ -75,18 +62,39 @@ dependencies:
|
|
75
62
|
requirement: &id003 !ruby/object:Gem::Requirement
|
76
63
|
none: false
|
77
64
|
requirements:
|
78
|
-
- - "
|
65
|
+
- - ">="
|
79
66
|
- !ruby/object:Gem::Version
|
80
|
-
hash:
|
67
|
+
hash: 7
|
81
68
|
segments:
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
version:
|
69
|
+
- 3
|
70
|
+
- 0
|
71
|
+
- 0
|
72
|
+
version: 3.0.0
|
86
73
|
type: :runtime
|
87
74
|
version_requirements: *id003
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rake
|
77
|
+
prerelease: false
|
78
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
type: :development
|
88
|
+
version_requirements: *id004
|
88
89
|
description: "brdinheiro \xC3\xA9 uma das gems que compoem o Brazilian Rails"
|
89
|
-
email:
|
90
|
+
email:
|
91
|
+
- tapajos@gmail.com
|
92
|
+
- tinorj@gmail.com
|
93
|
+
- kupkovski@gmail.com
|
94
|
+
- vinicius.m.teles@gmail.com
|
95
|
+
- felipebarreto@gmail.com
|
96
|
+
- rafawalter@gmail.com
|
97
|
+
- cassiommc@gmail.com
|
90
98
|
executables: []
|
91
99
|
|
92
100
|
extensions: []
|