toolhound-ruby 1.0.7 → 1.0.8

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
2
  SHA1:
3
- metadata.gz: 56b2a904fa9e63bf93b7df672026dcbfa458bbfe
4
- data.tar.gz: 218d36a7325fab73a2f55d252763d86efdde35b2
3
+ metadata.gz: e9bb19365bad8211a21cb1236ab9dd44ec5b567e
4
+ data.tar.gz: 916ecdf9c5d21387356a34ff121fe61acef0f4f8
5
5
  SHA512:
6
- metadata.gz: 634b7f860ff50b570701a3aaa0df814caedcde2eff78b2b88097b519176c6abef2909708c15d63030d8b0e811f59fdeee3691aa5072b77b1248855a23947da2a
7
- data.tar.gz: 166a718f791167da439e230996b2e4beac764c96703eba2ea27056aab56ad2f9361d7a3f1902f1cd4a66bba093b4e86de2890f88cf6daf7384f8bbbd9591431c
6
+ metadata.gz: a1e885e703b4cef7a1f0a883371bb44aa19f8287f8c3930cf0f6d69d0089f5b40a796056acdc5c62ab2d519ddb7decf0316146f9d78993eb0fb50ee96fcb5d6e
7
+ data.tar.gz: cd6fc6df1e56709ddc7f75ab40e7c932f53070c7f4dbbab6ea00f9ae545f2d552f6d3e5f4617dc01cd16c648b3481e77eb9c1ee80947b3e017b736a11c2e255d
@@ -46,6 +46,10 @@ module Toolhound
46
46
 
47
47
  # Closes the current active session by expiring the ticket.
48
48
  #
49
+ def reconnect
50
+ sign_out
51
+ sign_in
52
+ end
49
53
  def sign_out
50
54
  @connection.close if @connection
51
55
  @connection = nil
@@ -38,11 +38,17 @@ module Toolhound
38
38
  # @connection ||= Toolhound.connection
39
39
  # end
40
40
  #
41
- def initialize(connection, options = {})
42
- @connection = connection
41
+ def initialize(client, options = {})
42
+ @client = client
43
43
  # @original = attrs
44
44
  # self.attributes = transform_attributes(attrs)
45
45
  end
46
+
47
+ def connection
48
+ @client.connection
49
+ end
50
+
51
+
46
52
  def table_name
47
53
  name = self.class.table_name || demodulize(self.class.name)
48
54
  formatted_table_name(name)
@@ -73,6 +73,12 @@ module Toolhound
73
73
  inspected
74
74
  end
75
75
 
76
+ def connection
77
+ if @connection && @connection.dead?
78
+ sign_in
79
+ end
80
+ @connection
81
+ end
76
82
 
77
83
 
78
84
  # Set username for authentication
@@ -96,36 +102,36 @@ module Toolhound
96
102
  end
97
103
 
98
104
  def inventory
99
- @inventory ||= Toolhound::Inventory.new(connection)
105
+ @inventory ||= Toolhound::Inventory.new(self)
100
106
  end
101
107
 
102
108
  def inventory_item
103
- @inventory_item ||= Toolhound::InventoryItem.new(connection)
109
+ @inventory_item ||= Toolhound::InventoryItem.new(self)
104
110
  end
105
111
 
106
112
  def project
107
- @project ||= Toolhound::Project.new(connection)
113
+ @project ||= Toolhound::Project.new(self)
108
114
  end
109
115
 
110
116
  def rental
111
- @rental ||= Toolhound::Rental.new(connection)
117
+ @rental ||= Toolhound::Rental.new(self)
112
118
  end
113
119
 
114
120
  def rental_item
115
- @rental_item ||= Toolhound::RentalItem.new(connection)
121
+ @rental_item ||= Toolhound::RentalItem.new(self)
116
122
  end
117
123
  def rental_charge
118
- @rental_charge ||= Toolhound::RentalCharge.new(connection)
124
+ @rental_charge ||= Toolhound::RentalCharge.new(self)
119
125
  end
120
126
 
121
127
  def vendor
122
- @vendor ||= Toolhound::Vendor.new(connection)
128
+ @vendor ||= Toolhound::Vendor.new(self)
123
129
  end
124
130
  def manufacturer
125
- @vendor ||= Toolhound::Manufacturer.new(connection)
131
+ @vendor ||= Toolhound::Manufacturer.new(self)
126
132
  end
127
133
  def purchase_order
128
- @vendor ||= Toolhound::PurchaseOrder.new(connection)
134
+ @vendor ||= Toolhound::PurchaseOrder.new(self)
129
135
  end
130
136
 
131
137
 
@@ -62,6 +62,10 @@ module Toolhound
62
62
  all(where: [{int_curr_location_id: entity_id}])
63
63
  end
64
64
 
65
+ def for_inventory(inventory_id)
66
+
67
+ end
68
+
65
69
  def charges_for_entity(entity_id)
66
70
  joins = default_joins
67
71
  joins << "INNER JOIN tblInventoryType ON tblInventoryType.intInventoryTypeID = tblInventoryItem.intInventoryTypeID AND tblInventoryType.bolSerialized = 1"
@@ -1,7 +1,6 @@
1
1
  module Toolhound
2
2
 
3
- # Class to parse GitHub repository owner and name from
4
- # URLs and to generate URLs
3
+ # A single charge for a rental item
5
4
  class RentalCharge < Base
6
5
 
7
6
 
@@ -28,11 +27,11 @@ module Toolhound
28
27
  arr
29
28
  end
30
29
 
31
- def find_by_entity_id(id)
32
- all(limit: 1, where: [{int_entity_id: id}]).first
33
- end
30
+ # def find_by_entity_id(id)
31
+ # all(limit: 1, where: [{int_entity_id: id}]).first
32
+ # end
34
33
 
35
- def find_first_and_last_charge_for_entity(id)
34
+ def find_first_and_last_charge_for_entity(entity_id)
36
35
  selects = {
37
36
  rental_charge: [
38
37
  {dte_start_date: {as: :max_date, agg: :max} },
@@ -40,14 +39,14 @@ module Toolhound
40
39
  ]
41
40
  }
42
41
 
43
- build_and_query(selects: selects, where: [{int_entity_id: id}])
42
+ build_and_query(selects: selects, where: [{int_entity_id: entity_id}])
44
43
  end
45
44
 
46
45
  def find_by_rental_id(id)
47
46
  all(where: [{"rental_detail.int_rental_id" => id}])
48
47
  end
49
48
 
50
- def for_entity_over_period(id, from, to)
49
+ def for_entity_over_period(entity_id, from, to)
51
50
  joins = []
52
51
  joins << "LEFT OUTER JOIN tblRentalItem ON tblRentalItem.intRentalItemID = tblRentalCharge.intRentalItemID"
53
52
  joins << "LEFT OUTER JOIN tblRentalDetail ON tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID"
@@ -57,7 +56,7 @@ module Toolhound
57
56
  joins << "INNER JOIN tblInventoryText ON tblInventory.intInventoryID = tblInventoryText.intInventoryID"
58
57
 
59
58
  wheres = [
60
- {"rental_charge.int_entity_id" => id},
59
+ {"rental_charge.int_entity_id" => entity_id},
61
60
  {"inventory.bol_deleted" => 0},
62
61
  {"inventory.bol_is_active" => 1},
63
62
  {"inventory_text.var_locale_id" => locale},
@@ -1,7 +1,6 @@
1
1
  module Toolhound
2
2
 
3
- # Class to parse GitHub repository owner and name from
4
- # URLs and to generate URLs
3
+
5
4
  class RentalItem < Base
6
5
 
7
6
 
@@ -1,3 +1,3 @@
1
1
  module Toolhound
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toolhound-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Klooth