gocardless 0.2.0 → 1.0.0

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/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
+ ## 1.0.0 - April 24, 2012
2
+
3
+ - Add plan_id to selected resources
4
+ - Remove deprecated resource attributes
5
+ - Fix sorting issue in Utils.normalize_params
6
+ - Add rake console task
7
+ - Add rake version:bump tasks
8
+ - Fix user agent formatting
9
+ - Relax multi_json dependency
10
+
11
+
1
12
  ## 0.2.0 - April 3, 2012
2
13
 
3
14
  - Add `cancel!` method to `Subscription`
15
+ - Depend on multi_json rather than json
4
16
  - Include the API version in the user agent header
5
17
 
6
18
 
data/Rakefile CHANGED
@@ -7,8 +7,76 @@ YARD::Rake::YardocTask.new do |t|
7
7
  t.files = files.reject { |f| f =~ /seed|example/ }
8
8
  end
9
9
 
10
+ desc "Run an IRB session with gocardless pre-loaded"
11
+ task :console do
12
+ exec "irb -I lib -r gocardless"
13
+ end
14
+
10
15
  desc "Run the specs"
11
16
  RSpec::Core::RakeTask.new(:spec) do |t|
12
17
  t.rspec_opts = %w[--color]
13
18
  end
14
19
 
20
+
21
+ def generate_changelog(last_version, new_version)
22
+ commits = `git log v#{last_version}.. --oneline`.split("\n")
23
+ msgs = commits.map { |commit| commit.sub(/^[a-f0-9]+/, '-') }
24
+ date = Time.now.strftime("%B %d, %Y")
25
+ "## #{new_version} - #{date}\n\n#{msgs.join("\n")}\n\n\n"
26
+ end
27
+
28
+ def update_changelog(last_version, new_version)
29
+ contents = File.read('CHANGELOG.md')
30
+ if contents =~ /## #{new_version}/
31
+ puts "CHANGELOG already contains v#{new_version}, skipping"
32
+ return false
33
+ end
34
+ changelog = generate_changelog(last_version, new_version)
35
+ File.open('CHANGELOG.md', 'w') { |f| f.write(changelog + contents) }
36
+ end
37
+
38
+ def update_version_file(new_version)
39
+ path = "lib/#{Dir.glob('*.gemspec').first.split('.').first}/version.rb"
40
+ contents = File.read(path)
41
+ contents.sub!(/VERSION\s+=\s+["'][\d\.]+["']/, "VERSION = '#{new_version}'")
42
+ File.open(path, 'w') { |f| f.write(contents) }
43
+ end
44
+
45
+ def bump_version(part)
46
+ last_version = `git tag -l | tail -1`.strip.sub(/^v/, '')
47
+ major, minor, patch = last_version.scan(/\d+/).map(&:to_i)
48
+
49
+ case part
50
+ when :major
51
+ major += 1
52
+ minor = patch = 0
53
+ when :minor
54
+ minor += 1
55
+ patch = 0
56
+ when :patch
57
+ patch += 1
58
+ end
59
+ new_version = "#{major}.#{minor}.#{patch}"
60
+
61
+ update_changelog(last_version, new_version)
62
+ puts "Updated CHANGELOG"
63
+
64
+ update_version_file(new_version)
65
+ puts "Updated version.rb"
66
+ end
67
+
68
+ desc "Update the version, auto-generating the changelog"
69
+ namespace :version do
70
+ namespace :bump do
71
+ task :major do
72
+ bump_version :major
73
+ end
74
+ task :minor do
75
+ bump_version :minor
76
+ end
77
+ task :patch do
78
+ bump_version :patch
79
+ end
80
+ end
81
+ end
82
+
data/gocardless.gemspec CHANGED
@@ -2,7 +2,7 @@ require File.expand_path('../lib/gocardless/version', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.add_runtime_dependency 'oauth2', '~> 0.5.0.rc1'
5
- gem.add_runtime_dependency 'multi_json', '~> 1.2'
5
+ gem.add_runtime_dependency 'multi_json', '~> 1.0'
6
6
 
7
7
  gem.add_development_dependency 'rspec', '~> 2.6'
8
8
  gem.add_development_dependency 'mocha', '~> 0.9.12'
@@ -4,13 +4,14 @@ module GoCardless
4
4
 
5
5
  creatable
6
6
 
7
- attr_accessor :amount
8
- attr_accessor :source_type
9
- attr_accessor :description
10
- attr_accessor :name
7
+ attr_accessor :amount,
8
+ :source_type,
9
+ :description,
10
+ :name,
11
+ :plan_id
11
12
 
12
13
  # @attribute source_id
13
- # @return [Integer] the ID of the bill's source (eg subscription, pre_authorization)
14
+ # @return [String] the ID of the bill's source (eg subscription, pre_authorization)
14
15
  attr_accessor :source_id
15
16
 
16
17
  reference_accessor :merchant_id, :user_id, :payment_id
@@ -5,6 +5,7 @@ require 'openssl'
5
5
  require 'uri'
6
6
  require 'cgi'
7
7
  require 'time'
8
+ require 'base64'
8
9
 
9
10
  module GoCardless
10
11
  class Client
@@ -270,7 +271,7 @@ module GoCardless
270
271
  opts[:headers] = {} if opts[:headers].nil?
271
272
  opts[:headers]['Accept'] = 'application/json'
272
273
  opts[:headers]['Content-Type'] = 'application/json' unless method == :get
273
- opts[:headers]['User-Agent'] = "gocardless-ruby-v#{GoCardless::VERSION}"
274
+ opts[:headers]['User-Agent'] = "gocardless-ruby/v#{GoCardless::VERSION}"
274
275
  opts[:body] = MultiJson.encode(opts[:data]) if !opts[:data].nil?
275
276
 
276
277
  # Reset the URL in case the environment / base URL has been changed.
@@ -2,8 +2,14 @@ module GoCardless
2
2
  class PreAuthorization < Resource
3
3
  self.endpoint = '/pre_authorizations/:id'
4
4
 
5
- attr_accessor :max_amount, :currency, :amount, :interval_length,
6
- :interval_unit, :description
5
+ attr_accessor :max_amount,
6
+ :currency,
7
+ :amount,
8
+ :interval_length,
9
+ :interval_unit,
10
+ :name,
11
+ :description,
12
+ :plan_id
7
13
 
8
14
  reference_accessor :merchant_id, :user_id
9
15
  date_accessor :expires_at, :created_at
@@ -3,8 +3,13 @@ module GoCardless
3
3
 
4
4
  self.endpoint = '/subscriptions/:id'
5
5
 
6
- attr_accessor :amount, :currency, :interval_length, :interval_unit,
7
- :description, :setup_fee, :trial_length, :trial_unit
6
+ attr_accessor :amount,
7
+ :currency,
8
+ :interval_length,
9
+ :interval_unit,
10
+ :name,
11
+ :description,
12
+ :plan_id
8
13
 
9
14
  reference_accessor :merchant_id, :user_id
10
15
 
@@ -77,9 +77,9 @@ module GoCardless
77
77
  # percent-encoded according to RFC5849 §3.6 and parameters will be
78
78
  # normalised according to RFC5849 §3.4.1.3.2.
79
79
  def normalize_params(params)
80
- flatten_params(params).map do |pair|
80
+ flatten_params(params).sort.map do |pair|
81
81
  pair.map { |item| percent_encode(item) } * '='
82
- end.sort * '&'
82
+ end * '&'
83
83
  end
84
84
 
85
85
  # Given a Hash of parameters, normalize then (flatten and convert to a
@@ -1,3 +1,3 @@
1
1
  module GoCardless
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
data/spec/utils_spec.rb CHANGED
@@ -182,6 +182,10 @@ describe GoCardless::Utils do
182
182
  it "joins pairs by '&' signs" do
183
183
  subject['a' => 'b', 'c' => 'd'].should == 'a=b&c=d'
184
184
  end
185
+
186
+ it "sorts pairs by name then value" do
187
+ subject['a0' => 'b', 'a' => 'c'].should == 'a=c&a0=b'
188
+ end
185
189
  end
186
190
 
187
191
  describe ".sign_params" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gocardless
3
3
  version: !ruby/object:Gem::Version
4
- hash: 2380615109590600174
4
+ hash: 2387456872237229630
5
5
  prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 2
9
9
  - 0
10
- version: 0.2.0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Harry Marr
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-04-03 00:00:00 Z
19
+ date: 2012-04-24 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: oauth2
@@ -44,11 +44,11 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- hash: 3191556116430806706
47
+ hash: 4428665182548103036
48
48
  segments:
49
49
  - 1
50
- - 2
51
- version: "1.2"
50
+ - 0
51
+ version: "1.0"
52
52
  type: :runtime
53
53
  version_requirements: *id002
54
54
  - !ruby/object:Gem::Dependency