rulp 0.0.44 → 0.0.45

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b02471f804f1086c6193730ce602be9cf03d3ab4
4
- data.tar.gz: a9f7197bb1aeb4a1a707333244b6600fed798322
2
+ SHA256:
3
+ metadata.gz: 58a47250456efb480a41ea21a923355242c38c27d1e9eb04d17782493a51b083
4
+ data.tar.gz: e7b05a98c43d57035049cd1b2537fd3ecb42792e08114d8dd0729229092e96ac
5
5
  SHA512:
6
- metadata.gz: 5268c02947e586c5ad74630a9d9aadbca40c29f9ea5078f0f2a31563fdc81016a0664fc8d1f5b0406a7a5fe5d63d4e0ddfbd526a555f6b02525b509271a7707f
7
- data.tar.gz: 280a4f73804264683b9f65cfe42244934f12cf5a585a62e13f6d7cd8823466d1fc1fb43ff83d694fdf6d3e0a1e7cc0c29fbd373a53885f3b3b1f318435b6c283
6
+ metadata.gz: d12655f339c1095d9bc5f3c4620829965e3375ae4025fceeaea0438d97e6f334bdc0b727e0ac975d03ef8b688da4775c6c34cc9b56c0885cfa6fe38cd757d2dc
7
+ data.tar.gz: 9a3bd500cabd00c9118ff81cd79da588d629f5ee5788eae993d986161cd2ce3da715965534491f3d088b202154e53f124f7053dea671df606b028db96e24cdb4
@@ -1,5 +1,4 @@
1
- require_relative './array_extensions'
2
1
  require_relative './kernel_extensions'
3
2
  require_relative './object_extensions'
4
3
  require_relative './file_extensions'
5
- require_relative './os_extensions'
4
+ require_relative './os_extensions'
@@ -18,17 +18,15 @@ module Kernel
18
18
  alias_method :old_method_missing, :method_missing
19
19
  def method_missing(value, *args)
20
20
  method_name = "#{value}" rescue ""
21
- start = method_name[0]
22
- if (start <= "Z" && start >= "A")
23
- case method_name[-1]
24
- when "b"
25
- method_name = method_name[0..(method_name[-2] == "_" ? -3 : -2)]
21
+ if ("A".."Z").cover?(method_name[0])
22
+ if method_name.end_with?(BV.suffix)
23
+ method_name = method_name.chomp(BV.suffix).chomp("_")
26
24
  return BV.definition(method_name, args)
27
- when "i"
28
- method_name = method_name[0..(method_name[-2] == "_" ? -3 : -2)]
25
+ elsif method_name.end_with?(IV.suffix)
26
+ method_name = method_name.chomp(IV.suffix).chomp("_")
29
27
  return IV.definition(method_name, args)
30
- when "f"
31
- method_name = method_name[0..(method_name[-2] == "_" ? -3 : -2)]
28
+ elsif method_name.end_with?(LV.suffix)
29
+ method_name = method_name.chomp(LV.suffix).chomp("_")
32
30
  return LV.definition(method_name, args)
33
31
  end
34
32
  end
@@ -14,13 +14,13 @@ class << Object
14
14
  alias_method :old_const_missing, :const_missing
15
15
  def const_missing(value)
16
16
  method_name = "#{value}".split("::")[-1] rescue ""
17
- if (("A".."Z").include?(method_name[0]))
18
- if(method_name.end_with?("b"))
19
- return BV.definition(method_name[0..(method_name[-2] == "_" ? -3 : -2)])
20
- elsif(method_name.end_with?("i"))
21
- return IV.definition(method_name[0..(method_name[-2] == "_" ? -3 : -2)])
22
- elsif(method_name.end_with?("f"))
23
- return LV.definition(method_name[0..(method_name[-2] == "_" ? -3 : -2)])
17
+ if ("A".."Z").cover?(method_name[0])
18
+ if method_name.end_with?(BV.suffix)
19
+ return BV.definition(method_name.chomp(BV.suffix).chomp("_"))
20
+ elsif method_name.end_with?(IV.suffix)
21
+ return IV.definition(method_name.chomp(IV.suffix).chomp("_"))
22
+ elsif method_name.end_with?(LV.suffix)
23
+ return LV.definition(method_name.chomp(LV.suffix).chomp("_"))
24
24
  end
25
25
  end
26
26
  old_const_missing(value)
data/lib/rulp/lv.rb CHANGED
@@ -21,8 +21,12 @@ class LV
21
21
  "#{self.name}_#{self.suffix}"
22
22
  end
23
23
 
24
+ def self.suffix
25
+ ENV['RULP_LV_SUFFIX'] || "f"
26
+ end
27
+
24
28
  def suffix
25
- "f"
29
+ self.class.suffix
26
30
  end
27
31
 
28
32
  def self.definition(name, *args)
@@ -74,12 +78,13 @@ class LV
74
78
  end
75
79
 
76
80
  class BV < LV;
77
- def suffix
78
- "b"
81
+ def self.suffix
82
+ ENV['RULP_BV_SUFFIX'] || "b"
79
83
  end
80
84
  end
85
+
81
86
  class IV < LV;
82
- def suffix
83
- "i"
87
+ def self.suffix
88
+ ENV['RULP_IV_SUFFIX'] || "i"
84
89
  end
85
- end
90
+ end
data/lib/rulp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rulp
2
- VERSION = '0.0.44'
2
+ VERSION = '0.0.45'
3
3
  end
data/test/test_boolean.rb CHANGED
@@ -8,8 +8,8 @@ require_relative 'test_helper'
8
8
  class BooleanTest < Minitest::Test
9
9
  def setup
10
10
  @items = 30.times.map(&Shop_Item_b)
11
- items_count = @items.sum
12
- @items_costs = @items.map{|item| item * Random.rand(1.0...5.0)}.sum
11
+ items_count = @items.inject(:+)
12
+ @items_costs = @items.map{|item| item * Random.rand(1.0...5.0)}.inject(:+)
13
13
 
14
14
  @problem =
15
15
  Rulp::Min( @items_costs ) [
@@ -8,8 +8,8 @@ require_relative 'test_helper'
8
8
  class InfeasibleTest < Minitest::Test
9
9
  def setup
10
10
  @items = 30.times.map(&Shop_Item_b)
11
- items_count = @items.sum
12
- @items_costs = @items.map{|item| item * Random.rand(1.0...5.0)}.sum
11
+ items_count = @items.inject(:+)
12
+ @items_costs = @items.map{|item| item * Random.rand(1.0...5.0)}.inject(:+)
13
13
 
14
14
  @problem =
15
15
  Rulp::Min( @items_costs ) [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rulp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.44
4
+ version: 0.0.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-01 00:00:00.000000000 Z
11
+ date: 2024-03-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple Ruby LP description DSL
14
14
  email: wc@pico.net.nz
@@ -18,7 +18,6 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - bin/rulp
21
- - lib/extensions/array_extensions.rb
22
21
  - lib/extensions/extensions.rb
23
22
  - lib/extensions/file_extensions.rb
24
23
  - lib/extensions/kernel_extensions.rb
@@ -45,10 +44,10 @@ files:
45
44
  - test/test_infeasible.rb
46
45
  - test/test_save_to_file.rb
47
46
  - test/test_simple.rb
48
- homepage:
47
+ homepage:
49
48
  licenses: []
50
49
  metadata: {}
51
- post_install_message:
50
+ post_install_message:
52
51
  rdoc_options: []
53
52
  require_paths:
54
53
  - lib
@@ -63,9 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
62
  - !ruby/object:Gem::Version
64
63
  version: '0'
65
64
  requirements: []
66
- rubyforge_project:
67
- rubygems_version: 2.5.1
68
- signing_key:
65
+ rubygems_version: 3.5.6
66
+ signing_key:
69
67
  specification_version: 4
70
68
  summary: Ruby Linear Programming
71
69
  test_files:
@@ -1,5 +0,0 @@
1
- class Array
2
- def sum
3
- self.inject(:+)
4
- end
5
- end