orochi 0.0.0 → 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.
data/README.textile CHANGED
@@ -1,5 +1,7 @@
1
1
  h1. orochi
2
2
 
3
+ p. A ruby gem that helps ActiveRecord-ize directions and route data.
4
+
3
5
  h2. setup
4
6
 
5
7
  pre. sudo gem install orochi
@@ -7,12 +9,18 @@ rake orochi:awaken
7
9
 
8
10
  h2. usage
9
11
 
12
+ p. Orochi needs to know which models you intend to make routeable. So any model that has a start and stop destination can be represented as:
13
+
10
14
  pre. class YourModel < ActiveRecord::Base
11
15
  acts_as_routeable
12
16
  end
13
17
 
18
+ p. Orochi still isn't quite smart enough to make the association on its own, so for the time being you will have to generate a migration:
19
+
14
20
  pre. rails generate migration add_router_id_to_your_model
15
21
 
22
+ p. add in the necessary columns:
23
+
16
24
  pre. class AddRouterIdToYourModel < ActiveRecord::Migration
17
25
  self.up
18
26
  add_column :your_models, :router_id, :integer, :references => :routers
@@ -22,6 +30,12 @@ pre. class AddRouterIdToYourModel < ActiveRecord::Migration
22
30
  end
23
31
  end
24
32
 
33
+ p. then run the migration:
34
+
35
+ pre. db:migrate
36
+
37
+ p. Now you're set up and ready to go!
38
+
25
39
  h2. ghetto usage
26
40
 
27
41
  pre. your_model_instance.router.start = "a_start_address"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.2
@@ -1,4 +1,4 @@
1
- class OdinMigration < ActiveRecord::Migration
1
+ class OrochiMigration < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :routers do |t|
4
4
  t.string :start
@@ -1,3 +1,11 @@
1
1
  class Route < ActiveRecord::Base
2
2
  has_many :legs
3
+
4
+ def each_step(&block)
5
+ self.legs.each do |leg|
6
+ leg.steps.each do |step|
7
+ yield step
8
+ end
9
+ end
10
+ end
3
11
  end
@@ -68,6 +68,25 @@ module Orochi
68
68
  def routes
69
69
  self.router.routes
70
70
  end
71
+
72
+ def set_endpoints!(start, stop)
73
+ self.router.start = start
74
+ self.router.stop = stop
75
+ self.router.save!
76
+ end
77
+
78
+ def polyline
79
+ routes.first.each_step do |step|
80
+ puts step.polyline_json
81
+ puts
82
+ end
83
+ end
84
+
85
+ def directions_to
86
+ end
87
+
88
+ def directions_from
89
+ end
71
90
  end
72
91
  end
73
92
  end
data/orochi.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{orochi}
8
- s.version = "0.0.0"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kellydunn"]
@@ -38,8 +38,8 @@ Gem::Specification.new do |s|
38
38
  "lib/orochi/railtie.rb",
39
39
  "lib/rails_templates/default_template.rb",
40
40
  "orochi.gemspec",
41
+ "spec/gem/acts_as_routeable_spec.rb",
41
42
  "spec/helpers/core.rb",
42
- "spec/odin_spec.rb",
43
43
  "spec/rake/migration_spec.rb",
44
44
  "spec/rake/rake_spec.rb",
45
45
  "spec/spec_helper.rb"
@@ -50,8 +50,8 @@ Gem::Specification.new do |s|
50
50
  s.rubygems_version = %q{1.3.7}
51
51
  s.summary = %q{An easy way to ActiveRecord-ize directions and route data}
52
52
  s.test_files = [
53
+ "spec/gem/acts_as_routeable_spec.rb",
53
54
  "spec/helpers/core.rb",
54
- "spec/odin_spec.rb",
55
55
  "spec/rake/migration_spec.rb",
56
56
  "spec/rake/rake_spec.rb",
57
57
  "spec/spec_helper.rb"
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe "A model acting as routeable" do
4
+ create_rails_app
5
+
6
+ context "setting endpoints" do
7
+ it "should be able to set its stopping and starting endpoints"
8
+ it "should not be able to route if no endpoints are set"
9
+ it "should be able to route after endpoints are set"
10
+ end
11
+
12
+ context "routing" do
13
+ it "should have a route that correctly reflects the endpoints"
14
+ it "should be able to grab a polyline after being routed"
15
+ end
16
+
17
+ destroy_rails_app
18
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orochi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 0
10
- version: 0.0.0
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - kellydunn
@@ -167,8 +167,8 @@ files:
167
167
  - lib/orochi/railtie.rb
168
168
  - lib/rails_templates/default_template.rb
169
169
  - orochi.gemspec
170
+ - spec/gem/acts_as_routeable_spec.rb
170
171
  - spec/helpers/core.rb
171
- - spec/odin_spec.rb
172
172
  - spec/rake/migration_spec.rb
173
173
  - spec/rake/rake_spec.rb
174
174
  - spec/spec_helper.rb
@@ -207,8 +207,8 @@ signing_key:
207
207
  specification_version: 3
208
208
  summary: An easy way to ActiveRecord-ize directions and route data
209
209
  test_files:
210
+ - spec/gem/acts_as_routeable_spec.rb
210
211
  - spec/helpers/core.rb
211
- - spec/odin_spec.rb
212
212
  - spec/rake/migration_spec.rb
213
213
  - spec/rake/rake_spec.rb
214
214
  - spec/spec_helper.rb
data/spec/odin_spec.rb DELETED
@@ -1,4 +0,0 @@
1
- 'spec_helper'
2
-
3
- describe "Odin" do
4
- end