liquidplanner 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ begin
14
14
  gemspec.description = "LiquidPlanner API client, using ActiveResource"
15
15
  gemspec.email = "api@liquidplanner.com"
16
16
  gemspec.homepage = "http://github.com/liquidplanner/liquidplanner"
17
- gemspec.authors = ["Brett Bender", "Adam Sanderson"]
17
+ gemspec.authors = ["Brett Bender", "Adam Sanderson", "Mark Holton"]
18
18
 
19
19
  gemspec.files = FileList["[A-Z]*", "{examples,lib,test}/**/*"]
20
20
 
data/examples/README CHANGED
@@ -1,7 +1,7 @@
1
1
  Command Line Examples:
2
2
  ======================
3
3
 
4
- Files: create_task.rb, list_tasks.rb, track_time.rb
4
+ Files: create_task.rb, list_tasks.rb, track_time.rb, list_custom_fields.rb, update_custom_field_value.rb
5
5
 
6
6
  All of these examples expect you to pass in your account name and workspace id,
7
7
  for instance:
@@ -0,0 +1,45 @@
1
+ # Require the LiquidPlanner API.
2
+ require File.dirname(__FILE__) + '/../lib/liquidplanner'
3
+
4
+ # Require support libraries used by this example.
5
+ require 'rubygems'
6
+ require 'highline/import'
7
+ require 'active_support/all'
8
+ require File.dirname(__FILE__) + '/support/helper'
9
+
10
+ # List a set of custom fields and custom field values in a workspace.
11
+ #
12
+ # You will:
13
+ # * Access a workspace
14
+ # * display the custom Project and custom Task fields in that workspace
15
+ #
16
+ # This example will use the highline library to handle input and output.
17
+ # You can install it with:
18
+ # gem install highline
19
+
20
+ email, password, space_id = get_credentials!
21
+
22
+ # Create a new LiquidPlanner API object. It requires the login credentials we gathered above.
23
+ lp = LiquidPlanner::Base.new(:email=>email, :password=>password)
24
+
25
+ # Fetch the user's workspace, and then print its name.
26
+ workspace = lp.workspaces(space_id)
27
+ say "#{workspace.name}: Custom Fields and Custom Field Values:"
28
+ say "-" * 40
29
+
30
+ # Fetch custom fields for that workspace
31
+ custom_fields = workspace.custom_fields(:all)
32
+
33
+ # print the custom fields and custom field values
34
+ custom_fields.each do |cf|
35
+ # LiquidPlanner::Resources::CustomField
36
+ # LiquidPlanner::Resources::CustomField::Value
37
+
38
+ # show the name, type, and value choices for the CustomField:
39
+ say "category: #{cf.category}" if cf.category
40
+ say "name: #{cf.name} (id:#{cf.id})" if cf.name
41
+ cf.values.each do |cfv| # custom_field_values
42
+ say "label: #{cfv.label} (type: #{cfv.type} sort_order: #{cfv.sort_order} id: #{cfv.id})"
43
+ end
44
+ say "-" * 40
45
+ end
@@ -0,0 +1,63 @@
1
+ # Require the LiquidPlanner API.
2
+ require File.dirname(__FILE__) + '/../lib/liquidplanner'
3
+
4
+ # Require support libraries used by this example.
5
+ require 'rubygems'
6
+ require 'highline/import'
7
+ require File.dirname(__FILE__) + '/support/helper'
8
+
9
+ require 'pp'
10
+ # Get the user's credentials
11
+ email, password, space_id = get_credentials!
12
+
13
+ # Create a new LiquidPlanner API object with the login credentials
14
+ lp = LiquidPlanner::Base.new(:email=>email, :password=>password)
15
+
16
+ # Get the user's workspace and account, and then print its name.
17
+ workspace = lp.workspaces(space_id)
18
+ account = lp.account
19
+
20
+ say "-" * 40
21
+ # Get the user's first task
22
+ tasks = workspace.tasks(:all, :filter=>'owner_id = me')
23
+ projects = workspace.projects(:all, :filter=>'owner_id = me')
24
+
25
+ custom_task_fields = workspace.custom_fields(:all).select{|item| item.category == "task"}
26
+ custom_project_fields = workspace.custom_fields(:all).select{|item| item.category == "project"}
27
+
28
+ if tasks.empty? && projects.empty?
29
+ say "No tasks or projects are assigned to you."
30
+ exit
31
+ else
32
+ task = tasks.first
33
+ project = projects.first
34
+ end
35
+
36
+ say "Workspace: #{workspace.name} - Set a Custom Field Value on the first Task, Milestone, or Event in your space"
37
+ say "#{task.type}: #{task.name}"
38
+ say "* available Custom Task Fields:"
39
+
40
+ # allows you to set all custom fields available on this task
41
+ custom_task_fields.each do |cf|
42
+ say "#{cf.name}"
43
+ cf.values.each do |cfv| # options to choose from
44
+ say "#{cfv.label}"
45
+ end
46
+ cf_value = ask("Type in the Custom Field Value you wish to set on '#{task.name}'?", String)
47
+ puts "chose: #{cf_value}"
48
+ # HTTP PUT "'{'task':{'custom_field_values':{'your_task_field':'your_task_field_value'}}}'"
49
+ task.custom_field_values = {cf.name => cf_value}
50
+ task.save
51
+ end
52
+
53
+ # allows you to set all custom fields available on this task
54
+ custom_project_fields.each do |cf|
55
+ say "#{cf.name}"
56
+ cf.values.each do |cfv| # options to choose from
57
+ say "#{cfv.label}"
58
+ end
59
+ cf_value = ask("Type in the Custom Field Value you wish to set on '#{task.name}'?", String)
60
+ puts "chose: #{cf_value}"
61
+ project.custom_field_values = {cf.name => cf_value}
62
+ project.save
63
+ end
data/lib/liquidplanner.rb CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module LiquidPlanner
5
- VERSION = "0.0.3"
5
+ VERSION = "0.0.4"
6
6
  API_BASE_URL = "https://app.liquidplanner.com/api"
7
7
  end
8
8
 
@@ -16,6 +16,8 @@ require "net/http/post/multipart" # for uploading documents
16
16
  # could also glob these paths and require all matches...
17
17
  require "liquidplanner/base"
18
18
  require "liquidplanner/liquidplanner_resource"
19
+ require "liquidplanner/resources/workspace_resource"
20
+
19
21
  require "liquidplanner/resources/account"
20
22
  require "liquidplanner/resources/member"
21
23
  require "liquidplanner/resources/workspace"
@@ -44,6 +46,7 @@ require "liquidplanner/resources/link"
44
46
  require "liquidplanner/resources/estimate"
45
47
  require "liquidplanner/resources/snapshot"
46
48
  require "liquidplanner/resources/activity"
49
+ require "liquidplanner/resources/custom_field"
47
50
 
48
51
  require "liquidplanner/ext/hash"
49
52
  require "liquidplanner/ext/connection"
@@ -31,6 +31,7 @@ module LiquidPlanner
31
31
  LiquidPlannerResource.site = @api_base_url
32
32
  LiquidPlannerResource.user = @email
33
33
  LiquidPlannerResource.password = @password
34
+ LiquidPlannerResource.connection.enable_gzip
34
35
  end
35
36
 
36
37
  end
@@ -7,5 +7,24 @@ module ActiveResource
7
7
  with_auth { request(:get, path, build_request_headers(headers, :get, self.site.merge(path))) }
8
8
  end
9
9
 
10
+ # force accept-encoding request header to "gzip"
11
+ # so that server compresses its response
12
+ #
13
+ def enable_gzip
14
+ default_header['accept-encoding'] = 'gzip'
15
+ end
16
+
17
+ # transparently decompress response body,
18
+ # if content-encoding indicates it is gzipped
19
+ #
20
+ alias_method :handle_response_without_gzip, :handle_response
21
+ def handle_response(response)
22
+ if 'gzip' == response['content-encoding']
23
+ response.body = Zlib::GzipReader.new(StringIO.new(response.body)).read
24
+ response.delete('content-encoding')
25
+ end
26
+ handle_response_without_gzip(response)
27
+ end
28
+
10
29
  end
11
30
  end
@@ -0,0 +1,6 @@
1
+ module LiquidPlanner
2
+ module Resources
3
+ class CustomField < WorkspaceResource
4
+ end
5
+ end
6
+ end
@@ -1,7 +1,6 @@
1
1
  module LiquidPlanner
2
2
  module Resources
3
- class Member < LiquidPlanner::LiquidPlannerResource
4
- self.prefix = "/api/workspaces/:workspace_id/"
3
+ class Member < WorkspaceResource
5
4
  def avatar
6
5
  get_raw(:avatar)
7
6
  end
@@ -3,9 +3,7 @@
3
3
  #------------------------------------------------------------------------
4
4
  module LiquidPlanner
5
5
  module Resources
6
- class Treeitem < LiquidPlanner::LiquidPlannerResource
7
-
8
- self.prefix = "/api/workspaces/:workspace_id/"
6
+ class Treeitem < WorkspaceResource
9
7
 
10
8
  def parent
11
9
  parent_id && Treeitem.find( :one, :from => "/api/workspaces/#{workspace_id}/treeitems/#{parent_id}" )
@@ -37,6 +37,10 @@ module LiquidPlanner
37
37
  def folders( scope=:all, options={} )
38
38
  Folder.find( scope, :params => { :workspace_id => self.id, :flat => true }.merge(options) )
39
39
  end
40
+
41
+ def custom_fields( scope=:all, options={} )
42
+ CustomField.find( scope, :params => { :workspace_id => self.id }.merge(options) )
43
+ end
40
44
 
41
45
  protected
42
46
 
@@ -0,0 +1,8 @@
1
+ module LiquidPlanner
2
+ module Resources
3
+ class WorkspaceResource < LiquidPlanner::LiquidPlannerResource
4
+ self.prefix = "/api/workspaces/:workspace_id/"
5
+ end
6
+ end
7
+ end
8
+
metadata CHANGED
@@ -1,146 +1,102 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: liquidplanner
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Brett Bender
14
9
  - Adam Sanderson
10
+ - Mark Holton
15
11
  autorequire:
16
12
  bindir: bin
17
13
  cert_chain: []
18
-
19
- date: 2012-03-14 00:00:00 -07:00
14
+ date: 2012-06-22 00:00:00.000000000 -07:00
20
15
  default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
23
18
  name: activeresource
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirement: &2222498920 !ruby/object:Gem::Requirement
26
20
  none: false
27
- requirements:
28
- - - ~>
29
- - !ruby/object:Gem::Version
30
- hash: 7
31
- segments:
32
- - 3
33
- - 0
34
- - 0
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
35
24
  version: 3.0.0
36
- - - ">="
37
- - !ruby/object:Gem::Version
38
- hash: 7
39
- segments:
40
- - 3
41
- - 0
42
- - 0
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
43
27
  version: 3.0.0
44
28
  type: :runtime
45
- version_requirements: *id001
46
- - !ruby/object:Gem::Dependency
47
- name: activesupport
48
29
  prerelease: false
49
- requirement: &id002 !ruby/object:Gem::Requirement
30
+ version_requirements: *2222498920
31
+ - !ruby/object:Gem::Dependency
32
+ name: activesupport
33
+ requirement: &2222498160 !ruby/object:Gem::Requirement
50
34
  none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- hash: 7
55
- segments:
56
- - 3
57
- - 0
58
- - 0
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
59
38
  version: 3.0.0
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- hash: 7
63
- segments:
64
- - 3
65
- - 0
66
- - 0
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
67
41
  version: 3.0.0
68
42
  type: :runtime
69
- version_requirements: *id002
70
- - !ruby/object:Gem::Dependency
71
- name: multipart-post
72
43
  prerelease: false
73
- requirement: &id003 !ruby/object:Gem::Requirement
44
+ version_requirements: *2222498160
45
+ - !ruby/object:Gem::Dependency
46
+ name: multipart-post
47
+ requirement: &2222497400 !ruby/object:Gem::Requirement
74
48
  none: false
75
- requirements:
76
- - - ~>
77
- - !ruby/object:Gem::Version
78
- hash: 21
79
- segments:
80
- - 1
81
- - 0
82
- - 1
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
83
52
  version: 1.0.1
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 21
87
- segments:
88
- - 1
89
- - 0
90
- - 1
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
91
55
  version: 1.0.1
92
56
  type: :runtime
93
- version_requirements: *id003
94
- - !ruby/object:Gem::Dependency
95
- name: highline
96
57
  prerelease: false
97
- requirement: &id004 !ruby/object:Gem::Requirement
58
+ version_requirements: *2222497400
59
+ - !ruby/object:Gem::Dependency
60
+ name: highline
61
+ requirement: &2222496660 !ruby/object:Gem::Requirement
98
62
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 5
103
- segments:
104
- - 1
105
- - 5
106
- version: "1.5"
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '1.5'
107
67
  type: :development
108
- version_requirements: *id004
109
- - !ruby/object:Gem::Dependency
110
- name: mocha
111
68
  prerelease: false
112
- requirement: &id005 !ruby/object:Gem::Requirement
69
+ version_requirements: *2222496660
70
+ - !ruby/object:Gem::Dependency
71
+ name: mocha
72
+ requirement: &2222496180 !ruby/object:Gem::Requirement
113
73
  none: false
114
- requirements:
115
- - - "="
116
- - !ruby/object:Gem::Version
117
- hash: 43
118
- segments:
119
- - 0
120
- - 9
121
- - 8
74
+ requirements:
75
+ - - =
76
+ - !ruby/object:Gem::Version
122
77
  version: 0.9.8
123
78
  type: :development
124
- version_requirements: *id005
79
+ prerelease: false
80
+ version_requirements: *2222496180
125
81
  description: LiquidPlanner API client, using ActiveResource
126
82
  email: api@liquidplanner.com
127
83
  executables: []
128
-
129
84
  extensions: []
130
-
131
- extra_rdoc_files:
85
+ extra_rdoc_files:
132
86
  - README.rdoc
133
- files:
87
+ files:
134
88
  - HISTORY
135
89
  - README.rdoc
136
90
  - Rakefile
137
91
  - examples/README
138
92
  - examples/create_task.rb
93
+ - examples/list_custom_fields.rb
139
94
  - examples/list_tasks.rb
140
95
  - examples/post-commit.rb
141
96
  - examples/support/helper.rb
142
97
  - examples/svn-post-commit.sh
143
98
  - examples/track_time.rb
99
+ - examples/update_custom_field_value.rb
144
100
  - lib/liquidplanner.rb
145
101
  - lib/liquidplanner/base.rb
146
102
  - lib/liquidplanner/debug.rb
@@ -153,6 +109,7 @@ files:
153
109
  - lib/liquidplanner/resources/client.rb
154
110
  - lib/liquidplanner/resources/comment.rb
155
111
  - lib/liquidplanner/resources/container.rb
112
+ - lib/liquidplanner/resources/custom_field.rb
156
113
  - lib/liquidplanner/resources/document.rb
157
114
  - lib/liquidplanner/resources/estimate.rb
158
115
  - lib/liquidplanner/resources/event.rb
@@ -173,42 +130,34 @@ files:
173
130
  - lib/liquidplanner/resources/task.rb
174
131
  - lib/liquidplanner/resources/treeitem.rb
175
132
  - lib/liquidplanner/resources/workspace.rb
133
+ - lib/liquidplanner/resources/workspace_resource.rb
176
134
  - test/liquidplanner_resource_test.rb
177
135
  - test/workspace_test.rb
178
136
  has_rdoc: true
179
137
  homepage: http://github.com/liquidplanner/liquidplanner
180
138
  licenses: []
181
-
182
139
  post_install_message:
183
140
  rdoc_options: []
184
-
185
- require_paths:
141
+ require_paths:
186
142
  - lib
187
- required_ruby_version: !ruby/object:Gem::Requirement
143
+ required_ruby_version: !ruby/object:Gem::Requirement
188
144
  none: false
189
- requirements:
190
- - - ">="
191
- - !ruby/object:Gem::Version
192
- hash: 3
193
- segments:
194
- - 0
195
- version: "0"
196
- required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
197
150
  none: false
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- hash: 3
202
- segments:
203
- - 0
204
- version: "0"
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
205
155
  requirements: []
206
-
207
156
  rubyforge_project:
208
- rubygems_version: 1.3.7
157
+ rubygems_version: 1.6.2
209
158
  signing_key:
210
159
  specification_version: 3
211
160
  summary: LiquidPlanner API client
212
- test_files:
161
+ test_files:
213
162
  - test/liquidplanner_resource_test.rb
214
163
  - test/workspace_test.rb