jvmargs 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -96,22 +96,7 @@ module JVMArgs
96
96
  end
97
97
 
98
98
  def heap_size(size)
99
- if (size =~ /([0-9]+)%/)
100
- percent = $1.to_i * 0.01
101
- if percent > 1
102
- raise ArgumentError, "heap_size percentage must be less than 100%, you provided #{$1}%"
103
- elsif percent < 0.01
104
- raise ArgumentError, "heap_size percentage must be between 100% - 1%, you provided #{$1}%"
105
- end
106
- system_ram = JVMArgs::Util.get_system_ram_m.sub(/M/,'').to_i
107
- size_ram = "#{(system_ram * percent).to_i}M"
108
- else
109
- begin
110
- size_ram = JVMArgs::Util.convert_to_m(size)
111
- rescue ArgumentError
112
- raise ArgumentError, "heap_size percentage must be a percentage or a fixed size in KiloBytes(K), MegaBytes (M), or Gigabytes(G)"
113
- end
114
- end
99
+ size_ram = JVMArgs::Util.parse_ram_size_to_m(size)
115
100
  @args[:nonstandard]["Xmx"] = JVMArgs::NonStandard.new("-Xmx#{size_ram}")
116
101
  @args[:nonstandard]["Xms"] = JVMArgs::NonStandard.new("-Xms#{size_ram}")
117
102
  end
@@ -4,11 +4,12 @@ module JVMArgs
4
4
 
5
5
  def initialize(arg)
6
6
  stripped = arg.sub(/^-/, '')
7
- stripped =~ /(X[a-z]+)([0-9]+[a-zA-Z])?/
8
- @key = $1
7
+ stripped =~ /(X[a-z]+:?)([0-9]+[a-zA-Z])?/
9
8
  if $2.nil?
10
- @value = true
9
+ @key = $1
10
+ @value = stripped[@key.length..-1] # could be an empty string
11
11
  else
12
+ @key = $1
12
13
  @value = JVMArgs::Util.convert_to_m($2)
13
14
  # value is a kilobyte value < 1 MB after conversion
14
15
  if @value == "0M"
@@ -18,11 +19,7 @@ module JVMArgs
18
19
  end
19
20
 
20
21
  def to_s
21
- if @value == true
22
- "-#{@key}"
23
- else
24
- "-#{@key}#{@value}"
25
- end
22
+ "-#{@key}#{@value}"
26
23
  end
27
24
  end
28
25
  end
@@ -39,5 +39,25 @@ module JVMArgs
39
39
  [$1.to_i, $2.upcase]
40
40
  end
41
41
 
42
+ # Accepts a 'size' value such as 70% or 5G and converts this to
43
+ # the size in M.
44
+ def self.parse_ram_size_to_m(size)
45
+ if (size =~ /([0-9]+)%/)
46
+ percent = $1.to_i * 0.01
47
+ if percent > 1
48
+ raise ArgumentError, "heap_size percentage must be less than 100%, you provided #{$1}%"
49
+ elsif percent < 0.01
50
+ raise ArgumentError, "heap_size percentage must be between 100% - 1%, you provided #{$1}%"
51
+ end
52
+ system_ram = JVMArgs::Util.get_system_ram_m.sub(/M/,'').to_i
53
+ size_ram = "#{(system_ram * percent).to_i}M"
54
+ else
55
+ begin
56
+ size_ram = JVMArgs::Util.convert_to_m(size)
57
+ rescue ArgumentError
58
+ raise ArgumentError, "heap_size percentage must be a percentage or a fixed size in KiloBytes(K), MegaBytes (M), or Gigabytes(G)"
59
+ end
60
+ end
61
+ end
42
62
  end
43
63
  end
@@ -1,4 +1,4 @@
1
1
  module JVMArgs
2
2
  # The gem version
3
- VERSION = '0.0.6'
3
+ VERSION = '0.0.7'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jvmargs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-20 00:00:00.000000000 Z
12
+ date: 2013-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -115,6 +115,6 @@ rubyforge_project:
115
115
  rubygems_version: 1.8.25
116
116
  signing_key:
117
117
  specification_version: 3
118
- summary: jvmargs-0.0.6
118
+ summary: jvmargs-0.0.7
119
119
  test_files: []
120
120
  has_rdoc: