ci_power 0.0.27 → 0.0.28

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,7 +25,12 @@ module CiPower
25
25
  field = method(method_name).call
26
26
  field = field.to_s unless field.is_a? String
27
27
  # Workaround for special characters problem
28
- if field.scan(/./mu).size < field.size
28
+ given_field_size = field.scan(/./mu).size
29
+ # truncate if field is too long
30
+ if given_field_size > field.size
31
+ field = truncate(field, field.size)
32
+ end
33
+ if given_field_size < field.size
29
34
  length = adjust_length(field, length)
30
35
  end
31
36
  line << field.ljust(length)
@@ -38,5 +43,16 @@ module CiPower
38
43
  difference = string.size - string.scan(/./mu).size
39
44
  length += difference
40
45
  end
46
+
47
+ def truncate(string, length)
48
+ output = ''
49
+ # this way is necessary when text contains special characters!
50
+ string_array = string.to_s.strip.scan(/./mu)
51
+ string_array.each_index do |i|
52
+ break if i >= length
53
+ output += string_array[i]
54
+ end
55
+ output
56
+ end
41
57
  end
42
58
  end
@@ -1,3 +1,3 @@
1
1
  module CiPower
2
- VERSION = "0.0.27"
2
+ VERSION = "0.0.28"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ci_power
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.27
5
+ version: 0.0.28
6
6
  platform: ruby
7
7
  authors:
8
8
  - Maik Duff
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-09-19 00:00:00 +02:00
13
+ date: 2012-12-05 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency