routific 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2e7ffe5c2bb636a3ab3c1e594516b763d2e8197
4
- data.tar.gz: be71b166f79ade2947066ab085952980b04b5a5d
3
+ metadata.gz: 816c3c547394292568835be244e80f7e3042a2bf
4
+ data.tar.gz: 7699025ca637127d31938cf3f0737ff14a881ef7
5
5
  SHA512:
6
- metadata.gz: ef023e2e3aca0209ded96748d90bc1cc158f05d819a057ad16a4d71fde24c9a113e4ee084ab388c4bcdc51bec5f51553dde2d9a1bff7bdabc0b604fe68b62caa
7
- data.tar.gz: 007e6e6b7a0b5cbb8873aa25257835425f7ae0822d9afaa90a66f6cdac2f96341a9c0a3ccc366cddd57219c04a08029fbb3466059586623343ec55e455f50cd2
6
+ metadata.gz: ca55300f37e6c0659b33c89d6bd57eba44b2e80eefc668bad6f1c38bf8817d7ffa144d8f8b99c0598bbb2c61f0ef3699c61b9ebcaa4284cfcbda26b389a1ea88
7
+ data.tar.gz: fffe66b45b0f2f52b0c8882f328c7960c6637c5fb963f1d924ef902db9c539e0e4b6b3db2a4725d70407a65b4d8f2dffb044476b57041b3c53d64878cd24d1b7
data/README.md CHANGED
@@ -1,150 +1,169 @@
1
1
  Routific Ruby Gem
2
2
  =================
3
3
 
4
- This Ruby Gem assists users to easily access the [Routific API][1], which is a practical and scalable solution to the Vehicle Routing Problem.
5
-
6
- Logistics companies struggle with this challenge every day; most of them are still manually scheduling their fleet with a team of dispatchers.
7
-
8
- Routific can automate this process, and optimize it. The savings are tremendous: less fuel, and fewer vehicles, drivers and dispatchers.
4
+ [![Build Status](https://secure.travis-ci.org/asoesilo/routific-gem.png)](http://travis-ci.org/asoesilo/routific-gem)
9
5
 
10
- In the U.S., 1/8th of all fuel is consumed by trucks - that's 50 billion gallons a year. Our optimization algorithms will reduce that number by 20%!
6
+ This Ruby Gem assists users to easily access the [Routific API][1], which is a practical and scalable solution to the Vehicle Routing Problem.
11
7
 
12
- [1]: https://routific.com
8
+ [1]: https://routific.com/developers
13
9
 
14
10
  Installing
15
11
  ----------
16
12
 
17
- > gem install routific
13
+ `gem install routific`
18
14
 
19
15
  Usage
20
16
  -----
21
- Remember to require it before using it
17
+ Remember to require it and instantiate it with your token before using it
18
+
19
+ ```ruby
20
+ require 'routific'
21
+ routific = Routific.new(--API_KEY--)
22
+ ```
23
+
24
+ ### Instance methods
25
+
26
+ `routific.setLocation( id, params )`
27
+
28
+ Sets a location with the specified ID and parameters
29
+
30
+ Required arguments in params:
31
+
32
+ - lat: Latitude of this location
33
+ - lng: Longitude of this location
34
+
35
+ Optional arguments in params:
22
36
 
23
- > require 'routific'
37
+ - name: Name of this location
24
38
 
25
- The following instance methods are available:
39
+ `routific.setVisit( id, [params] )`
26
40
 
27
- - Sets a location with the specified ID and parameters
41
+ Sets a visit for the specified location using the specified parameters
28
42
 
29
- Required arguments in params:
30
-
31
- - lat: Latitude of this location
32
- - lng: Longitude of this location
43
+ Optional arguments in params:
33
44
 
34
- Optional arguments in params:
35
- - name: Name of this location
45
+ - start: the earliest time for this visit. Default value is 00:00, if not specified.
46
+ - end: the latest time for this visit. Default value is 23:59, if not specified.
47
+ - duration: the length of this visit in minutes
48
+ - demand: the capacity that this visit requires
36
49
 
37
- > routific.setLocation( id, params )
50
+ `routific.setVehicle( id, params )`
38
51
 
39
- - Sets a visit for the specified location using the specified parameters
52
+ Sets a vehicle with the specified ID and parameters
40
53
 
41
- Optional arguments in params:
42
- - start: the earliest time for this visit. Default value is 00:00, if not specified.
43
- - end: the latest time for this visit. Default value is 23:59, if not specified.
44
- - duration: the length of this visit in minutes
45
- - demand: the capacity that this visit requires
54
+ Required arguments in params:
46
55
 
47
- > routific.setVisit( id, [params] )
56
+ - start_location: ID of start location for this vehicle
48
57
 
49
- - Sets a vehicle with the specified ID and parameters
50
-
51
- Required arguments in params:
52
- - start_location: ID of start location for this vehicle
58
+ Optional arguments in params:
53
59
 
54
- Optional arguments in params:
55
- - end_location: ID of end location for this vehicle
56
- - shift_start: this vehicle's start shift time (e.g. '08:00'). Default value is 00:00, if not specified.
57
- - shift_end: this vehicle's end shift time (e.g. '17:00'). Default value is 23:59, if not specified.
58
- - capacity: the capacity that this vehicle can load
60
+ - end_location: ID of end location for this vehicle
61
+ - shift_start: this vehicle's start shift time (e.g. '08:00'). Default value is 00:00, if not specified.
62
+ - shift_end: this vehicle's end shift time (e.g. '17:00'). Default value is 23:59, if not specified.
63
+ - capacity: the capacity that this vehicle can load
59
64
 
60
- > routific.setVehicle( id, params )
65
+ `routific.getRoute()`
61
66
 
62
- - Returns the route using the previously provided network, visits and
63
- fleet information
64
- > routific.getRoute()
67
+ Returns the route using the previously provided network, visits and fleet information
65
68
 
66
- The following class methods are available:
67
69
 
68
- - Sets the default access token to use
69
- > Routific.setToken( token )
70
+ ### Class methods
70
71
 
71
- - Returns the route using the specified access token, network, visits and fleet information
72
- > Routific.getRoute( id, [params] )
72
+ `Routific.setToken( token )`
73
73
 
74
- Both getRoute functions return the Route object, which has the following methods:
74
+ Sets the default access token to use
75
+
76
+ `Routific.getRoute( id, [params] )`
77
+
78
+ Returns the route using the specified access token, network, visits and fleet information
79
+
80
+
81
+ Both getRoute functions return the Route object, which has the following attributes:
75
82
 
76
83
  - status: A sanity check, will always be success when the HTTP code is 200
77
84
  - fitness: Total travel-time, representing the fitness score of the solution (less is better)
78
- - unserved: List of visits that could not be scheduled.
85
+ - unserved: List of visits that could not be scheduled.
79
86
  - vehicleRoutes: The optimized schedule
80
87
 
81
88
  Examples
82
89
  --------
83
90
  Example 1:
84
91
 
85
- require 'routific'
86
-
87
- routific = Routific.new(--API_KEY--)
88
- routific.setLocation("order_1", {
89
- "name" => "6800 Cambie",
90
- "lat" => 49.227107,
91
- "lng" => -123.1163085,
92
- })
93
-
94
- routific.setLocation("depot", {
95
- "name" => "800 Kingsway",
96
- "lat" => 49.2553636,
97
- "lng" => -123.0873365,
98
- })
99
-
100
- routific.setVisit("order_1", {
101
- "start" => "9:00",
102
- "end" => "12:00",
103
- "duration" => 10,
104
- })
105
-
106
- routific.setVehicle("vehicle_1", {
107
- "start_location" => "depot",
108
- "end_location" => "depot",
109
- "shift_start" => "8:00",
110
- "shift_end" => "12:00",
111
- })
112
-
92
+ ```ruby
93
+ require 'routific'
94
+
95
+ routific = Routific.new(--API_KEY--)
96
+
97
+ routific.setLocation("order_1", {
98
+ "name" => "6800 Cambie",
99
+ "lat" => 49.227107,
100
+ "lng" => -123.1163085,
101
+ })
102
+
103
+ routific.setLocation("depot", {
104
+ "name" => "800 Kingsway",
105
+ "lat" => 49.2553636,
106
+ "lng" => -123.0873365,
107
+ })
108
+
109
+ routific.setVisit("order_1", {
110
+ "start" => "9:00",
111
+ "end" => "12:00",
112
+ "duration" => 10,
113
+ })
114
+
115
+ routific.setVehicle("vehicle_1", {
116
+ "start_location" => "depot",
117
+ "end_location" => "depot",
118
+ "shift_start" => "8:00",
119
+ "shift_end" => "12:00",
120
+ })
121
+
122
+ route = routific.getRoute()
123
+ ```
124
+
113
125
  Example 2:
114
126
 
115
- require 'routific'
116
-
117
- Routific.setToken(--API_KEY--)
118
- network = {
119
- "order_1" => {
120
- "name" => "6800 Cambie",
121
- "lat" => 49.227107,
122
- "lng" => -123.1163085
123
- },
124
- "depot" => {
125
- "name" => "800 Kingsway",
126
- "lat" => 49.2553636,
127
- "lng" => -123.0873365
128
- }
129
- }
130
- visits = {
131
- "order_1" => {
132
- "start" => "9:00",
133
- "end" => "12:00",
134
- "duration" => 10
135
- }
136
- }
137
- fleet = {
138
- "vehicle_1" => {
139
- "start-location" => "depot",
140
- "end-location" => "depot",
141
- "shift-start" => "8:00",
142
- "shift-end" => "12:00"
143
- }
144
- }
145
- @data = {
146
- network: network,
147
- visits: visits,
148
- fleet: fleet
149
- }
150
- Routific.getRoute(@data)
127
+ ```ruby
128
+ require 'routific'
129
+
130
+ Routific.setToken(--API_KEY--)
131
+
132
+ network = {
133
+ "order_1" => {
134
+ "name" => "6800 Cambie",
135
+ "lat" => 49.227107,
136
+ "lng" => -123.1163085
137
+ },
138
+ "depot" => {
139
+ "name" => "800 Kingsway",
140
+ "lat" => 49.2553636,
141
+ "lng" => -123.0873365
142
+ }
143
+ }
144
+
145
+ visits = {
146
+ "order_1" => {
147
+ "start" => "9:00",
148
+ "end" => "12:00",
149
+ "duration" => 10
150
+ }
151
+ }
152
+
153
+ fleet = {
154
+ "vehicle_1" => {
155
+ "start-location" => "depot",
156
+ "end-location" => "depot",
157
+ "shift-start" => "8:00",
158
+ "shift-end" => "12:00"
159
+ }
160
+ }
161
+
162
+ data = {
163
+ network: network,
164
+ visits: visits,
165
+ fleet: fleet
166
+ }
167
+
168
+ route = Routific.getRoute(data)
169
+ ```
@@ -19,14 +19,19 @@ class Location
19
19
  @name = params["name"]
20
20
  end
21
21
 
22
- # Returns the JSON representation of this object
23
22
  def to_json(options = nil)
23
+ as_json(options).to_json
24
+ end
25
+
26
+ # Returns the JSON representation of this object
27
+ # def to_json(options = nil)
28
+ def as_json(options = nil)
24
29
  jsonData = {}
25
30
  jsonData["name"] = self.name if self.name
26
31
  jsonData["lat"] = self.lat
27
32
  jsonData["lng"] = self.lng
28
33
 
29
- jsonData.to_json
34
+ jsonData
30
35
  end
31
36
 
32
37
  private
@@ -23,8 +23,13 @@ class Vehicle
23
23
  @capacity = params["capacity"]
24
24
  end
25
25
 
26
+ def to_json(options=nil)
27
+ as_json(options).to_json
28
+ end
29
+
26
30
  # Returns the JSON representation of this object
27
- def to_json(options = nil)
31
+ # def to_json(options = nil)
32
+ def as_json(options = nil)
28
33
  jsonData = {}
29
34
  jsonData["start-location"] = self.start_location
30
35
  jsonData["end-location"] = self.end_location if self.end_location
@@ -32,7 +37,7 @@ class Vehicle
32
37
  jsonData["shift-end"] = self.shift_end if self.shift_end
33
38
  jsonData["capacity"] = self.capacity if self.capacity
34
39
 
35
- jsonData.to_json
40
+ jsonData
36
41
  end
37
42
 
38
43
  private
@@ -16,14 +16,19 @@ class Visit
16
16
  @demand = params["demand"]
17
17
  end
18
18
 
19
+ def to_json(options)
20
+ as_json(options).to_json
21
+ end
22
+
19
23
  # Returns the JSON representation of this object
20
- def to_json(options = nil)
24
+ # def to_json(options = nil)
25
+ def as_json(options = nil)
21
26
  jsonData = {}
22
27
  jsonData["start"] = self.start if self.start
23
28
  jsonData["end"] = self.end if self.end
24
29
  jsonData["duration"] = self.duration if self.duration
25
30
  jsonData["demand"] = self.demand if self.demand
26
31
 
27
- jsonData.to_json
32
+ jsonData
28
33
  end
29
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: routific
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Kuo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-23 00:00:00.000000000 Z
12
+ date: 2014-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client