clieop 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.rspec +2 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +28 -0
- data/README.rdoc +8 -1
- data/autotest/discover.rb +1 -0
- data/clieop.gemspec +8 -4
- data/lib/clieop.rb +1 -1
- data/lib/clieop/batch.rb +12 -5
- data/lib/clieop/file.rb +2 -2
- data/lib/clieop/record.rb +13 -14
- data/spec/clieop/batch_spec.rb +80 -22
- data/spec/clieop/file_spec.rb +12 -1
- data/spec/spec_helper.rb +3 -6
- data/tasks/github-gem.rake +90 -52
- metadata +68 -21
data/.gitignore
CHANGED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
clieop (0.1.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ZenTest (4.4.1)
|
10
|
+
diff-lcs (1.1.2)
|
11
|
+
rake (0.8.7)
|
12
|
+
rspec (2.2.0)
|
13
|
+
rspec-core (~> 2.2)
|
14
|
+
rspec-expectations (~> 2.2)
|
15
|
+
rspec-mocks (~> 2.2)
|
16
|
+
rspec-core (2.2.1)
|
17
|
+
rspec-expectations (2.2.0)
|
18
|
+
diff-lcs (~> 1.1.2)
|
19
|
+
rspec-mocks (2.2.0)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
ZenTest (~> 4.4)
|
26
|
+
clieop!
|
27
|
+
rake
|
28
|
+
rspec (~> 2.2)
|
data/README.rdoc
CHANGED
@@ -20,7 +20,14 @@ http://www.ingbank.nl/ing/downloadables/eclieop1.pdf
|
|
20
20
|
|
21
21
|
== Usage
|
22
22
|
|
23
|
-
Run <tt>gem install clieop</tt> to install the gem
|
23
|
+
Run <tt>gem install clieop</tt> to install the gem or add <tt>gem 'clieop'</tt> to
|
24
|
+
your project's Gemfile.
|
24
25
|
|
25
26
|
See the project's wiki at http://wiki.github.com/wvanbergen/clieop for an example
|
26
27
|
creating and writing a direct debt batch file.
|
28
|
+
|
29
|
+
== About
|
30
|
+
|
31
|
+
This library is released under the MIT license (see <tt>MIT-LICENSE</tt>) and was
|
32
|
+
originally written by Willem van Bergen. It is currently being maintained by
|
33
|
+
Leon Berenschot.
|
@@ -0,0 +1 @@
|
|
1
|
+
Autotest.add_discovery { "rspec2" }
|
data/clieop.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
|
4
4
|
# Do not set version and date yourself, this will be done automatically
|
5
5
|
# by the gem release script.
|
6
|
-
s.version = "0.
|
7
|
-
s.date = "2010-
|
6
|
+
s.version = "0.2.0"
|
7
|
+
s.date = "2010-12-09"
|
8
8
|
|
9
9
|
s.summary = "A pure Ruby implementation to write CLIEOP files"
|
10
10
|
s.description = "This library is a pure Ruby, MIT licensed implementation of the CLIEOP03 transaction format. CLIEOP03 can be used to communicate direct debt transactions with your (Dutch) bank."
|
@@ -13,8 +13,12 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.email = ['willem@vanbergen.org', 'LeipeLeon@gmail.com']
|
14
14
|
s.homepage = 'http://github.com/wvanbergen/clieop/wikis'
|
15
15
|
|
16
|
+
s.add_development_dependency('rake')
|
17
|
+
s.add_development_dependency('rspec', '~> 2.2')
|
18
|
+
s.add_development_dependency('ZenTest', '~> 4.4')
|
19
|
+
|
16
20
|
# Do not set files and test_files yourself, this will be done automatically
|
17
21
|
# by the gem release script.
|
18
|
-
s.files = %w(
|
19
|
-
s.test_files = %w(spec/clieop/batch_spec.rb spec/
|
22
|
+
s.files = %w(.gitignore .rspec Gemfile Gemfile.lock MIT-LICENSE README.rdoc Rakefile autotest/discover.rb clieop.gemspec doc/clieop03.pdf init.rb lib/clieop.rb lib/clieop/batch.rb lib/clieop/file.rb lib/clieop/record.rb spec/clieop/batch_spec.rb spec/clieop/file_spec.rb spec/clieop/record_spec.rb spec/clieop_spec.rb spec/spec_helper.rb tasks/github-gem.rake)
|
23
|
+
s.test_files = %w(spec/clieop/batch_spec.rb spec/clieop/file_spec.rb spec/clieop/record_spec.rb spec/clieop_spec.rb)
|
20
24
|
end
|
data/lib/clieop.rb
CHANGED
data/lib/clieop/batch.rb
CHANGED
@@ -49,11 +49,10 @@ module Clieop
|
|
49
49
|
@transactions.each do |tr|
|
50
50
|
|
51
51
|
# prepare data for this transaction's records
|
52
|
-
transaction_type = tr[:transaction_type] || (
|
53
|
-
to_account =
|
54
|
-
from_account =
|
52
|
+
transaction_type = tr[:transaction_type] || (transaction_is_payment? ? 1002 : 0)
|
53
|
+
to_account = transaction_is_payment? ? @batch_info[:account_nr] : tr[:account_nr]
|
54
|
+
from_account = transaction_is_payment? ? tr[:account_nr] : @batch_info[:account_nr]
|
55
55
|
amount_in_cents = (tr[:amount] * 100).round.to_i
|
56
|
-
name_record = @batch_info[:transaction_group] == 10 ? :invoice_name : :payment_name
|
57
56
|
|
58
57
|
# update checksums
|
59
58
|
total_account += tr[:account_nr].to_i
|
@@ -65,7 +64,7 @@ module Clieop
|
|
65
64
|
:to_account => to_account, :from_account => from_account).to_clieop
|
66
65
|
|
67
66
|
# generate record with transaction information
|
68
|
-
batch_data << Clieop::Record.new(
|
67
|
+
batch_data << Clieop::Record.new(:invoice_name, :name => tr[:account_owner]).to_clieop if transaction_is_payment?
|
69
68
|
batch_data << Clieop::Record.new(:transaction_reference, :reference_number => tr[:reference_number]).to_clieop unless tr[:reference_number].nil?
|
70
69
|
|
71
70
|
# split discription into lines and make a record for the first 4 lines
|
@@ -74,6 +73,8 @@ module Clieop
|
|
74
73
|
batch_data << Clieop::Record.new(:transaction_description, :description => line.strip).to_s unless line == ''
|
75
74
|
end
|
76
75
|
end
|
76
|
+
batch_data << Clieop::Record.new(:payment_name, :name => tr[:account_owner]).to_clieop unless transaction_is_payment?
|
77
|
+
|
77
78
|
end
|
78
79
|
|
79
80
|
# generate batch footer record including some checks
|
@@ -104,5 +105,11 @@ module Clieop
|
|
104
105
|
# total.to_s.chars.last(10).join('') # ruby 1.8.7
|
105
106
|
end
|
106
107
|
|
108
|
+
private
|
109
|
+
|
110
|
+
def transaction_is_payment?
|
111
|
+
@batch_info[:transaction_group] == 10
|
112
|
+
end
|
113
|
+
|
107
114
|
end
|
108
115
|
end
|
data/lib/clieop/file.rb
CHANGED
data/lib/clieop/record.rb
CHANGED
@@ -57,11 +57,6 @@ module Clieop
|
|
57
57
|
[:record_variant, :alpha, 1, 'B'],
|
58
58
|
[:name, :alpha, 35],
|
59
59
|
],
|
60
|
-
:payment_name =>[
|
61
|
-
[:record_code, :numeric, 4, 170],
|
62
|
-
[:record_variant, :alpha, 1, 'B'],
|
63
|
-
[:name, :alpha, 35],
|
64
|
-
],
|
65
60
|
:transaction_reference => [
|
66
61
|
[:record_code, :numeric, 4, 150],
|
67
62
|
[:record_variant, :alpha, 1, 'A'],
|
@@ -72,6 +67,11 @@ module Clieop
|
|
72
67
|
[:record_variant, :alpha, 1, 'A'],
|
73
68
|
[:description, :alpha, 32],
|
74
69
|
],
|
70
|
+
:payment_name =>[
|
71
|
+
[:record_code, :numeric, 4, 170],
|
72
|
+
[:record_variant, :alpha, 1, 'B'],
|
73
|
+
[:name, :alpha, 35],
|
74
|
+
],
|
75
75
|
}
|
76
76
|
|
77
77
|
attr_accessor :definition, :data
|
@@ -83,8 +83,7 @@ module Clieop
|
|
83
83
|
@definition = Clieop::Record::TYPE_DEFINITIONS[record_type.to_sym]
|
84
84
|
|
85
85
|
# set default values according to definition
|
86
|
-
@data = {}
|
87
|
-
@definition.each { |field| @data[field[0]] = field[3] if field[3] }
|
86
|
+
@data = @definition.inject({}) { |memo, field| memo[field[0]] = field[3] if field[3] ; memo }
|
88
87
|
|
89
88
|
# set values for all the provided data
|
90
89
|
record_data.each { |field, value| @data[field] = value }
|
@@ -92,15 +91,15 @@ module Clieop
|
|
92
91
|
|
93
92
|
def to_clieop
|
94
93
|
line = ""
|
95
|
-
#format each field
|
96
|
-
@definition.each do |field|
|
94
|
+
# format each field
|
95
|
+
@definition.each do |field, type, length, content|
|
97
96
|
fmt = '%'
|
98
|
-
fmt << (
|
99
|
-
fmt << (
|
100
|
-
fmt << (
|
101
|
-
raw_data = (
|
97
|
+
fmt << (type == :numeric ? '0' : '-')
|
98
|
+
fmt << (length.to_s)
|
99
|
+
fmt << (type == :numeric ? 'd' : 's')
|
100
|
+
raw_data = (type == :numeric) ? @data[field].to_i : @data[field]
|
102
101
|
value = sprintf(fmt, raw_data)
|
103
|
-
line << (
|
102
|
+
line << (type == :numeric ? value[0 - length, length] : value[0, length])
|
104
103
|
end
|
105
104
|
# fill each line with spaces up to 50 characters and close with a CR/LF
|
106
105
|
line.ljust(50) + "\r\n"
|
data/spec/clieop/batch_spec.rb
CHANGED
@@ -4,8 +4,8 @@ describe Clieop::Batch do
|
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
@batch_info = {
|
7
|
-
:description
|
8
|
-
:account_nr
|
7
|
+
:description => "Batch",
|
8
|
+
:account_nr => 123456789,
|
9
9
|
:account_owner => "Reciever"
|
10
10
|
}
|
11
11
|
end
|
@@ -26,26 +26,84 @@ describe Clieop::Batch do
|
|
26
26
|
batch.batch_info[:transaction_group].should eql(0)
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
29
|
+
describe "transactions" do
|
30
|
+
|
31
|
+
describe "Invoice" do
|
32
|
+
|
33
|
+
before do
|
34
|
+
@batch = Clieop::Batch.invoice_batch(@batch_info.dup)
|
35
|
+
@batch << {
|
36
|
+
:reference_number => "Factnr 100101",
|
37
|
+
:account_nr => 123456789,
|
38
|
+
:account_owner => 'Payee',
|
39
|
+
:amount => 30102,
|
40
|
+
:description => "Testing a CLIEOP direct debt transaction\nCharging your bank account",
|
41
|
+
:transaction_type => 1001
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should add transactions to batch" do
|
46
|
+
@batch.batch_info[:transaction_group].should eql(10)
|
47
|
+
@batch.to_clieop.should match(/0010B1001234567890001EUR /)
|
48
|
+
@batch.to_clieop.should match(/0020ABatch /)
|
49
|
+
@batch.to_clieop.should match(/0030B1000000Reciever P /)
|
50
|
+
@batch.to_clieop.should match(/0100A100100000301020001234567890123456789 /)
|
51
|
+
@batch.to_clieop.should match(/0110BPayee /)
|
52
|
+
@batch.to_clieop.should match(/0150AFactnr 100101 /)
|
53
|
+
@batch.to_clieop.should match(/0160ATesting a CLIEOP direct debt tra /)
|
54
|
+
@batch.to_clieop.should match(/0160ACharging your bank account /)
|
55
|
+
@batch.to_clieop.should match(/9990A00000000000301020002469135780000001 /)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should appear in proper order" do
|
59
|
+
last_record_code = 0
|
60
|
+
@batch.to_clieop.split("\n").each do |line|
|
61
|
+
line =~ /^(\d{4})[AB]/
|
62
|
+
$1.to_i.should >= last_record_code
|
63
|
+
last_record_code = $1.to_i
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "Payment" do
|
70
|
+
|
71
|
+
before do
|
72
|
+
@batch = Clieop::Batch.payment_batch(@batch_info.dup)
|
73
|
+
@batch << {
|
74
|
+
:reference_number => "Factnr 100101",
|
75
|
+
:account_nr => 123456789,
|
76
|
+
:account_owner => 'Payee',
|
77
|
+
:amount => 30102,
|
78
|
+
:description => "Testing a CLIEOP direct credit transaction\nPaying your bank account",
|
79
|
+
:transaction_type => 1001
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should add transactions to batch" do
|
84
|
+
@batch.batch_info[:transaction_group].should eql(0)
|
85
|
+
@batch.to_clieop.should match(/0010B0001234567890001EUR /)
|
86
|
+
@batch.to_clieop.should match(/0020ABatch /)
|
87
|
+
@batch.to_clieop.should match(/0030B1000000Reciever P /)
|
88
|
+
@batch.to_clieop.should match(/0100A100100000301020001234567890123456789 /)
|
89
|
+
@batch.to_clieop.should match(/0150AFactnr 100101 /)
|
90
|
+
@batch.to_clieop.should match(/0160ATesting a CLIEOP direct credit t /)
|
91
|
+
@batch.to_clieop.should match(/0160APaying your bank account /)
|
92
|
+
@batch.to_clieop.should match(/0170BPayee /)
|
93
|
+
@batch.to_clieop.should match(/9990A00000000000301020002469135780000001 /)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should appear in proper order" do
|
97
|
+
last_record_code = 0
|
98
|
+
@batch.to_clieop.split("\n").each do |line|
|
99
|
+
line =~ /^(\d{4})[AB]/
|
100
|
+
$1.to_i.should >= last_record_code
|
101
|
+
last_record_code = $1.to_i
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
49
107
|
end
|
50
108
|
|
51
109
|
end
|
data/spec/clieop/file_spec.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Clieop::File do
|
4
|
-
|
4
|
+
|
5
|
+
context "#save" do
|
6
|
+
|
7
|
+
it "should create 'filename' and put the CLIEOP data in it" do
|
8
|
+
file = mock('file')
|
9
|
+
File.should_receive(:open).with("filename", "w").and_yield(file)
|
10
|
+
file.should_receive(:write).with("0001A091210CLIEOP03 1 \r\n9999A \r\n")
|
11
|
+
subject.save('filename')
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
5
16
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
3
|
-
require
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.require(:default, :development)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
Spec::Runner.configure do |config|
|
5
|
+
RSpec.configure do |config|
|
8
6
|
|
9
7
|
end
|
10
|
-
|
data/tasks/github-gem.rake
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'rake/tasklib'
|
4
4
|
require 'date'
|
5
|
-
require '
|
5
|
+
require 'set'
|
6
6
|
|
7
7
|
module GithubGem
|
8
8
|
|
@@ -24,7 +24,7 @@ module GithubGem
|
|
24
24
|
|
25
25
|
class RakeTasks
|
26
26
|
|
27
|
-
attr_reader :gemspec, :modified_files
|
27
|
+
attr_reader :gemspec, :modified_files
|
28
28
|
attr_accessor :gemspec_file, :task_namespace, :main_include, :root_dir, :spec_pattern, :test_pattern, :remote, :remote_branch, :local_branch
|
29
29
|
|
30
30
|
# Initializes the settings, yields itself for configuration
|
@@ -33,7 +33,7 @@ module GithubGem
|
|
33
33
|
@gemspec_file = GithubGem.detect_gemspec_file
|
34
34
|
@task_namespace = task_namespace
|
35
35
|
@main_include = GithubGem.detect_main_include
|
36
|
-
@modified_files =
|
36
|
+
@modified_files = Set.new
|
37
37
|
@root_dir = Dir.pwd
|
38
38
|
@test_pattern = 'test/**/*_test.rb'
|
39
39
|
@spec_pattern = 'spec/**/*_spec.rb'
|
@@ -43,13 +43,16 @@ module GithubGem
|
|
43
43
|
|
44
44
|
yield(self) if block_given?
|
45
45
|
|
46
|
-
@git = Git.open(@root_dir)
|
47
46
|
load_gemspec!
|
48
47
|
define_tasks!
|
49
48
|
end
|
50
49
|
|
51
50
|
protected
|
52
51
|
|
52
|
+
def git
|
53
|
+
@git ||= ENV['GIT'] || 'git'
|
54
|
+
end
|
55
|
+
|
53
56
|
# Define Unit test tasks
|
54
57
|
def define_test_tasks!
|
55
58
|
require 'rake/testtask'
|
@@ -68,23 +71,23 @@ module GithubGem
|
|
68
71
|
|
69
72
|
# Defines RSpec tasks
|
70
73
|
def define_rspec_tasks!
|
71
|
-
require '
|
74
|
+
require 'rspec/core/rake_task'
|
72
75
|
|
73
76
|
namespace(:spec) do
|
74
77
|
desc "Verify all RSpec examples for #{gemspec.name}"
|
75
|
-
|
76
|
-
t.
|
78
|
+
RSpec::Core::RakeTask.new(:basic) do |t|
|
79
|
+
t.pattern = spec_pattern
|
77
80
|
end
|
78
81
|
|
79
82
|
desc "Verify all RSpec examples for #{gemspec.name} and output specdoc"
|
80
|
-
|
81
|
-
t.
|
82
|
-
t.
|
83
|
+
RSpec::Core::RakeTask.new(:specdoc) do |t|
|
84
|
+
t.pattern = spec_pattern
|
85
|
+
t.rspec_opts = ['--format', 'documentation', '--color']
|
83
86
|
end
|
84
87
|
|
85
88
|
desc "Run RCov on specs for #{gemspec.name}"
|
86
|
-
|
87
|
-
t.
|
89
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
90
|
+
t.pattern = spec_pattern
|
88
91
|
t.rcov = true
|
89
92
|
t.rcov_opts = ['--exclude', '"spec/*,gems/*"', '--rails']
|
90
93
|
end
|
@@ -119,23 +122,43 @@ module GithubGem
|
|
119
122
|
checks = [:check_current_branch, :check_clean_status, :check_not_diverged, :check_version]
|
120
123
|
checks.unshift('spec:basic') if has_specs?
|
121
124
|
checks.unshift('test:basic') if has_tests?
|
122
|
-
checks.push << [:check_rubyforge] if gemspec.rubyforge_project
|
125
|
+
# checks.push << [:check_rubyforge] if gemspec.rubyforge_project
|
123
126
|
|
124
127
|
desc "Perform all checks that would occur before a release"
|
125
128
|
task(:release_checks => checks)
|
126
129
|
|
127
|
-
release_tasks = [:release_checks, :set_version, :build, :github_release]
|
128
|
-
release_tasks << [:rubyforge_release] if gemspec.rubyforge_project
|
130
|
+
release_tasks = [:release_checks, :set_version, :build, :github_release, :gemcutter_release]
|
131
|
+
# release_tasks << [:rubyforge_release] if gemspec.rubyforge_project
|
129
132
|
|
130
|
-
desc "Release a new
|
133
|
+
desc "Release a new version of the gem using the VERSION environment variable"
|
131
134
|
task(:release => release_tasks) { release_task }
|
135
|
+
|
136
|
+
namespace(:release) do
|
137
|
+
desc "Release the next version of the gem, by incrementing the last version segment by 1"
|
138
|
+
task(:next => [:next_version] + release_tasks) { release_task }
|
139
|
+
|
140
|
+
desc "Release the next version of the gem, using a patch increment (0.0.1)"
|
141
|
+
task(:patch => [:next_patch_version] + release_tasks) { release_task }
|
142
|
+
|
143
|
+
desc "Release the next version of the gem, using a minor increment (0.1.0)"
|
144
|
+
task(:minor => [:next_minor_version] + release_tasks) { release_task }
|
132
145
|
|
133
|
-
|
134
|
-
|
146
|
+
desc "Release the next version of the gem, using a major increment (1.0.0)"
|
147
|
+
task(:major => [:next_major_version] + release_tasks) { release_task }
|
148
|
+
end
|
149
|
+
|
150
|
+
# task(:check_rubyforge) { check_rubyforge_task }
|
151
|
+
# task(:rubyforge_release) { rubyforge_release_task }
|
152
|
+
task(:gemcutter_release) { gemcutter_release_task }
|
135
153
|
task(:github_release => [:commit_modified_files, :tag_version]) { github_release_task }
|
136
154
|
task(:tag_version) { tag_version_task }
|
137
155
|
task(:commit_modified_files) { commit_modified_files_task }
|
138
156
|
|
157
|
+
task(:next_version) { next_version_task }
|
158
|
+
task(:next_patch_version) { next_version_task(:patch) }
|
159
|
+
task(:next_minor_version) { next_version_task(:minor) }
|
160
|
+
task(:next_major_version) { next_version_task(:major) }
|
161
|
+
|
139
162
|
desc "Updates the gem release tasks with the latest version on Github"
|
140
163
|
task(:update_tasks) { update_tasks_task }
|
141
164
|
end
|
@@ -145,7 +168,7 @@ module GithubGem
|
|
145
168
|
# in the repository and the spec/test file pattern.
|
146
169
|
def manifest_task
|
147
170
|
# Load all the gem's files using "git ls-files"
|
148
|
-
repository_files = git
|
171
|
+
repository_files = `#{git} ls-files`.split("\n")
|
149
172
|
test_files = Dir[test_pattern] + Dir[spec_pattern]
|
150
173
|
|
151
174
|
update_gemspec(:files, repository_files)
|
@@ -159,6 +182,32 @@ module GithubGem
|
|
159
182
|
sh "mv #{gemspec.name}-#{gemspec.version}.gem pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
160
183
|
end
|
161
184
|
|
185
|
+
def newest_version
|
186
|
+
`#{git} tag`.split("\n").map { |tag| tag.split('-').last }.compact.map { |v| Gem::Version.new(v) }.max || Gem::Version.new('0.0.0')
|
187
|
+
end
|
188
|
+
|
189
|
+
def next_version(increment = nil)
|
190
|
+
next_version = newest_version.segments
|
191
|
+
increment_index = case increment
|
192
|
+
when :micro then 3
|
193
|
+
when :patch then 2
|
194
|
+
when :minor then 1
|
195
|
+
when :major then 0
|
196
|
+
else next_version.length - 1
|
197
|
+
end
|
198
|
+
|
199
|
+
next_version[increment_index] ||= 0
|
200
|
+
next_version[increment_index] = next_version[increment_index].succ
|
201
|
+
((increment_index + 1)...next_version.length).each { |i| next_version[i] = 0 }
|
202
|
+
|
203
|
+
Gem::Version.new(next_version.join('.'))
|
204
|
+
end
|
205
|
+
|
206
|
+
def next_version_task(increment = nil)
|
207
|
+
ENV['VERSION'] = next_version(increment).version
|
208
|
+
puts "Releasing version #{ENV['VERSION']}..."
|
209
|
+
end
|
210
|
+
|
162
211
|
# Updates the version number in the gemspec file, the VERSION constant in the main
|
163
212
|
# include file and the contents of the VERSION file.
|
164
213
|
def version_task
|
@@ -171,70 +220,58 @@ module GithubGem
|
|
171
220
|
|
172
221
|
def check_version_task
|
173
222
|
raise "#{ENV['VERSION']} is not a valid version number!" if ENV['VERSION'] && !Gem::Version.correct?(ENV['VERSION'])
|
174
|
-
proposed_version = Gem::Version.new(ENV['VERSION'] || gemspec.version)
|
175
|
-
#
|
176
|
-
newest_version = git.tags.map { |tag| tag.name.split('-').last }.compact.map { |v| Gem::Version.new(v) }.max
|
177
|
-
raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version && newest_version >= proposed_version
|
223
|
+
proposed_version = Gem::Version.new(ENV['VERSION'].dup || gemspec.version)
|
224
|
+
raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version >= proposed_version
|
178
225
|
end
|
179
226
|
|
180
227
|
# Checks whether the current branch is not diverged from the remote branch
|
181
228
|
def check_not_diverged_task
|
182
|
-
raise "The current branch is diverged from the remote branch!" if git
|
229
|
+
raise "The current branch is diverged from the remote branch!" if `#{git} rev-list HEAD..#{remote}/#{remote_branch}`.split("\n").any?
|
183
230
|
end
|
184
231
|
|
185
232
|
# Checks whether the repository status ic clean
|
186
233
|
def check_clean_status_task
|
187
|
-
raise "The current working copy contains modifications" if git.
|
234
|
+
raise "The current working copy contains modifications" if `#{git} ls-files -m`.split("\n").any?
|
188
235
|
end
|
189
236
|
|
190
237
|
# Checks whether the current branch is correct
|
191
238
|
def check_current_branch_task
|
192
|
-
raise "Currently not on #{local_branch} branch!" unless git
|
239
|
+
raise "Currently not on #{local_branch} branch!" unless `#{git} branch`.split("\n").detect { |b| /^\* / =~ b } == "* #{local_branch}"
|
193
240
|
end
|
194
241
|
|
195
242
|
# Fetches the latest updates from Github
|
196
243
|
def fetch_origin_task
|
197
|
-
git
|
244
|
+
sh git, 'fetch', remote
|
198
245
|
end
|
199
246
|
|
200
247
|
# Commits every file that has been changed by the release task.
|
201
248
|
def commit_modified_files_task
|
202
|
-
|
203
|
-
|
204
|
-
|
249
|
+
really_modified = `#{git} ls-files -m #{modified_files.entries.join(' ')}`.split("\n")
|
250
|
+
if really_modified.any?
|
251
|
+
really_modified.each { |file| sh git, 'add', file }
|
252
|
+
sh git, 'commit', '-m', "Released #{gemspec.name} gem version #{gemspec.version}."
|
205
253
|
end
|
206
254
|
end
|
207
255
|
|
208
256
|
# Adds a tag for the released version
|
209
257
|
def tag_version_task
|
210
|
-
git
|
258
|
+
sh git, 'tag', '-a', "#{gemspec.name}-#{gemspec.version}", '-m', "Released #{gemspec.name} gem version #{gemspec.version}."
|
211
259
|
end
|
212
260
|
|
213
261
|
# Pushes the changes and tag to github
|
214
262
|
def github_release_task
|
215
|
-
git
|
216
|
-
end
|
217
|
-
|
218
|
-
# Checks whether Rubyforge is configured properly
|
219
|
-
def check_rubyforge_task
|
220
|
-
# Login no longer necessary when using rubyforge 2.0.0 gem
|
221
|
-
# raise "Could not login on rubyforge!" unless `rubyforge login 2>&1`.strip.empty?
|
222
|
-
output = `rubyforge names`.split("\n")
|
223
|
-
raise "Rubyforge group not found!" unless output.any? { |line| %r[^groups\s*\:.*\b#{Regexp.quote(gemspec.rubyforge_project)}\b.*] =~ line }
|
224
|
-
raise "Rubyforge package not found!" unless output.any? { |line| %r[^packages\s*\:.*\b#{Regexp.quote(gemspec.name)}\b.*] =~ line }
|
263
|
+
sh git, 'push', '--tags', remote, remote_branch
|
225
264
|
end
|
226
265
|
|
227
|
-
|
228
|
-
|
229
|
-
sh 'rubyforge', 'add_release', gemspec.rubyforge_project, gemspec.name, gemspec.version.to_s, "pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
266
|
+
def gemcutter_release_task
|
267
|
+
sh "gem", 'push', "pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
230
268
|
end
|
231
269
|
|
232
270
|
# Gem release task.
|
233
271
|
# All work is done by the task's dependencies, so just display a release completed message.
|
234
272
|
def release_task
|
235
273
|
puts
|
236
|
-
puts
|
237
|
-
puts "Released #{gemspec.name} version #{gemspec.version}"
|
274
|
+
puts "Release successful."
|
238
275
|
end
|
239
276
|
|
240
277
|
private
|
@@ -294,6 +331,9 @@ module GithubGem
|
|
294
331
|
|
295
332
|
# Reload the gemspec so the changes are incorporated
|
296
333
|
load_gemspec!
|
334
|
+
|
335
|
+
# Also mark the Gemfile.lock file as changed because of the new version.
|
336
|
+
modified_files << 'Gemfile.lock' if File.exist?(File.join(root_dir, 'Gemfile.lock'))
|
297
337
|
end
|
298
338
|
end
|
299
339
|
|
@@ -309,15 +349,13 @@ module GithubGem
|
|
309
349
|
open(__FILE__, "w") { |file| file.write(response.body) }
|
310
350
|
end
|
311
351
|
|
312
|
-
relative_file = File.expand_path(__FILE__).sub(%r[^#{
|
313
|
-
if git
|
314
|
-
git
|
315
|
-
git
|
316
|
-
puts "Updated to latest version of gem release management tasks."
|
352
|
+
relative_file = File.expand_path(__FILE__).sub(%r[^#{@root_dir}/], '')
|
353
|
+
if `#{git} ls-files -m #{relative_file}`.split("\n").any?
|
354
|
+
sh git, 'add', relative_file
|
355
|
+
sh git, 'commit', '-m', "Updated to latest gem release management tasks."
|
317
356
|
else
|
318
357
|
puts "Release managament tasks already are at the latest version."
|
319
358
|
end
|
320
359
|
end
|
321
|
-
|
322
360
|
end
|
323
361
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clieop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Willem van Bergen
|
@@ -16,10 +16,53 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-12-09 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
|
-
dependencies:
|
22
|
-
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: rake
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 7
|
45
|
+
segments:
|
46
|
+
- 2
|
47
|
+
- 2
|
48
|
+
version: "2.2"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: ZenTest
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 19
|
60
|
+
segments:
|
61
|
+
- 4
|
62
|
+
- 4
|
63
|
+
version: "4.4"
|
64
|
+
type: :development
|
65
|
+
version_requirements: *id003
|
23
66
|
description: This library is a pure Ruby, MIT licensed implementation of the CLIEOP03 transaction format. CLIEOP03 can be used to communicate direct debt transactions with your (Dutch) bank.
|
24
67
|
email:
|
25
68
|
- willem@vanbergen.org
|
@@ -31,23 +74,27 @@ extensions: []
|
|
31
74
|
extra_rdoc_files: []
|
32
75
|
|
33
76
|
files:
|
34
|
-
- spec/spec_helper.rb
|
35
|
-
- spec/clieop/batch_spec.rb
|
36
77
|
- .gitignore
|
37
|
-
-
|
78
|
+
- .rspec
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
38
81
|
- MIT-LICENSE
|
39
|
-
-
|
40
|
-
- lib/clieop/file.rb
|
41
|
-
- lib/clieop/batch.rb
|
42
|
-
- lib/clieop.rb
|
43
|
-
- init.rb
|
82
|
+
- README.rdoc
|
44
83
|
- Rakefile
|
84
|
+
- autotest/discover.rb
|
45
85
|
- clieop.gemspec
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
86
|
+
- doc/clieop03.pdf
|
87
|
+
- init.rb
|
88
|
+
- lib/clieop.rb
|
89
|
+
- lib/clieop/batch.rb
|
90
|
+
- lib/clieop/file.rb
|
91
|
+
- lib/clieop/record.rb
|
92
|
+
- spec/clieop/batch_spec.rb
|
50
93
|
- spec/clieop/file_spec.rb
|
94
|
+
- spec/clieop/record_spec.rb
|
95
|
+
- spec/clieop_spec.rb
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
- tasks/github-gem.rake
|
51
98
|
has_rdoc: true
|
52
99
|
homepage: http://github.com/wvanbergen/clieop/wikis
|
53
100
|
licenses: []
|
@@ -84,6 +131,6 @@ specification_version: 3
|
|
84
131
|
summary: A pure Ruby implementation to write CLIEOP files
|
85
132
|
test_files:
|
86
133
|
- spec/clieop/batch_spec.rb
|
87
|
-
- spec/clieop_spec.rb
|
88
|
-
- spec/clieop/record_spec.rb
|
89
134
|
- spec/clieop/file_spec.rb
|
135
|
+
- spec/clieop/record_spec.rb
|
136
|
+
- spec/clieop_spec.rb
|