kelredd-wesabe 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,test}/**/*")
17
+ s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib}/**/*")
20
18
  # s.executables = ['wesabe']
21
19
 
22
- s.add_dependency('kelredd-resourceful', '>= 0.3.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
- desc 'Generate the gemspec to serve this Gem from Github'
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
@@ -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 :oldest_txaction_on, :date, :path => "oldest-txaction"
26
- attribute :newest_txaction_on, :date, :path => "newest-txaction"
31
+ attribute :oldest_txaction_at, :date, :path => "oldest-txaction"
32
+ attribute :newest_txaction_at, :date, :path => "newest-txaction"
27
33
 
28
- def institution
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
@@ -2,22 +2,27 @@ module Wesabe
2
2
  module Model
3
3
  class Base < Resourceful::Model::Xml
4
4
 
5
- def self.configure(opts={})
6
- raise Wesabe::NotConfigured, "No user provided to access the Wesabe API" if blank?(opts[:user])
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(resource, params, xpath)
14
- raise Wesabe::NotConfigured, "Wesabe not configured to access the API." if blank?(@agent)
15
- super(resource, params, xpath)
10
+
11
+ def self.get(path, params, search, force=true)
12
+ config_check
13
+ super(path, params, search, force)
16
14
  end
17
-
18
- def self.get_collection(resource, params, xpath)
19
- raise Wesabe::NotConfigured, "Wesabe not configured to access the API." if blank?(@agent)
20
- super(resource, params, xpath)
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
- def account
26
- @account ||= Wesabe::Model::Account.find(self.account_id)
27
- end
25
+ has_one :merchant, :klass => 'Wesabe::Model::Merchant'
28
26
 
29
- def merchant
30
- @merchant ||= (get_node('./merchant') ? Wesabe::Model::Merchant.new(get_node('./merchant')) : nil)
27
+ def account
28
+ @account ||= Wesabe::Model::Account.find(self.account_id) if self.account_id
31
29
  end
32
30
 
33
31
  end
@@ -3,7 +3,7 @@ module Wesabe
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- TINY = 0
6
+ TINY = 1
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
data/lib/wesabe.rb CHANGED
@@ -2,6 +2,6 @@
2
2
  require lib
3
3
  end
4
4
 
5
- %w(exceptions model).each do |file|
5
+ %w(exceptions configuration model).each do |file|
6
6
  require File.join(File.dirname(__FILE__), 'wesabe', "#{file}.rb")
7
7
  end
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.0
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-07-24 00:00:00 -07:00
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.3.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
- - test/test_helper.rb
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.2.0
73
+ rubygems_version: 1.3.5
74
74
  signing_key:
75
- specification_version: 2
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
@@ -1,10 +0,0 @@
1
- # http://sneaq.net/textmate-wtf
2
- $:.reject! { |e| e.include? 'TextMate' }
3
-
4
- require 'rubygems'
5
- require 'test/unit'
6
- require 'matchy'
7
- require 'context'
8
- require 'mocha'
9
-
10
- require File.dirname(__FILE__) + '/../lib/wesabe'
@@ -1,13 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
-
3
- class WesabeTest < Test::Unit::TestCase
4
-
5
- describe "An instance of the Wesabe class" do
6
-
7
- it "should flunk" do
8
- flunk "Please provide some tests"
9
- end
10
-
11
- end
12
-
13
- end