ifmb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - rbx-19mode
5
+ - jruby-19mode
6
+ - 1.9.2
7
+ - 1.9.3
8
+ - ruby-head
data/README.md CHANGED
@@ -1,12 +1,18 @@
1
- # Ifmb
1
+ # IFMB [![Build Status](https://secure.travis-ci.org/Sinemys/ifmb.png?branch=master)](https://travis-ci.org/Sinemys/ifmb) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/Sinemys/ifmb)
2
+
3
+ This is gem is a basic implementation to bill via IFMB service from IFTHEN.
4
+ It is a fork from https://github.com/Davidslv/MB and this may fail because it was not fully tested yet.
5
+
6
+ ## Features
7
+ * Generate payment references to pay via MB (ATM)
8
+ * Format the payment data in html
2
9
 
3
- TODO: Write a gem description
4
10
 
5
11
  ## Installation
6
12
 
7
13
  Add this line to your application's Gemfile:
8
14
 
9
- gem 'ifmb_generator'
15
+ gem 'ifmb'
10
16
 
11
17
  And then execute:
12
18
 
@@ -17,8 +23,20 @@ Or install it yourself as:
17
23
  $ gem install ifmb
18
24
 
19
25
  ## Usage
20
-
21
- TODO: Write usage instructions here
26
+ ```ruby
27
+ payment_data = {
28
+ entidade: 11604,
29
+ sub_entidade: 999,
30
+ order_id: 1234,
31
+ order_value: 25.86
32
+ }
33
+
34
+ @generator = Ifmb::Generator.new(payment_data)
35
+ @generator.generate # => your payment reference to give to the user
36
+
37
+ # You can also use the html format to print directly
38
+ <%= @generator.in_html %>
39
+ ```
22
40
 
23
41
  ## Contributing
24
42
 
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+ task :test => :spec
@@ -10,9 +10,11 @@ Gem::Specification.new do |gem|
10
10
  gem.summary = %q{Payment references generation for IFMB}
11
11
  gem.homepage = "http://github.com/sinemys/ifmb"
12
12
 
13
+ gem.add_development_dependency('rake')
13
14
  gem.add_development_dependency('rspec')
14
15
  gem.add_development_dependency('guard-rspec')
15
16
  gem.add_development_dependency('rb-fsevent')
17
+ gem.add_development_dependency('simplecov')
16
18
 
17
19
  gem.files = `git ls-files`.split($\)
18
20
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -1,5 +1,5 @@
1
- require "Ifmb/version"
2
- require 'Ifmb/html_formatter'
1
+ require "ifmb/version"
2
+ require 'ifmb/html_formatter'
3
3
  require 'ifmb/generator'
4
4
 
5
5
  module Ifmb
@@ -19,7 +19,7 @@ module Ifmb
19
19
 
20
20
  [:entidade, :sub_entidade, :order_id, :order_value].each do |attr|
21
21
  define_method "#{attr}=" do |value|
22
- # refresh validation
22
+ # TODO refresh validation
23
23
  instance_variable_set "@#{attr}", value
24
24
  end
25
25
  end
@@ -59,26 +59,19 @@ module Ifmb
59
59
  def generate
60
60
  raise ArgumentError.new "arguments are invalid! #{@errors}" unless valid?
61
61
 
62
-
63
-
64
62
  check_val = 0
65
63
  # order_id = "0000" + order_id.to_s
66
64
 
67
- puts order_value.inspect
68
-
69
65
  # order_id = order_id.slice((order_id.length - 4)..-1).to_s
70
66
 
71
-
72
67
  if ((order_value.to_f * 100).round < 1)
73
- p 'impossivel de realizar pagamentos de 1 euro'
74
- exit
68
+ raise RuntimeError.new 'impossivel de realizar pagamentos de 1 euro'
75
69
  end
76
70
 
77
71
  if ((order_value.to_f * 100).round >= 1_000_000)
78
72
  # this is not implemented
79
73
  # related with the while loop
80
- p 'Aviso: Pagamento Fraccionado por exceder o valor limite para pagamentos por multibanco'
81
- exit
74
+ raise RuntimeError.new 'Aviso: Pagamento Fraccionado por exceder o valor limite para pagamentos por multibanco'
82
75
  end
83
76
 
84
77
  # this is not implemented
@@ -87,7 +80,7 @@ module Ifmb
87
80
  # generate_mb_ref(entidade, sub_entidade, order_id, 999999.99)
88
81
  # order_value = order_value.to_f - 999999.99
89
82
  # end
90
- puts order_id
83
+
91
84
 
92
85
  check_str = sprintf('%05u%03u%04u%08u', entidade, sub_entidade, order_id.to_s, (order_value.to_f * 100).round)
93
86
 
@@ -102,9 +95,6 @@ module Ifmb
102
95
 
103
96
  check_digits = sprintf('%02u', 98-check_val);
104
97
 
105
- p "ENTIDADE : #{entidade}"
106
- p "REFERENCIA: #{sub_entidade} #{check_str[8,3]} #{check_str[11,1]} #{check_digits}"
107
- p "VALOR : #{order_value}"
108
98
  @referencia = "#{sub_entidade}#{check_str[8,3]}#{check_str[11,1]}#{check_digits}".to_i
109
99
  end
110
100
 
@@ -1,3 +1,3 @@
1
1
  module Ifmb
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'Ifmb'
2
+ require 'ifmb'
3
3
 
4
4
  describe Ifmb::Generator do
5
5
 
@@ -1,3 +1,10 @@
1
+ unless ENV['CI']
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter 'spec'
5
+ end
6
+ end
7
+
1
8
  require 'rspec'
2
9
  require 'ifmb'
3
10
  RSpec.configure do |c|
@@ -1,5 +1,7 @@
1
+ gem 'ifmb'
1
2
  require 'ifmb'
2
3
 
3
4
  generator = Ifmb::Generator.new entidade: 18282, sub_entidade: 123, order_id: 162, order_value: 234.23
4
- generator.generate
5
- generator.in_html
5
+ puts generator.generate
6
+ puts ''
7
+ puts generator.in_html
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ifmb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,8 +10,24 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-21 00:00:00.000000000 Z
13
+ date: 2012-11-22 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
15
31
  - !ruby/object:Gem::Dependency
16
32
  name: rspec
17
33
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +76,22 @@ dependencies:
60
76
  - - ! '>='
61
77
  - !ruby/object:Gem::Version
62
78
  version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: simplecov
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
63
95
  description: Generate references for IFMB payments (portuguese ATM payment service
64
96
  from IFTHEN)
65
97
  email:
@@ -70,6 +102,7 @@ extra_rdoc_files: []
70
102
  files:
71
103
  - .gitignore
72
104
  - .rspec
105
+ - .travis.yml
73
106
  - Gemfile
74
107
  - Guardfile
75
108
  - LICENSE