redmine_rest 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1eb48cd91b3992ee6524c3b5728b0836a6c74563
4
- data.tar.gz: 405d4e6946dea7a35e1e87d05531879ec6dbed56
3
+ metadata.gz: 670b07a066cf6379e097ccc21ec3aecc60ac7e04
4
+ data.tar.gz: 22635636c57dd44c1988f8ee8b28eb85ad7ce098
5
5
  SHA512:
6
- metadata.gz: bb1b966892b31414edf9e9b294880afe71ce043fbe46c290f6edbf065751584af4d8ad3479657a9631e90da82b2fb0b528c218b64a6052b8ae1960c564f9c132
7
- data.tar.gz: 25306cc4f5a0ceb3f9d10c847254e8c5b6d7a62cdac41a53fd4e995f7928722d1b01b8c2b6762225db985e0f05c5eae704728cf88c915db29d2695dfdb098b64
6
+ metadata.gz: 00aaa274b644ed7b194da87a38221d3fcde33b7fbcbecbfd7c298abccab4815e4aa48814b05a93a24742c2d91d1c1424b1db369c542b56721ffa1f3de397f02a
7
+ data.tar.gz: 4fb599f913f0c87f182a9462ac535d589da6d8c42faf3681507f328782670085df729bfb2ccaac282b89d3f00bc0de803a0e9a2be2ae8832fc4e208ded7f95b2
@@ -7,6 +7,7 @@ require_relative 'relation'
7
7
  require_relative 'tracker'
8
8
  require_relative 'attachment'
9
9
  require_relative 'collections/issue'
10
+ require_relative 'issue/journal'
10
11
 
11
12
  module RedmineRest
12
13
  module Models
@@ -27,6 +28,7 @@ module RedmineRest
27
28
  has_many :watchers, class_name: User
28
29
  has_many :relations, class_name: Relation
29
30
  has_many :attachments, class_name: Attachment
31
+ has_many :journals, class_name: Journal
30
32
 
31
33
  validates :subject, :tracker_id, presence: true
32
34
 
@@ -53,6 +55,52 @@ module RedmineRest
53
55
  super(what, options)
54
56
  end
55
57
 
58
+ def version
59
+ fixed_version
60
+ end
61
+
62
+ #
63
+ # Sets #fixed_version_id via Version object.
64
+ #
65
+ def fixed_version=(version)
66
+ fail ArgumentError unless version.is_a? Version
67
+ self.fixed_version_id = version.id
68
+ end
69
+
70
+ alias_method 'version=', 'fixed_version='
71
+
72
+ #
73
+ # Sets #tracker_id via Tracker object.
74
+ #
75
+ def tracker=(tracker)
76
+ fail ArgumentError unless tracker.is_a? Tracker
77
+ self.tracker_id = tracker.id
78
+ end
79
+
80
+ #
81
+ # Sets #project_id via Project object.
82
+ #
83
+ def project=(project)
84
+ fail ArgumentError unless project.is_a? Project
85
+ self.project_id = project.id
86
+ end
87
+
88
+ #
89
+ # Sets #assigned_to_id via User object
90
+ #
91
+ def assigned_to=(user)
92
+ fail ArgumentError unless user.is_a? User
93
+ self.assigned_to_id = user.id
94
+ end
95
+
96
+ #
97
+ # Sets #parent_issue_id via Issue object
98
+ #
99
+ def parent=(issue)
100
+ fail ArgumentError unless issue.is_a? Issue
101
+ self.parent_issue_id = issue.id
102
+ end
103
+
56
104
  def method_missing(method, *args)
57
105
  return super if block_given? || method.to_s.end_with?('?') || !args.empty?
58
106
  attributes[method]
@@ -0,0 +1,35 @@
1
+ require_relative 'journal_detail'
2
+
3
+ module RedmineRest
4
+ module Models
5
+ class Issue < ActiveResource::Base
6
+ #
7
+ # Class that represents issue journals.
8
+ #
9
+ # Redmine REST provides journals only through `/issues.xml?include=journals`,
10
+ # so there's no reason to use active_resource
11
+ #
12
+ class Journal
13
+ attr_accessor :id, :user, :notes,
14
+ :created_on, :details
15
+
16
+ attr_reader :broken # for indication that something is wrong
17
+
18
+ def initialize(params, _persisted)
19
+ params.each { |attr, value| public_send("#{attr}=", value) }
20
+ rescue
21
+ @broken = true
22
+ end
23
+
24
+ def user=(value)
25
+ @user = User.new(value, true)
26
+ end
27
+
28
+ def details=(value)
29
+ value = [value] unless value.is_a? Array
30
+ @details = value.map { |v| Detail.new(v) }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,42 @@
1
+ require 'active_model'
2
+
3
+ module RedmineRest
4
+ module Models
5
+ class Issue < ActiveResource::Base
6
+ class Journal
7
+ #
8
+ # Journal detail
9
+ #
10
+ class Detail
11
+ include ActiveModel::Model
12
+ attr_accessor :property, :name, :old_value, :new_value
13
+
14
+ def attribute?
15
+ property == 'attr'
16
+ end
17
+
18
+ def relation?
19
+ property == 'relation'
20
+ end
21
+
22
+ def method_missing(m, *args)
23
+ m = m.to_s
24
+
25
+ return super unless args.empty? && m.to_s.end_with?('?')
26
+ name == m.to_s[0..-2]
27
+ end
28
+
29
+ def to_s
30
+ if attribute?
31
+ "#{name}: #{old_value.nil? ? 'nil' : old_value} -> #{new_value.nil? ? 'nil' : new_value}"
32
+ elsif relation?
33
+ "#{name} #{new_value}"
34
+ else
35
+ super
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module RedmineRest
2
- VERSION = '0.7.0'.freeze
2
+ VERSION = '0.8.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Non
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-31 00:00:00.000000000 Z
11
+ date: 2016-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -117,6 +117,8 @@ files:
117
117
  - lib/redmine_rest/models/collections/issue.rb
118
118
  - lib/redmine_rest/models/group.rb
119
119
  - lib/redmine_rest/models/issue.rb
120
+ - lib/redmine_rest/models/issue/journal.rb
121
+ - lib/redmine_rest/models/issue/journal_detail.rb
120
122
  - lib/redmine_rest/models/issue_priority.rb
121
123
  - lib/redmine_rest/models/issue_status.rb
122
124
  - lib/redmine_rest/models/membership.rb