clubhouse2 1.0.3 → 1.0.4

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: 7d4671759a9bb2c2702d1b3e236f8b46127dc5ed
4
- data.tar.gz: 7edbf8d76327399603dce7c2c50002095c11ba1f
3
+ metadata.gz: b16f448e16fc7ce33fd39bbd93278cc53383f7f9
4
+ data.tar.gz: 5e38fa96e9f8caea41690a94859bbcd68c18684f
5
5
  SHA512:
6
- metadata.gz: e4735bbe5697325758b252859a42748c9fea3394ef26c4f44dd6a361cb2ce5ef0088d3f511e1f5eb872ebebfb5c561703babcd86098c0e1ccef1ed7a35595e46
7
- data.tar.gz: 0da00f45ceb285c2ad6a5ec6c0d378c2668b92477e710f36d8c5c51ed54c415754d51996c2f9f439b23290c03b4aaab5e5ddbf36ca6fe92eed3101f3fe00e3c0
6
+ metadata.gz: ef29340fa36a3746ced78c18d7c18624cb1135c4b870fff74e4c1d69edf4649f5b2c2044fc4b692fc244369af0a94bcdab6dc7bb8b39791da0fcb149a1b1e2a0
7
+ data.tar.gz: 9193677a35bcf663e1d679a4763d8066cdc6b8067c3ff93327e83321d02ae6fcb9b0912da3a6cabe763113bc37758da2c64a64aa8465168ea5875a492105d824
data/README.md CHANGED
@@ -11,6 +11,7 @@ client = Clubhouse::Client.new(api_key: 'your_api_key')
11
11
  ```
12
12
 
13
13
  ### Quick-start
14
+ #### Queries
14
15
  Get all stories being followed by a user called 'James'.
15
16
  ```ruby
16
17
  client.stories(follower_ids: client.member(name: 'James'))
@@ -36,6 +37,56 @@ Get all stories last updated more than 30 days ago
36
37
  client.stories.select { |story| story.updated_at < Date.today - 30 }
37
38
  ```
38
39
 
40
+ Get a list of all story states in the default workflow
41
+ ```ruby
42
+ client.workflow.states
43
+ ```
44
+
45
+ #### Creating resources
46
+ See the official Clubhouse API documentation for valid properties to use here:
47
+ https://clubhouse.io/api/rest/v2/
48
+
49
+ Create a new story in the 'Testing' project
50
+ ```ruby
51
+ client.project(name: 'Testing').create_story( **...** )
52
+ client.create_story(project_id: client.project(name: 'Testing'), **...** )
53
+ ```
54
+
55
+ #### Updating resources
56
+ Updating a property of a resource can be achieved simply by using assignment operators, as shown in the examples below.
57
+
58
+ See the official Clubhouse API documentation for valid properties to use here:
59
+ https://clubhouse.io/api/rest/v2/
60
+
61
+ Change the name of a story
62
+ ```ruby
63
+ client.story(name: 'Old name').name = 'New name'
64
+ client.story(id: 123).name = 'New name'
65
+ ```
66
+
67
+ Add a new follower to a story
68
+ ```ruby
69
+ client.story(id: 123).follower_ids += [ client.member(name: 'Jeff') ]
70
+ ```
71
+
72
+ Assign a story to an epic
73
+ ```ruby
74
+ client.story(id: 123).epic_id = client.epic(name: 'Awesome')
75
+ ```
76
+
77
+ #### Deleting resources
78
+ Deletion is possible by using the `delete!` method, which is available on most resources. Some resources can only be deleted from the web interface.
79
+
80
+ Delete an epic
81
+ ```ruby
82
+ client.epic(id: 123).delete!
83
+ ```
84
+
85
+ Delete all stories in the 'Testing' project
86
+ ```ruby
87
+ client.project(name: 'Testing').stories.each(&:delete!)
88
+ ```
89
+
39
90
  ### Methods returning arrays of resources
40
91
  ```ruby
41
92
  client.projects # list all projects
@@ -61,7 +112,7 @@ client.stories.select { |story| story.updated_at < Date.today - 30 }
61
112
  client.team # list the first matching team
62
113
  ```
63
114
  ### Filtering
64
- It's possible to filter by any resource property provided by the API. Multiple property filters can be specified.
115
+ It's possible to filter by any resource property provided by the API. Multiple property filters can be specified. Filters match any member of an array, for example you can filter `stories` by `follower_ids`, which will match any stories for which the given member, or members, are followers.
65
116
  ```ruby
66
117
  client.project(id: 123) # get a specific project
67
118
  client.project(name: 'blah') # get a project by name
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.0.4
@@ -11,7 +11,8 @@ module Clubhouse
11
11
  [
12
12
  :archived, :days_to_thermometer, :entity_type, :id, :show_thermometer, :stats, :created_at, :updated_at,
13
13
  :started_at, :completed_at, :comments, :position, :started, :project_ids, :completed, :blocker, :moved_at,
14
- :task_ids, :files, :comment_ids, :workflow_state_id, :story_links, :mention_ids, :file_ids, :linked_file_ids
14
+ :task_ids, :files, :comment_ids, :workflow_state_id, :story_links, :mention_ids, :file_ids, :linked_file_ids,
15
+ :tasks
15
16
  ]
16
17
  end
17
18
 
@@ -36,7 +37,8 @@ module Clubhouse
36
37
  self.class.properties.each do |this_property|
37
38
  self.class.class_eval { attr_accessor(this_property.to_sym) }
38
39
  self.class.send(:define_method, (this_property.to_s + '=').to_sym) do |value|
39
- update({ this_property => value })
40
+ update({ this_property => resolve_to_ids(value) })
41
+ instance_variable_set('@' + this_property.to_s, resolve_to_ids(value))
40
42
  end
41
43
  end
42
44
 
@@ -44,6 +46,11 @@ module Clubhouse
44
46
  self
45
47
  end
46
48
 
49
+ def resolve_to_ids(object)
50
+ return object.collect { |o| resolve_to_ids(o) } if object.is_a? Array
51
+ (object.respond_to?(:id) ? object.id : object)
52
+ end
53
+
47
54
  def set_properties(object)
48
55
  object.each_pair do |k, v|
49
56
  instance_variable_set('@' + k.to_s, value_format(k, v))
@@ -60,7 +67,7 @@ module Clubhouse
60
67
  end
61
68
 
62
69
  def update(args = {})
63
- new_params = to_h.merge(args).reject { |k, v| self.class.property_filter_update.include? k.to_sym }
70
+ new_params = args.reject { |k, v| self.class.property_filter_update.include? k.to_sym }
64
71
  validate(new_params)
65
72
  flush
66
73
  @client.api_request(:put, @client.url(api_url), :json => new_params)
@@ -43,6 +43,12 @@ module Clubhouse
43
43
  end
44
44
  end
45
45
 
46
+ def update(**args)
47
+ # The API won't let us try to update the project ID without changing it
48
+ args.delete(:project_id) if args[:project_id] == @project_id
49
+ super
50
+ end
51
+
46
52
  def create_task(**args)
47
53
  Task.validate(**args)
48
54
  @tasks = nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clubhouse2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Denness
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-09 00:00:00.000000000 Z
11
+ date: 2017-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http