kelredd-wesabe 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +29 -6
- data/lib/wesabe/configuration.rb +38 -0
- data/lib/wesabe/model/account.rb +12 -19
- data/lib/wesabe/model/base.rb +18 -13
- data/lib/wesabe/model/currency.rb +19 -0
- data/lib/wesabe/model/txaction.rb +3 -5
- data/lib/wesabe/version.rb +1 -1
- data/lib/wesabe.rb +1 -1
- metadata +9 -9
- data/test/test_helper.rb +0 -10
- data/test/unit/wesabe_test.rb +0 -13
data/Rakefile
CHANGED
@@ -4,8 +4,6 @@ require 'rake/testtask'
|
|
4
4
|
|
5
5
|
require 'lib/wesabe/version'
|
6
6
|
|
7
|
-
task :default => :test
|
8
|
-
|
9
7
|
spec = Gem::Specification.new do |s|
|
10
8
|
s.name = 'wesabe'
|
11
9
|
s.version = Wesabe::Version.to_s
|
@@ -16,10 +14,10 @@ spec = Gem::Specification.new do |s|
|
|
16
14
|
s.author = 'Kelly Redding'
|
17
15
|
s.email = 'kelly@kelredd.com'
|
18
16
|
s.homepage = ''
|
19
|
-
s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib
|
17
|
+
s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib}/**/*")
|
20
18
|
# s.executables = ['wesabe']
|
21
19
|
|
22
|
-
s.add_dependency('kelredd-resourceful', '>= 0.
|
20
|
+
s.add_dependency('kelredd-resourceful', '>= 0.4.6')
|
23
21
|
end
|
24
22
|
|
25
23
|
Rake::GemPackageTask.new(spec) do |pkg|
|
@@ -32,9 +30,34 @@ Rake::TestTask.new do |t|
|
|
32
30
|
t.verbose = true
|
33
31
|
end
|
34
32
|
|
35
|
-
|
33
|
+
begin
|
34
|
+
require 'rcov/rcovtask'
|
35
|
+
|
36
|
+
Rcov::RcovTask.new(:coverage) do |t|
|
37
|
+
t.libs = ['test']
|
38
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
39
|
+
t.verbose = true
|
40
|
+
t.rcov_opts = ['--text-report', "-x #{Gem.path}", '-x /Library/Ruby', '-x /usr/lib/ruby']
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :coverage
|
44
|
+
|
45
|
+
rescue LoadError
|
46
|
+
warn "\n**** Install rcov (sudo gem install relevance-rcov) to get coverage stats ****\n"
|
47
|
+
task :default => :test
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
desc 'Generate the gemspec to serve this gem'
|
36
52
|
task :gemspec do
|
37
53
|
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
|
38
54
|
File.open(file, 'w') {|f| f << spec.to_ruby }
|
39
55
|
puts "Created gemspec: #{file}"
|
40
|
-
end
|
56
|
+
end
|
57
|
+
|
58
|
+
require 'cucumber'
|
59
|
+
require 'cucumber/rake/task'
|
60
|
+
|
61
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
62
|
+
t.cucumber_opts = "test/features --format pretty"
|
63
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Wesabe
|
2
|
+
module Configuration
|
3
|
+
|
4
|
+
HOST_URL = 'https://www.wesabe.com'
|
5
|
+
|
6
|
+
ATTRS = [:host, :email, :password, :log_file]
|
7
|
+
ATTRS.each { |a| class_variable_set("@@#{a.to_s}", nil) }
|
8
|
+
@@mechanize_agent = nil
|
9
|
+
|
10
|
+
def self.set(config={})
|
11
|
+
@@host ||= HOST_URL
|
12
|
+
ATTRS.each { |a| class_variable_set("@@#{a.to_s}", config.delete(a)) unless config[a].nil? }
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.host
|
16
|
+
@@host
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.email
|
20
|
+
@@email
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.password
|
24
|
+
@@password
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.log_file
|
28
|
+
@@log_file
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.rest_client
|
32
|
+
@@rest_client ||= Resourceful::Agent::RestClient.new(:host => @@host, :user => @@email, :password => @@password) do
|
33
|
+
@@log_file ? File.expand_path(@@log_file) : nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
data/lib/wesabe/model/account.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
%w(base institution).each do |file|
|
1
|
+
%w(base institution currency).each do |file|
|
2
2
|
require File.join(File.dirname(__FILE__), "#{file}.rb")
|
3
3
|
end
|
4
4
|
|
@@ -9,9 +9,9 @@ module Wesabe
|
|
9
9
|
def self.find(id)
|
10
10
|
case id
|
11
11
|
when :all
|
12
|
-
get_collection("/accounts", {}, "//accounts/account")
|
12
|
+
get_collection("/accounts.xml", {}, "//accounts/account")
|
13
13
|
else
|
14
|
-
get("/accounts/#{id}", {}, "//account")
|
14
|
+
get("/accounts/#{id}.xml", {}, "//account")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -19,26 +19,19 @@ module Wesabe
|
|
19
19
|
attribute :key, :string, :path => "guid"
|
20
20
|
attribute :number, :string, :path => "account-number"
|
21
21
|
attribute :name, :string
|
22
|
+
|
23
|
+
has_one :institution, :klass => 'Wesabe::Model::Institution', :path => 'financial-institution'
|
24
|
+
|
22
25
|
attribute :account_type, :string, :path => "account-type"
|
26
|
+
|
27
|
+
has_one :currency, :klass => 'Wesabe::Model::Currency'
|
28
|
+
|
23
29
|
attribute :balance, :float, :path => "current-balance"
|
24
30
|
attribute :last_uploaded_at, :datetime, :path => "last-uploaded-at"
|
25
|
-
attribute :
|
26
|
-
attribute :
|
31
|
+
attribute :oldest_txaction_at, :date, :path => "oldest-txaction"
|
32
|
+
attribute :newest_txaction_at, :date, :path => "newest-txaction"
|
27
33
|
|
28
|
-
|
29
|
-
@institution ||= Wesabe::Model::Institution.new(get_node('./financial-institution'))
|
30
|
-
end
|
31
|
-
|
32
|
-
def currency
|
33
|
-
node = get_node('./currency')
|
34
|
-
@currency ||= {
|
35
|
-
:symbol => node['symbol'],
|
36
|
-
:delimiter => node['delimiter'],
|
37
|
-
:separator => node['separator'],
|
38
|
-
:decimal_places => node['decimal_places'],
|
39
|
-
:type => node.content.to_s
|
40
|
-
}
|
41
|
-
end
|
34
|
+
has_many :txactions, :klass => 'Wesabe::Model::Txaction', :path => 'txactions/txaction'
|
42
35
|
|
43
36
|
def to_s
|
44
37
|
self.id
|
data/lib/wesabe/model/base.rb
CHANGED
@@ -2,22 +2,27 @@ module Wesabe
|
|
2
2
|
module Model
|
3
3
|
class Base < Resourceful::Model::Xml
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
raise Wesabe::NotConfigured, "No password provided to access the Wesabe API" if blank?(opts[:password])
|
8
|
-
agent RestClient::Resource.new('https://www.wesabe.com', :user => opts[:user], :password => opts[:password])
|
5
|
+
agent do
|
6
|
+
Wesabe::Configuration.rest_client
|
9
7
|
end
|
10
|
-
|
8
|
+
|
11
9
|
protected
|
12
|
-
|
13
|
-
def self.get(
|
14
|
-
|
15
|
-
super(
|
10
|
+
|
11
|
+
def self.get(path, params, search, force=true)
|
12
|
+
config_check
|
13
|
+
super(path, params, search, force)
|
16
14
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
def self.get_collection(path, params, search, force=true)
|
16
|
+
config_check
|
17
|
+
super(path, params, search, force)
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def self.config_check
|
23
|
+
raise Wesabe::NotConfigured, "Unknown host configured" if blank?(Wesabe::Configuration.host)
|
24
|
+
raise Wesabe::NotConfigured, "No user provided to access the Wesabe API" if blank?(Wesabe::Configuration.email)
|
25
|
+
raise Wesabe::NotConfigured, "No password provided to access the Wesabe API" if blank?(Wesabe::Configuration.password)
|
21
26
|
end
|
22
27
|
|
23
28
|
private
|
@@ -0,0 +1,19 @@
|
|
1
|
+
%w(base).each do |file|
|
2
|
+
require File.join(File.dirname(__FILE__), "#{file}.rb")
|
3
|
+
end
|
4
|
+
|
5
|
+
module Wesabe
|
6
|
+
module Model
|
7
|
+
|
8
|
+
class Currency < Wesabe::Model::Base
|
9
|
+
|
10
|
+
attribute :symbol, :string, :path => "./@symbol"
|
11
|
+
attribute :delimiter, :string, :path => "./@delimiter"
|
12
|
+
attribute :separator, :string, :path => "./@separator"
|
13
|
+
attribute :decimal_places, :integer, :path => "./@decimal_places"
|
14
|
+
attribute :type, :string, :path => "./."
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -22,12 +22,10 @@ module Wesabe
|
|
22
22
|
attribute :memo, :string
|
23
23
|
attribute :transfer_key, :string, :path => "transfer/guid"
|
24
24
|
|
25
|
-
|
26
|
-
@account ||= Wesabe::Model::Account.find(self.account_id)
|
27
|
-
end
|
25
|
+
has_one :merchant, :klass => 'Wesabe::Model::Merchant'
|
28
26
|
|
29
|
-
def
|
30
|
-
@
|
27
|
+
def account
|
28
|
+
@account ||= Wesabe::Model::Account.find(self.account_id) if self.account_id
|
31
29
|
end
|
32
30
|
|
33
31
|
end
|
data/lib/wesabe/version.rb
CHANGED
data/lib/wesabe.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kelredd-wesabe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.4.6
|
24
24
|
version:
|
25
25
|
description:
|
26
26
|
email: kelly@kelredd.com
|
@@ -34,21 +34,21 @@ files:
|
|
34
34
|
- README.rdoc
|
35
35
|
- Rakefile
|
36
36
|
- lib/wesabe
|
37
|
+
- lib/wesabe/configuration.rb
|
37
38
|
- lib/wesabe/exceptions.rb
|
38
39
|
- lib/wesabe/model
|
39
40
|
- lib/wesabe/model/account.rb
|
40
41
|
- lib/wesabe/model/base.rb
|
42
|
+
- lib/wesabe/model/currency.rb
|
41
43
|
- lib/wesabe/model/institution.rb
|
42
44
|
- lib/wesabe/model/merchant.rb
|
43
45
|
- lib/wesabe/model/txaction.rb
|
44
46
|
- lib/wesabe/model.rb
|
45
47
|
- lib/wesabe/version.rb
|
46
48
|
- lib/wesabe.rb
|
47
|
-
|
48
|
-
- test/unit
|
49
|
-
- test/unit/wesabe_test.rb
|
50
|
-
has_rdoc: true
|
49
|
+
has_rdoc: false
|
51
50
|
homepage: ""
|
51
|
+
licenses:
|
52
52
|
post_install_message:
|
53
53
|
rdoc_options:
|
54
54
|
- --main
|
@@ -70,9 +70,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements: []
|
71
71
|
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.
|
73
|
+
rubygems_version: 1.3.5
|
74
74
|
signing_key:
|
75
|
-
specification_version:
|
75
|
+
specification_version: 3
|
76
76
|
summary: A simplistic gem to assist in consuming the Wesabe API.
|
77
77
|
test_files: []
|
78
78
|
|
data/test/test_helper.rb
DELETED
data/test/unit/wesabe_test.rb
DELETED