ci_power 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,109 +1,109 @@
1
- module CiPower
2
- class ProcessData < Record
3
- attr_accessor :enforcement_date,
4
- :enforcement_demand_action,
5
- :delivery_date,
6
- :continue_date,
7
- :enforcement_no,
8
- :enforcement_on,
9
- :enforcement_bureau,
10
- :comment,
11
- :processes_to_date,
12
- :execution_date,
13
- :reclamation_from_date,
14
- :reclamation_to_date,
15
- :is_income_variable,
16
- :is_third_party_claim,
17
- :is_real_estate,
18
- :execution_amount,
19
- :income,
20
- :quote,
21
- :living_wage,
22
- :execution_type,
23
- :enforcement_group,
24
- :third_party_claim,
25
- :real_estate,
26
- :reclamation_objects,
27
- :unpaid_debts_certificate_date,
28
- :is_continuable_after_6months,
29
- :unpaid_debts_amount,
30
- :gain,
31
- :loss,
32
- :unpaid_debts_type,
33
- :gain_dropdown,
34
- :unpaid_debts_certificate_no,
35
- :claim_petition_date,
36
- :opening_of_bankruptcy_date,
37
- :opening_of_bankruptcy_process,
38
- :opening_of_bankruptcy_process_no,
39
- :directive_date,
40
- :decision_date,
41
- :judicial_vitiation_date,
42
- :legal_effect_date,
43
- :case_no_directive,
44
- :case_no_decision,
45
- :cip_dossier_no,
46
- :unpaid_debts_certificate_transfer_application_date
47
-
48
- def initialize(attributes = {})
49
- if attributes.is_a? Hash
50
- attributes.merge! :record_type => '19'
51
- attributes.each do |key, value|
52
- self.send("#{key}=".to_sym, value) if self.respond_to?("#{key}=")
53
- end
54
- end
55
- end
56
-
57
- def to_cip(with_line_terminator = true)
58
- cip_default_data << fill_up(
59
- {
60
- :enforcement_date => 10,
61
- :enforcement_demand_action => 10,
62
- :delivery_date => 10,
63
- :continue_date => 10,
64
- :enforcement_no => 32,
65
- :enforcement_on => 32,
66
- :enforcement_bureau => 120,
67
- :comment => 120,
68
- :processes_to_date => 10,
69
- :execution_date => 10,
70
- :reclamation_from_date => 10,
71
- :reclamation_to_date => 10,
72
- :is_income_variable => 1,
73
- :is_third_party_claim => 1,
74
- :is_real_estate => 1,
75
- :execution_amount => 15,
76
- :income => 15,
77
- :quote => 15,
78
- :living_wage => 15,
79
- :execution_type => 32,
80
- :enforcement_group => 32,
81
- :third_party_claim => 64,
82
- :real_estate => 64,
83
- :reclamation_objects => 240,
84
- :unpaid_debts_certificate_date => 10,
85
- :is_continuable_after_6months => 1,
86
- :unpaid_debts_amount => 15,
87
- :gain => 15,
88
- :loss => 15,
89
- :unpaid_debts_type => 32,
90
- :gain_dropdown => 32,
91
- :unpaid_debts_certificate_no => 32,
92
- :claim_petition_date => 10,
93
- :opening_of_bankruptcy_date => 10,
94
- :opening_of_bankruptcy_process => 32,
95
- :opening_of_bankruptcy_process_no => 32,
96
- :directive_date => 10,
97
- :decision_date => 10,
98
- :judicial_vitiation_date => 10,
99
- :legal_effect_date => 10,
100
- :case_no_directive => 32,
101
- :case_no_decision => 32,
102
- :cip_dossier_no => 9,
103
- :unpaid_debts_certificate_transfer_application_date => 10
104
- }, with_line_terminator
105
- )
106
- end
107
-
108
- end
1
+ module CiPower
2
+ class ProcessData < Record
3
+ attr_accessor :enforcement_date,
4
+ :enforcement_demand_action,
5
+ :delivery_date,
6
+ :continue_date,
7
+ :enforcement_no,
8
+ :enforcement_on,
9
+ :enforcement_bureau,
10
+ :comment,
11
+ :processes_to_date,
12
+ :execution_date,
13
+ :reclamation_from_date,
14
+ :reclamation_to_date,
15
+ :is_income_variable,
16
+ :is_third_party_claim,
17
+ :is_real_estate,
18
+ :execution_amount,
19
+ :income,
20
+ :quote,
21
+ :living_wage,
22
+ :execution_type,
23
+ :enforcement_group,
24
+ :third_party_claim,
25
+ :real_estate,
26
+ :reclamation_objects,
27
+ :unpaid_debts_certificate_date,
28
+ :is_continuable_after_6months,
29
+ :unpaid_debts_amount,
30
+ :gain,
31
+ :loss,
32
+ :unpaid_debts_type,
33
+ :gain_dropdown,
34
+ :unpaid_debts_certificate_no,
35
+ :claim_petition_date,
36
+ :opening_of_bankruptcy_date,
37
+ :opening_of_bankruptcy_process,
38
+ :opening_of_bankruptcy_process_no,
39
+ :directive_date,
40
+ :decision_date,
41
+ :judicial_vitiation_date,
42
+ :legal_effect_date,
43
+ :case_no_directive,
44
+ :case_no_decision,
45
+ :cip_dossier_no,
46
+ :unpaid_debts_certificate_transfer_application_date
47
+
48
+ def initialize(attributes = {})
49
+ if attributes.is_a? Hash
50
+ attributes.merge! :record_type => '19'
51
+ attributes.each do |key, value|
52
+ self.send("#{key}=".to_sym, value) if self.respond_to?("#{key}=")
53
+ end
54
+ end
55
+ end
56
+
57
+ def to_cip(with_line_terminator = true)
58
+ cip_default_data << fill_up(
59
+ {
60
+ :enforcement_date => 10,
61
+ :enforcement_demand_action => 10,
62
+ :delivery_date => 10,
63
+ :continue_date => 10,
64
+ :enforcement_no => 32,
65
+ :enforcement_on => 32,
66
+ :enforcement_bureau => 120,
67
+ :comment => 120,
68
+ :processes_to_date => 10,
69
+ :execution_date => 10,
70
+ :reclamation_from_date => 10,
71
+ :reclamation_to_date => 10,
72
+ :is_income_variable => 1,
73
+ :is_third_party_claim => 1,
74
+ :is_real_estate => 1,
75
+ :execution_amount => 15,
76
+ :income => 15,
77
+ :quote => 15,
78
+ :living_wage => 15,
79
+ :execution_type => 32,
80
+ :enforcement_group => 32,
81
+ :third_party_claim => 64,
82
+ :real_estate => 64,
83
+ :reclamation_objects => 240,
84
+ :unpaid_debts_certificate_date => 10,
85
+ :is_continuable_after_6months => 1,
86
+ :unpaid_debts_amount => 15,
87
+ :gain => 15,
88
+ :loss => 15,
89
+ :unpaid_debts_type => 32,
90
+ :gain_dropdown => 32,
91
+ :unpaid_debts_certificate_no => 32,
92
+ :claim_petition_date => 10,
93
+ :opening_of_bankruptcy_date => 10,
94
+ :opening_of_bankruptcy_process => 32,
95
+ :opening_of_bankruptcy_process_no => 32,
96
+ :directive_date => 10,
97
+ :decision_date => 10,
98
+ :judicial_vitiation_date => 10,
99
+ :legal_effect_date => 10,
100
+ :case_no_directive => 32,
101
+ :case_no_decision => 32,
102
+ :cip_dossier_no => 9,
103
+ :unpaid_debts_certificate_transfer_application_date => 10
104
+ }, with_line_terminator
105
+ )
106
+ end
107
+
108
+ end
109
109
  end
@@ -1,42 +1,42 @@
1
- module CiPower
2
- class Record
3
- attr_accessor :record_type,
4
- :group_no,
5
- :address_identification_debtee,
6
- :address_identification_debtor
7
- {}
8
- def cip_default_data
9
- _fill_up(:record_type => 2, :group_no => 7, :address_identification_debtee => 25, :address_identification_debtor => 25)
10
- end
11
-
12
- def fill_up(data, with_line_terminator = true)
13
- _fill_up(data) + (with_line_terminator ? line_terminator : '')
14
- end
15
-
16
- def line_terminator
17
- "\n"
18
- end
19
-
20
- private
21
- def _fill_up(data)
22
- line = ""
23
- if data.is_a? Hash
24
- data.each do |method_name, length|
25
- field = method(method_name).call
26
- field = field.to_s unless field.is_a? String
27
- # Workaround for special characters problem
28
- if field.scan(/./mu).size < field.size
29
- length = adjust_length(field, length)
30
- end
31
- line << field.ljust(length)
32
- end
33
- end
34
- line
35
- end
36
-
37
- def adjust_length(string, length)
38
- difference = string.size - string.scan(/./mu).size
39
- length += difference
40
- end
41
- end
1
+ module CiPower
2
+ class Record
3
+ attr_accessor :record_type,
4
+ :group_no,
5
+ :address_identification_debtee,
6
+ :address_identification_debtor
7
+ {}
8
+ def cip_default_data
9
+ _fill_up(:record_type => 2, :group_no => 7, :address_identification_debtee => 25, :address_identification_debtor => 25)
10
+ end
11
+
12
+ def fill_up(data, with_line_terminator = true)
13
+ _fill_up(data) + (with_line_terminator ? line_terminator : '')
14
+ end
15
+
16
+ def line_terminator
17
+ "\n"
18
+ end
19
+
20
+ private
21
+ def _fill_up(data)
22
+ line = ""
23
+ if data.is_a? Hash
24
+ data.each do |method_name, length|
25
+ field = method(method_name).call
26
+ field = field.to_s unless field.is_a? String
27
+ # Workaround for special characters problem
28
+ if field.scan(/./mu).size < field.size
29
+ length = adjust_length(field, length)
30
+ end
31
+ line << field.ljust(length)
32
+ end
33
+ end
34
+ line
35
+ end
36
+
37
+ def adjust_length(string, length)
38
+ difference = string.size - string.scan(/./mu).size
39
+ length += difference
40
+ end
41
+ end
42
42
  end
@@ -1,3 +1,3 @@
1
- module CiPower
2
- VERSION = "0.0.24"
3
- end
1
+ module CiPower
2
+ VERSION = "0.0.25"
3
+ end
data/lib/ci_power.rb CHANGED
@@ -1,13 +1,13 @@
1
- require "ci_power/version"
2
-
3
- require "ci_power/export"
4
-
5
- require "ci_power/record"
6
- require "ci_power/dossier_data"
7
- require "ci_power/address"
8
- require "ci_power/communication"
9
- require "ci_power/debt_claim"
10
- require "ci_power/action"
11
- require "ci_power/open_appointment"
12
- require "ci_power/debtor_data"
13
- require "ci_power/installment_plan"
1
+ require "ci_power/version"
2
+
3
+ require "ci_power/export"
4
+
5
+ require "ci_power/record"
6
+ require "ci_power/dossier_data"
7
+ require "ci_power/address"
8
+ require "ci_power/communication"
9
+ require "ci_power/debt_claim"
10
+ require "ci_power/action"
11
+ require "ci_power/open_appointment"
12
+ require "ci_power/debtor_data"
13
+ require "ci_power/installment_plan"
@@ -1,12 +1,12 @@
1
- module CiPower
2
- module Generators
3
- class CiPowerGenerator < Rails::Generators::Base
4
- source_root File.expand_path('../templates', __FILE__)
5
-
6
- desc "This generator creates a model file at app/models"
7
- def generate_cip_export
8
- copy_file "cip_export.rb", "app/models/cip_export.rb"
9
- end
10
- end
11
- end
1
+ module CiPower
2
+ module Generators
3
+ class CiPowerGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ desc "This generator creates a model file at app/models"
7
+ def generate_cip_export
8
+ copy_file "cip_export.rb", "app/models/cip_export.rb"
9
+ end
10
+ end
11
+ end
12
12
  end
@@ -1,13 +1,13 @@
1
- class CipExport
2
- include CiPower::Export
3
-
4
- def initialize(output)
5
- # Define mapping for CI-Power export here. For example:
6
- #
7
- # Add dossier_data
8
- # output << dossier_data(:reference_1 => '99999', :interest_rate => '15')
9
- #
10
- # Add communication
11
- # output << communication(:type => 'T1', :text => '0812502850')
12
- end
1
+ class CipExport
2
+ include CiPower::Export
3
+
4
+ def initialize(output)
5
+ # Define mapping for CI-Power export here. For example:
6
+ #
7
+ # Add dossier_data
8
+ # output << dossier_data(:reference_1 => '99999', :interest_rate => '15')
9
+ #
10
+ # Add communication
11
+ # output << communication(:type => 'T1', :text => '0812502850')
12
+ end
13
13
  end
@@ -1,24 +1,24 @@
1
- namespace :ci_power do
2
- OUTPUT_FILE = 'tmp/ci_power_export.txt'
3
-
4
- desc 'Extract data from application'
5
- task :extract_data => :environment do
6
- @content = CipExport.new.output.sort_by { |a| [a.group_no, a.record_type] }
7
- end
8
-
9
- desc 'Export data into output file'
10
- task :export => :extract_data do
11
- File.open(OUTPUT_FILE, "w+") do |file|
12
- @content.each do |line|
13
- file.puts line.to_cip
14
- end
15
- end
16
- end
17
-
18
- desc 'Removes output file'
19
- task :clean do
20
- rm OUTPUT_FILE
21
- end
22
-
23
- task :default => "ci_power:export"
1
+ namespace :ci_power do
2
+ OUTPUT_FILE = 'tmp/ci_power_export.txt'
3
+
4
+ desc 'Extract data from application'
5
+ task :extract_data => :environment do
6
+ @content = CipExport.new.output.sort_by { |a| [a.group_no, a.record_type] }
7
+ end
8
+
9
+ desc 'Export data into output file'
10
+ task :export => :extract_data do
11
+ File.open(OUTPUT_FILE, "w+") do |file|
12
+ @content.each do |line|
13
+ file.puts line.to_cip
14
+ end
15
+ end
16
+ end
17
+
18
+ desc 'Removes output file'
19
+ task :clean do
20
+ rm OUTPUT_FILE
21
+ end
22
+
23
+ task :default => "ci_power:export"
24
24
  end
@@ -1,75 +1,75 @@
1
- require 'spec_helper'
2
-
3
- module CiPower
4
- describe Export do
5
- # created dummy class with module behaviour
6
- let(:dummy_class) do
7
- Class.new do
8
- extend(CiPower::Export)
9
- end
10
- end
11
-
12
- context "when module is included" do
13
- it "output should an empty array" do
14
- dummy_class.output.should be_instance_of Array
15
- dummy_class.output.should be_empty
16
- end
17
-
18
- it "group_no should be 0" do
19
- dummy_class.group_no.should == 0
20
- end
21
-
22
- it "data_format should be '%Y%m%d'" do
23
- dummy_class.date_format.should == '%Y%m%d'
24
- end
25
- end
26
-
27
- describe "#convert_date" do
28
- it "when date is valid should convert date to format" do
29
-
30
- unconverted_date = Time.local 2012, 7, 31
31
-
32
- converted_date = dummy_class.convert_date(unconverted_date)
33
- converted_date.should == "20120731"
34
- end
35
-
36
- it "when date is not valid do nothing" do
37
- converted_date = dummy_class.convert_date("XXX")
38
- converted_date.should be_nil
39
- end
40
- end
41
-
42
- describe "#date_format" do
43
- it "should change the date format" do
44
- dummy_class.date_format = 'new_format'
45
- dummy_class.date_format.should == 'new_format'
46
- end
47
-
48
- context "when the date format is changed" do
49
- before(:each) { dummy_class.date_format = '%d-%m-%Y' }
50
-
51
- it "should format the date with the new format" do
52
- date_string = dummy_class.convert_date Time.local(2012, 7, 31)
53
- date_string.should == "31-07-2012"
54
- end
55
- end
56
- end
57
-
58
- {:dossier_data_record => 'CiPower::DossierData',
59
- :address_record => 'CiPower::Address',
60
- :communication_record => 'CiPower::Communication',
61
- :debtor_data_record => 'CiPower::DebtorData',
62
- :debt_claim_record => 'CiPower::DebtClaim',
63
- :action_record => 'CiPower::Action',
64
- :open_appointment_record => 'CiPower::OpenAppointment',
65
- :installment_plan_record => 'CiPower::InstallmentPlan'
66
- }.each do |method, clazz|
67
- describe "##{method.to_s}" do
68
- it "generates a new instance of #{clazz}" do
69
- record = dummy_class.send(method, :test => 'test')
70
- record.should be_instance_of clazz.split("::").inject(Object) { |ref, clazz| ref::const_get(clazz) }
71
- end
72
- end
73
- end
74
- end
1
+ require 'spec_helper'
2
+
3
+ module CiPower
4
+ describe Export do
5
+ # created dummy class with module behaviour
6
+ let(:dummy_class) do
7
+ Class.new do
8
+ extend(CiPower::Export)
9
+ end
10
+ end
11
+
12
+ context "when module is included" do
13
+ it "output should an empty array" do
14
+ dummy_class.output.should be_instance_of Array
15
+ dummy_class.output.should be_empty
16
+ end
17
+
18
+ it "group_no should be 0" do
19
+ dummy_class.group_no.should == 0
20
+ end
21
+
22
+ it "data_format should be '%Y%m%d'" do
23
+ dummy_class.date_format.should == '%Y%m%d'
24
+ end
25
+ end
26
+
27
+ describe "#convert_date" do
28
+ it "when date is valid should convert date to format" do
29
+
30
+ unconverted_date = Time.local 2012, 7, 31
31
+
32
+ converted_date = dummy_class.convert_date(unconverted_date)
33
+ converted_date.should == "20120731"
34
+ end
35
+
36
+ it "when date is not valid do nothing" do
37
+ converted_date = dummy_class.convert_date("XXX")
38
+ converted_date.should be_nil
39
+ end
40
+ end
41
+
42
+ describe "#date_format" do
43
+ it "should change the date format" do
44
+ dummy_class.date_format = 'new_format'
45
+ dummy_class.date_format.should == 'new_format'
46
+ end
47
+
48
+ context "when the date format is changed" do
49
+ before(:each) { dummy_class.date_format = '%d-%m-%Y' }
50
+
51
+ it "should format the date with the new format" do
52
+ date_string = dummy_class.convert_date Time.local(2012, 7, 31)
53
+ date_string.should == "31-07-2012"
54
+ end
55
+ end
56
+ end
57
+
58
+ {:dossier_data_record => 'CiPower::DossierData',
59
+ :address_record => 'CiPower::Address',
60
+ :communication_record => 'CiPower::Communication',
61
+ :debtor_data_record => 'CiPower::DebtorData',
62
+ :debt_claim_record => 'CiPower::DebtClaim',
63
+ :action_record => 'CiPower::Action',
64
+ :open_appointment_record => 'CiPower::OpenAppointment',
65
+ :installment_plan_record => 'CiPower::InstallmentPlan'
66
+ }.each do |method, clazz|
67
+ describe "##{method.to_s}" do
68
+ it "generates a new instance of #{clazz}" do
69
+ record = dummy_class.send(method, :test => 'test')
70
+ record.should be_instance_of clazz.split("::").inject(Object) { |ref, clazz| ref::const_get(clazz) }
71
+ end
72
+ end
73
+ end
74
+ end
75
75
  end