cuculungwa 0.0.46 → 0.0.47

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cuculungwa.rb +12 -14
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef28ffa753351ea74a2145e41c8ff894ffb7d460
4
- data.tar.gz: 120d6053901d94d83ff81d1370626f7dbaf38544
3
+ metadata.gz: 6eab74c8b33adc6bed7c46adba0f9e4c6f1d3b8c
4
+ data.tar.gz: 4500077934b8854906454fa18c52d537e842193d
5
5
  SHA512:
6
- metadata.gz: 95368f8cb6a986aa60c2b26feecfe6ca334f38c1c39bb42114008a94462a5a6b05d7aaa890f27922fdda45ce291977e16a69b3209c6a1141bae33537242aba80
7
- data.tar.gz: af89b6b07a2d4cce038d6f86582c358cc68b9fbfcd2dcb2942cc86371ff507c8b82aa529cb421b5d4e519282cdb36d715b95589ade2adf74e7ec5c6ee6a991fe
6
+ metadata.gz: 9edff6a51cdce2019b3a98222a3b3e80ad8fa3b3537f9d6b5b3be2dbae141e7ac2d66fdd629ab5c8a4f5e4ed658bb747ec5875c0bf06e4d97c61ff7be8a2a432
7
+ data.tar.gz: dd31a1e1c07a1cc1a0d712407e86412ed99539f401d06d5aed79427b724bd6c2f2530c437e41a4b01d32c1a923fb302ac807929fb6a47b1bb600637b2669e597
data/lib/cuculungwa.rb CHANGED
@@ -113,17 +113,16 @@ module GenerateData
113
113
 
114
114
  def nip_generator(data_type)
115
115
  if (data_type.eql? 'positive_data_set')
116
- weights = Array[6, 5, 7, 2, 3, 4, 5, 6, 7]
117
- code = rand()*998+101
118
- number = rand()*999999
119
- nip = "%d%d"%[code, number]
120
- temp_cs = 0
121
- nip_elem = nip.each_char.map{|c| c.to_i}
122
- for i in 0..weights.length-1
123
- temp_cs += weights[i]*nip_elem[i]
124
- end
125
- control_sum = temp_cs%11
126
- return nip + control_sum.to_s
116
+ weights = [6, 5, 7, 2, 3, 4, 5, 6, 7]
117
+ code = rand(998-101) + 101
118
+ number = rand(1000000)
119
+ nip = code.to_s + number.to_s.rjust(6, '0')
120
+
121
+ c = nip.split(//).map! {|x| x.to_i}
122
+ sum = c.zip(weights).map! {|x| x[0]*x[1]}.reduce(:+) % 11
123
+
124
+ sum = sum == 10 ? 0 : sum
125
+ return nip + sum.to_s
127
126
  elsif (data_type.eql? 'negative_data_set')
128
127
  return "000"
129
128
  else
@@ -162,15 +161,14 @@ module Utils
162
161
  return iban_number
163
162
  end
164
163
 
165
- def wait_for_expected_result(timespan = @app.config['capybara']['default_wait_time'])
164
+ def wait_for_expected_result(timespan = @app.config['capybara']['default_wait_time'], exception_type = RSpec::Expectations::ExpectationNotMetError)
166
165
  # Default setting: get default wait time from config.yml
167
-
168
166
  _then = Time.now
169
167
  while true
170
168
  begin
171
169
  yield
172
170
  break
173
- rescue RSpec::Expectations::ExpectationNotMetError => e
171
+ rescue exception_type => e
174
172
  # Expectations were not met, check if we timed out, otherwise try one more time
175
173
  if Time.now > _then + timespan then
176
174
  puts "Timeout."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuculungwa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.46
4
+ version: 0.0.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Kaftanski