youtrack_on_rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTNiMzEzY2NlYzVhOTRhZjdmNDBmOWViZTEzMDg2ZDhkMTZmNTM1Mw==
4
+ NGZlYzY3YmI2YjYwNWQwYWNlYTI3YmIwZDg0YTcwNmJkYWRkOGM5Mg==
5
5
  data.tar.gz: !binary |-
6
- YzJiNWQwY2EzMzYwMzZlNzcxYmQ5M2M2ZjVlMzg1OTQ3YjZmZDdjZg==
6
+ YTJkNTMzNjlmNzgwMThiYTJlYThlYjEyZDMxN2Y1YzY1ZDcyMDkyMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTMzMTIyYWFjNDE1ZDNhYmZiNjFkY2Y0OTc2ZDNlODFiMjc2NjBkMzgzZjMz
10
- MmFkZDczZGI1Y2YxOTc1OTUzZGI0ZDM5MmM4ODAyMzBhNDhhY2RhN2UzYzQ0
11
- NDVmMmY4Y2MwOWE3YzMzOWVkMmUzMTdmMjJiNjUyZjI4ZDc0OWE=
9
+ M2QzZWI2NWUwYWZhNTA3YWU3MWI2M2FiMGNhMDBlMmYxYWVlZDRhNmQ4N2Vi
10
+ MmRiYTk2MTEyNzYxYjYxNjIwNjJkMTJmNDM0MTU3YzQxYzVlMzM1NDQ3ODM0
11
+ ZDQzOTQ1ZDE4NWY5OWM4NTE2N2Y4MDQ1NDk1NTBlM2IwZDNiYWE=
12
12
  data.tar.gz: !binary |-
13
- MDBiMjNiMzNlYTM0ODJiZDM1ZTFiNzJiY2Q3NGYzOTIwODQxODM0OGFhNWY0
14
- NzMxYmI1ODZhZjllZWIzODgyYWJlYWMwMjhlNzRiNjJiYWRjNjI3YjhhZTFl
15
- ZWU3OTVkYTk3MjJiNzg0ZmZiZmY5ZTIzMmMxNWMxM2RhNGUzNDk=
13
+ MjQ4NzY0NmVmMDc0MGNjMGNlYzEwNmQ0NjAzZDZjNGNiZjc0YTI5MjY4ZmQ3
14
+ NmE0MTU2ZDFhOGJkYWYwNDhkMGNmYjlkY2E3MDhkNWI4OTllMWFmODI3YjQ1
15
+ YTJmOWU5MzljMTZkNTNiZjQxZjBkYzAxM2I1NzUzZWJmMWM0NTE=
@@ -6,6 +6,7 @@ module YoutrackOnRails
6
6
  autoload :Post, 'youtrack_on_rails/requests/post'
7
7
 
8
8
  autoload :ListProjects, 'youtrack_on_rails/requests/list_projects'
9
+ autoload :ListIssues, 'youtrack_on_rails/requests/list_issues'
9
10
  autoload :SignIn, 'youtrack_on_rails/requests/sign_in'
10
11
  end
11
12
  end
@@ -31,6 +31,9 @@ module YoutrackOnRails
31
31
  end
32
32
 
33
33
  def http_request
34
+ #TODO Remove when development is done
35
+ puts "URI: #{endpoint_uri}"
36
+
34
37
  http_class.new(endpoint_uri).tap do |request|
35
38
  request.body = raw_body.to_s
36
39
  request.add_field("Cookie", cookie) if cookie
@@ -41,10 +44,14 @@ module YoutrackOnRails
41
44
 
42
45
  def endpoint_uri
43
46
  (connection_uri.path + processed_url).tap do |_endpoint_uri|
44
- _endpoint_uri += "?#{URI.encode_www_form(params)}" if http_method == 'get'
47
+ _endpoint_uri << "?#{encoded_params}" if http_method == 'get'
45
48
  end
46
49
  end
47
50
 
51
+ def encoded_params
52
+ URI.encode_www_form(params)
53
+ end
54
+
48
55
  def http_response
49
56
  connection.request(http_request)
50
57
  end
@@ -0,0 +1,9 @@
1
+ module YoutrackOnRails
2
+ module Requests
3
+ class ListIssues < Get
4
+ def url
5
+ '/rest/issue'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -6,6 +6,7 @@ module YoutrackOnRails
6
6
  autoload :CollectionResponse, 'youtrack_on_rails/responses/collection_response'
7
7
 
8
8
  autoload :ListProjects, 'youtrack_on_rails/responses/list_projects'
9
+ autoload :ListIssues, 'youtrack_on_rails/responses/list_issues'
9
10
  autoload :SignIn, 'youtrack_on_rails/responses/sign_in'
10
11
  end
11
12
  end
@@ -1,14 +1,16 @@
1
1
  module YoutrackOnRails
2
2
  module Responses
3
3
  class CollectionResponse < Base
4
- def process
5
- xml.xpath('//projects/project').map do |project_node|
6
- @attributes ||= project_node.attributes.keys
4
+ def process(&block)
5
+ xml.xpath(xpath).map do |object_node|
6
+ @attributes ||= object_node.attributes.keys
7
7
 
8
- hash = @attributes.each_with_object({}) do |attribute_key, hash|
9
- hash[attribute_key.underscore] = project_node[attribute_key]
8
+ hash = @attributes.each_with_object({}) do |attribute_key, _hash|
9
+ _hash[attribute_key.underscore] = object_node[attribute_key]
10
10
  end
11
11
 
12
+ block.call(hash, object_node) if block_given?
13
+
12
14
  Dish(hash)
13
15
  end
14
16
  end
@@ -19,8 +21,12 @@ module YoutrackOnRails
19
21
  'project'
20
22
  end
21
23
 
24
+ def collection_name
25
+ resource_name.pluralize
26
+ end
27
+
22
28
  def xpath
23
- "//#{resource_name.pluralize}/#{resource_name}"
29
+ "//#{collection_name}/#{resource_name}"
24
30
  end
25
31
  end
26
32
  end
@@ -0,0 +1,24 @@
1
+ module YoutrackOnRails
2
+ module Responses
3
+ class ListIssues < CollectionResponse
4
+ def process(*)
5
+ super do |hash, issue_node|
6
+ attributes = issue_node.xpath('field').map{|field| field['name']}
7
+ attributes.each_with_object(hash) do |attribute, _hash|
8
+ _hash[attribute.downcase] = issue_node.xpath("field[@name='#{attribute}']/value").text
9
+ end
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def resource_name
16
+ 'issue'
17
+ end
18
+
19
+ def collection_name
20
+ 'issueCompacts'
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module YoutrackOnRails
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youtrack_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - stevo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-12 00:00:00.000000000 Z
12
+ date: 2014-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -51,12 +51,14 @@ files:
51
51
  - lib/youtrack_on_rails/requests.rb
52
52
  - lib/youtrack_on_rails/requests/base.rb
53
53
  - lib/youtrack_on_rails/requests/get.rb
54
+ - lib/youtrack_on_rails/requests/list_issues.rb
54
55
  - lib/youtrack_on_rails/requests/list_projects.rb
55
56
  - lib/youtrack_on_rails/requests/post.rb
56
57
  - lib/youtrack_on_rails/requests/sign_in.rb
57
58
  - lib/youtrack_on_rails/responses.rb
58
59
  - lib/youtrack_on_rails/responses/base.rb
59
60
  - lib/youtrack_on_rails/responses/collection_response.rb
61
+ - lib/youtrack_on_rails/responses/list_issues.rb
60
62
  - lib/youtrack_on_rails/responses/list_projects.rb
61
63
  - lib/youtrack_on_rails/responses/sign_in.rb
62
64
  - lib/youtrack_on_rails/responses/simple_response.rb