eisenhower 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .DS_Store
2
+ pkg/
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2@eisenhower
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in eisenhower.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ eisenhower (0.0.1)
5
+ httparty (~> 0.7.4)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ crack (0.1.8)
11
+ httparty (0.7.4)
12
+ crack (= 0.1.8)
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ eisenhower!
19
+ httparty (~> 0.7.4)
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ desc "Open an irb session preloaded with this library"
5
+ task :console do
6
+ sh "irb -rubygems -I lib -r eisenhower.rb"
7
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "eisenhower/version"
4
+ require 'rubygems'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "eisenhower"
8
+ s.version = Eisenhower::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["micah rich"]
11
+ s.email = ["micah@micahrich.com"]
12
+ s.homepage = "http://micahrich.com/eisenhower"
13
+ s.summary = %q{A ruby wrapper for the Interstate API.}
14
+ s.description = %q{A ruby wrapper for the Interstate API. It's still unfinished, a bit slow, and read-only.}
15
+
16
+ s.rubyforge_project = "eisenhower"
17
+ s.required_rubygems_version = ">= 1.3.6"
18
+
19
+ s.add_dependency("httparty", "~> 0.7.4")
20
+
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
+ s.require_paths = ["lib"]
26
+ end
data/lib/eisenhower.rb ADDED
@@ -0,0 +1,26 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'httparty'
4
+
5
+ require 'eisenhower/version'
6
+ require 'eisenhower/client'
7
+ require 'eisenhower/roadmap'
8
+ require 'eisenhower/road'
9
+ require 'eisenhower/road_update'
10
+ require 'eisenhower/staff'
11
+
12
+ module Eisenhower
13
+ class APIError < RuntimeError; end
14
+ class << self
15
+ attr_accessor :oauth_token
16
+
17
+ def version
18
+ VERSION
19
+ end
20
+
21
+ def history
22
+ "The Dwight D. Eisenhower National System of Interstate and Defense Highways, commonly called the Interstate Highway System or Interstate Freeway System, and colloquially abbreviated 'the Interstate', is a network of limited-access roadways (also called freeways or expressways) in the United States. It is named for President Dwight D. Eisenhower, who championed its formation."
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,22 @@
1
+ module Eisenhower
2
+ class Client
3
+ attr_accessor :oauth_token
4
+
5
+ include HTTParty
6
+ base_uri "https://api.interstateapp.com/v#{API_VERSION}"
7
+ format :json
8
+
9
+ def self.fetch(path, options={})
10
+ options.merge!({:default_params => {:oauth_token=> Eisenhower.oauth_token}})
11
+ get(path, options)
12
+ end
13
+
14
+ def self.get_and_parse(path, options={})
15
+ getter = fetch(path, options)
16
+ return Crack::JSON.parse(getter.body)["response"]
17
+ end
18
+
19
+
20
+
21
+ end
22
+ end
@@ -0,0 +1,46 @@
1
+ module Eisenhower
2
+ class Road
3
+ attr_accessor :id, :title, :description, :description_html, :collapsed, :started, :status, :due, :position, :updates_count, :update_ids, :staff_ids
4
+ alias :name :title
5
+ BOOLEANS = %w(collapsed due)
6
+
7
+ def initialize(attributes={})
8
+ attributes.each { |key, val| send("#{key}=", val) if respond_to?("#{key}=") }
9
+ end
10
+
11
+ BOOLEANS.each do |boolean|
12
+ define_method("#{boolean}?") do
13
+ self.instance_variable_get("@#{boolean}")
14
+ end
15
+ end
16
+
17
+ def updates
18
+ self.update_ids.collect{|id| Eisenhower::RoadUpdate.find(id)}
19
+ end
20
+
21
+ def staff
22
+ self.staff_ids.collect{|id| Eisenhower::Staff.find(id)}
23
+ end
24
+
25
+
26
+ class << self
27
+ def find(road_id)
28
+ body = Eisenhower::Client.get_and_parse("/road/get/id/#{road_id}")
29
+ Eisenhower::Road.new({
30
+ :id => body["_id"],
31
+ :title => body["title"],
32
+ :description => body["description"],
33
+ :description_html => body["descriptionHtml"],
34
+ :collapsed => body["collapsed"],
35
+ :status => body["status"]["status"],
36
+ :due => body["due"] ? body["due"]["dmy"] : false,
37
+ :started => body["start"] ? body["start"]["dmy"] : false,
38
+ :position => body["order"]["position"],
39
+ :updates_count => body["updatesCount"],
40
+ :update_ids => body["updates"].collect{|up| up["_id"]},
41
+ :staff_ids => body["staffList"]
42
+ })
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,52 @@
1
+ module Eisenhower
2
+ class RoadUpdate
3
+ attr_accessor :id, :road_id, :staff_id, :time, :update, :road_map_id, :app_id, :staff
4
+ alias :user :staff
5
+ alias :owner :staff
6
+
7
+ def initialize(attributes={})
8
+ attributes.each { |key, val| send("#{key}=", val) if respond_to?("#{key}=") }
9
+ end
10
+
11
+ def staff
12
+ Eisenhower::Staff.find(self.staff_id)
13
+ end
14
+
15
+ class << self
16
+
17
+ def all(options={})
18
+ roadmap_id=nil, app_id=nil, limit=3, skip=0
19
+ options = {
20
+ :roadmap_id => nil,
21
+ :app_id => nil,
22
+ :limit => 3,
23
+ :skip => 0
24
+ }.merge(options)
25
+
26
+ body = Eisenhower::Client.get_and_parse("/update/listAll/roadmap/#{options[:roadmap_id]}/app/#{options[:app_id]}/limit/#{options[:limit]}/skip/#{options[:skip]}")
27
+ body["updates"].collect{|update|
28
+ Eisenhower::RoadUpdate.new({
29
+ :id => update["_id"],
30
+ :road_id => update["roadId"],
31
+ :staff_id => update["staffId"],
32
+ :time => update["time"],
33
+ :update => update["update"]
34
+ })}
35
+ end
36
+
37
+ def find(road_update_id)
38
+ body = Eisenhower::Client.get_and_parse("/update/get/id/#{road_update_id}")
39
+ Eisenhower::RoadUpdate.new({
40
+ :id => body["_id"],
41
+ :road_id => body["roadId"],
42
+ :staff_id => body["staffId"],
43
+ :time => body["time"],
44
+ :update => body["update"]
45
+ })
46
+ end
47
+
48
+ end
49
+
50
+
51
+ end
52
+ end
@@ -0,0 +1,68 @@
1
+ module Eisenhower
2
+ class Roadmap
3
+ attr_accessor :id, :app_id, :archived, :public, :title, :time, :staff_ids
4
+ alias :name :title
5
+ BOOLEANS = %w(archived public)
6
+
7
+ def initialize(attributes={})
8
+ attributes.each { |key, val| send("#{key}=", val) if respond_to?("#{key}=") }
9
+ end
10
+
11
+ BOOLEANS.each do |boolean|
12
+ define_method("#{boolean}?") do
13
+ self.instance_variable_get("@#{boolean}")
14
+ end
15
+ end
16
+
17
+ def staff
18
+ self.staff_ids.collect{|id| Eisenhower::Staff.find(id) }
19
+ end
20
+
21
+ def roads
22
+ response = Eisenhower::Client.fetch("/roadmap/roads/id/#{self.id}")
23
+ body = Crack::JSON.parse(response.body)["response"]
24
+ body.collect{|road| Eisenhower::Road.new({
25
+ :id => road["_id"],
26
+ :title => road["title"],
27
+ :description => road["description"],
28
+ :description_html => road["descriptionHtml"],
29
+ :collapsed => road["collapsed"],
30
+ :status => road["status"]["status"],
31
+ :due => road["due"] ? road["due"]["dmy"] : false,
32
+ :started => road["start"] ? road["start"]["dmy"] : false,
33
+ :position => road["order"]["position"],
34
+ :updates_count => road["updatesCount"],
35
+ :update_ids => road["updates"].collect{|up| up["_id"]},
36
+ :staff_ids => road["staffList"]
37
+ })}
38
+ end
39
+
40
+ class << self
41
+ def all
42
+ return body = Eisenhower::Client.get_and_parse('/roadmap/listAll')
43
+ #body.collect{|roadmap| Eisenhower::Roadmap.new({
44
+ # :id => roadmap.last.last["_id"],
45
+ # :app_id => roadmap.last.last["appId"],
46
+ # :archived => roadmap.last.last["archived"],
47
+ # :public => roadmap.last.last["public"],
48
+ # :title => roadmap.last.last["title"],
49
+ # :time => roadmap.last.last["time"],
50
+ # :staff_ids => roadmap.last.last["staff"].collect{|staff| staff["_id"]}
51
+ # }
52
+ #)}
53
+ end
54
+
55
+ def find(app_id)
56
+ body = Eisenhower::Client.get_and_parse("/roadmap/get/id/#{app_id}")
57
+ Eisenhower::Roadmap.new({
58
+ :id => body["_id"],
59
+ :app_id => body["appId"],
60
+ :archived => body["archived"],
61
+ :public => body["public"],
62
+ :title => body["title"],
63
+ :staff_ids => body["staff"].collect{|staff| staff["_id"]}
64
+ })
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,26 @@
1
+ module Eisenhower
2
+ class Staff
3
+ attr_accessor :id, :full_name, :email, :admin
4
+ alias :name :full_name
5
+
6
+ def initialize(attributes={})
7
+ attributes.each { |key, val| send("#{key}=", val) if respond_to?("#{key}=") }
8
+ end
9
+
10
+ def admin?
11
+ @admin
12
+ end
13
+
14
+ class << self
15
+ def find(staff_id)
16
+ body = Eisenhower::Client.get_and_parse("/staff/get/id/#{staff_id}")
17
+ Eisenhower::Staff.new({
18
+ :id => body["_id"],
19
+ :full_name => body["fullName"],
20
+ :email => body["email"],
21
+ :admin => body["admin"]
22
+ })
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ module Eisenhower
2
+ VERSION = "0.0.3"
3
+ API_VERSION = 1
4
+ end
data/readme.markdown ADDED
@@ -0,0 +1,90 @@
1
+ <img src="https://github.com/micahbrich/eisenhower/raw/gh-pages/public/images/portrait-header.jpg" alt="Eisenhower">
2
+
3
+ Eisenhower is a work-in-progress read-only rubygem to help you work the
4
+ [Interstate API](http://developers.interstateapp.com).
5
+
6
+ Install
7
+ -------
8
+
9
+ gem install 'eisenhower'
10
+
11
+ Usage
12
+ ----
13
+
14
+ First thing to do is set an OAuth token – how you get this, at the moment, is up to you.
15
+
16
+ Eisenhower.oauth_token = "432n4u3h24v23"
17
+
18
+ Now you can get all your roadmaps!
19
+
20
+ Eisenhower::Roadmap.all
21
+
22
+ You’ll get back interconnected **Eisenhower** objects whenever possible. Try this to get all the roads on a specific roadmap:
23
+
24
+ map = Eisenhower::Roadmap.all.first
25
+ map = Eisenhower::Roadmap.find("234f23f23fc2fg")
26
+
27
+ #<Eisenhower::Roadmap:0x00000100964028
28
+ @id="4d86bd5a36c040e22c000285",
29
+ @app_id="4d86bd5a36c040e22c000283",
30
+ @archived=false,
31
+ @public=nil,
32
+ @title="Your first roadmap",
33
+ @staff_ids=["4d86bd5a36c040e22c000284", "4d90e61336c040672d00035e"]>
34
+
35
+ map.roads
36
+
37
+ [#<Eisenhower::Road:0x000001009156d0
38
+ @id="4d86bd5a36c040e22c000287",
39
+ @title="This is a road",
40
+ @description="A road is usually the name of a feature that you're building. Etc, etc.",
41
+ @description_html="<p>A road is usually the name of a feature that you're building. Etc, etc.</p>",
42
+ @collapsed=false,
43
+ @status="Launched",
44
+ @due=false,
45
+ @started=false,
46
+ @position=0,
47
+ @updates_count=0,
48
+ @update_ids=[],
49
+ @staff_ids=["4d86bd5a36c040e22c000284"]>]
50
+
51
+ map.roads.first.title
52
+
53
+ "This is a road"
54
+
55
+ map.roads.first.staff
56
+
57
+ [#<Eisenhower::Staff:0x000001019d9548
58
+ @id="4d86bd5a36c040e22c000284",
59
+ @full_name="Micah Rich",
60
+ @email=nil,
61
+ @admin=true>]
62
+
63
+ And so on.
64
+
65
+
66
+ Double check the code, but most attributes are from Interstate's documentation:
67
+
68
+ 1. [Roadmaps](http://developers.interstateapp.com/roadmap/get)
69
+ 2. [Roads](http://developers.interstateapp.com/road/get)
70
+ 3. [Road Updates](http://developers.interstateapp.com/update/get)
71
+ 4. [Staff](http://developers.interstateapp.com/staff/get)
72
+
73
+
74
+ To Do
75
+ -----
76
+
77
+ There’s much left to do, so please feel free
78
+ to fork it & help out.
79
+
80
+ - **Refactor** - There are too many API calls, which makes getting simple information slow. API calls inside API calls gets ugly, and there’s a lot of information that could be instantiated without an extra call.
81
+
82
+ - **Tests** - I'm a designer, and am subsequently despicable at writing tests. Please help.
83
+
84
+ - **Implement newer API objects** - There are now at least two more objects (File & Activity) that I haven’t touched yet.
85
+
86
+ - **Writing as well as Reading** - The only reason Eisenhower is read-only is because that’s all I’ve found time to do so far. Help here would be swell.
87
+
88
+ - - -
89
+
90
+ Perhaps together, we can get it up to version one.
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eisenhower
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.3
6
+ platform: ruby
7
+ authors:
8
+ - micah rich
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-27 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httparty
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 0.7.4
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ description: A ruby wrapper for the Interstate API. It's still unfinished, a bit slow, and read-only.
27
+ email:
28
+ - micah@micahrich.com
29
+ executables: []
30
+
31
+ extensions: []
32
+
33
+ extra_rdoc_files: []
34
+
35
+ files:
36
+ - .gitignore
37
+ - .rvmrc
38
+ - Gemfile
39
+ - Gemfile.lock
40
+ - Rakefile
41
+ - eisenhower.gemspec
42
+ - lib/eisenhower.rb
43
+ - lib/eisenhower/client.rb
44
+ - lib/eisenhower/road.rb
45
+ - lib/eisenhower/road_update.rb
46
+ - lib/eisenhower/roadmap.rb
47
+ - lib/eisenhower/staff.rb
48
+ - lib/eisenhower/version.rb
49
+ - readme.markdown
50
+ homepage: http://micahrich.com/eisenhower
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.3.6
70
+ requirements: []
71
+
72
+ rubyforge_project: eisenhower
73
+ rubygems_version: 1.8.4
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: A ruby wrapper for the Interstate API.
77
+ test_files: []
78
+