artisan 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.2-p290@artisan_gem
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+
9
+ gem "httparty", "~> 0.7.3"
10
+
11
+ group :development do
12
+ gem "shoulda", ">= 0"
13
+ gem "bundler", "~> 1.0.0"
14
+ gem "jeweler", "~> 1.6.4"
15
+ gem "rcov", ">= 0"
16
+ end
@@ -0,0 +1,24 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ crack (0.1.8)
5
+ git (1.2.5)
6
+ httparty (0.7.8)
7
+ crack (= 0.1.8)
8
+ jeweler (1.6.4)
9
+ bundler (~> 1.0)
10
+ git (>= 1.2.5)
11
+ rake
12
+ rake (0.9.2)
13
+ rcov (0.9.9)
14
+ shoulda (2.11.3)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ bundler (~> 1.0.0)
21
+ httparty (~> 0.7.3)
22
+ jeweler (~> 1.6.4)
23
+ rcov
24
+ shoulda
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 patrickgombert
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = artisan
2
+
3
+ Communicate with artisan.8thlight.com's API. API keys are automatically issued per project on Artisan.
4
+
5
+ == Contributing to artisan
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Patrick Gombert. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "artisan"
18
+ gem.homepage = "http://github.com/patrickgombert/artisan"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Artisan API wrapper}
21
+ gem.description = %Q{Make calls to the Artisan API.}
22
+ gem.email = "patrickgombert@gmail.com"
23
+ gem.authors = ["patrickgombert"]
24
+ gem.add_dependency "httparty", "~> 0.7.8"
25
+ gem.add_development_dependency "thoughtbot-shoulda", ">=0"
26
+ # dependencies defined in Gemfile
27
+ end
28
+ Jeweler::RubygemsDotOrgTasks.new
29
+
30
+ require 'rake/testtask'
31
+ Rake::TestTask.new(:test) do |test|
32
+ test.libs << 'lib' << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ end
36
+
37
+ require 'rcov/rcovtask'
38
+ Rcov::RcovTask.new do |test|
39
+ test.libs << 'test'
40
+ test.pattern = 'test/**/test_*.rb'
41
+ test.verbose = true
42
+ test.rcov_opts << '--exclude "gems/*"'
43
+ end
44
+
45
+ task :default => :test
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "artisan #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,16 @@
1
+ require 'artisan/story'
2
+ require 'artisan/project'
3
+ require 'artisan/query'
4
+ require 'json'
5
+
6
+ module Artisan
7
+ def self.get_project key
8
+ response = Query.get_project key
9
+ json_chunk = JSON::parse(response)
10
+ return Project.new(json_chunk)
11
+ end
12
+
13
+ def self.update_estimates(key, story)
14
+ response = Query.update_estimates(key, story)
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ class Project
2
+
3
+ attr_reader :stories
4
+
5
+ def initialize json_chunk
6
+ story_json_chunks = json_chunk.collect{|story| story["story"]}
7
+ @stories = []
8
+ generate_stories story_json_chunks
9
+ end
10
+
11
+ def generate_stories story_chunks
12
+ story_chunks.each do |story|
13
+ @stories << Story.new(story)
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,23 @@
1
+ require 'httparty'
2
+
3
+ module Artisan
4
+ module Query
5
+ def self.get_project key
6
+ response = HTTParty.get 'http://artisan.8thlight.com/api/projects', :key => key, :accept => :json
7
+ Query.raise_not_okay_exception response.code
8
+ return response.body
9
+ end
10
+
11
+ def self.update_estimates(key, story)
12
+ return HTTParty.put 'http://artisan.8thlight.com/api/projects/stories/' + story.number + '/estimates', :key => key, :accept => :json, :optimistic => story.optimistic, :realistic => story.realistic, :pessimistic => story.pessimistic
13
+ Query.raise_not_okay_exception response.code
14
+ return response
15
+ end
16
+
17
+ def self.raise_not_okay_exception response_code
18
+ if !response_code == 200
19
+ raise 'Server response not 200'
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ class Story
2
+
3
+ attr_accessor :name, :number, :optimistic, :realistic, :pessimistic
4
+
5
+ def initialize json_chunk
6
+ @name = json_chunk["name"]
7
+ @number = json_chunk["number"]
8
+ @optimistic = json_chunk["optimistic"]
9
+ @realistic = json_chunk["realistic"]
10
+ @pessimistic = json_chunk["pessimistic"]
11
+ end
12
+
13
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ describe 'Project' do
5
+ it "intializes with an api call json chunk" do
6
+ chunk = '[{"story":{"name":"T1","number":1,"optimistic":null,"pessimistic":null,"realistic":null}},{"story":{"name":"T2","number":2,"optimistic":null,"pessimistic":null,"realistic":null}},{"story":{"name":"T3","number":3,"optimistic":null,"pessimistic":null,"realistic":null}}]'
7
+
8
+ project = Project.new(JSON::parse(chunk))
9
+ project.stories.size.should == 3
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Story do
4
+
5
+ it "initializes with an api call json chunk" do
6
+ chunk = {'name' => "Test", 'number' => 1, 'optimistic' => nil, 'realistic' => nil, 'pessimistic' => nil}
7
+ story = Story.new(chunk)
8
+ story.name.should == "Test"
9
+ story.optimistic.should be_nil
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ $: << File.join(File.expand_path(File.dirname(__FILE__)), "..", "lib")
2
+ require 'artisan'
3
+ require 'artisan/story'
4
+ require 'artisan/project'
5
+ require 'artisan/query'
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: artisan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - patrickgombert
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-05 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: &20241760 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.7.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *20241760
25
+ - !ruby/object:Gem::Dependency
26
+ name: shoulda
27
+ requirement: &20240160 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *20240160
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &20238480 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *20238480
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &20237060 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.4
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *20237060
58
+ - !ruby/object:Gem::Dependency
59
+ name: rcov
60
+ requirement: &20235240 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *20235240
69
+ - !ruby/object:Gem::Dependency
70
+ name: httparty
71
+ requirement: &20058760 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 0.7.8
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *20058760
80
+ - !ruby/object:Gem::Dependency
81
+ name: thoughtbot-shoulda
82
+ requirement: &20057860 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *20057860
91
+ description: Make calls to the Artisan API.
92
+ email: patrickgombert@gmail.com
93
+ executables: []
94
+ extensions: []
95
+ extra_rdoc_files:
96
+ - LICENSE.txt
97
+ - README.rdoc
98
+ files:
99
+ - .document
100
+ - .rvmrc
101
+ - Gemfile
102
+ - Gemfile.lock
103
+ - LICENSE.txt
104
+ - README.rdoc
105
+ - Rakefile
106
+ - VERSION
107
+ - lib/artisan.rb
108
+ - lib/artisan/project.rb
109
+ - lib/artisan/query.rb
110
+ - lib/artisan/story.rb
111
+ - spec/artisan/project_spec.rb
112
+ - spec/artisan/story_spec.rb
113
+ - spec/spec_helper.rb
114
+ homepage: http://github.com/patrickgombert/artisan
115
+ licenses:
116
+ - MIT
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ segments:
128
+ - 0
129
+ hash: 590979130552460352
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 1.8.6
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: Artisan API wrapper
142
+ test_files: []