howlingmine-client 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 0.1.4 / 2009-12-23
2
+
3
+ * Added Issue.find method
4
+ * Updated examples
5
+ * Added script/console script
6
+ * Requires howlingmine-server 0.2
7
+
1
8
  === 0.1.3 / 2009-12-16
2
9
 
3
10
  * fix bug when saving custom fields
data/Manifest.txt CHANGED
@@ -10,4 +10,5 @@ lib/howlingmine/config.rb
10
10
  lib/howlingmine/issue.rb
11
11
  redmine_test_files/database.yml
12
12
  redmine_test_files/redmine.db
13
+ script/console
13
14
  test/issue_test.rb
@@ -54,30 +54,14 @@
54
54
  <key>caret</key>
55
55
  <dict>
56
56
  <key>column</key>
57
- <integer>127</integer>
57
+ <integer>209</integer>
58
58
  <key>line</key>
59
- <integer>22</integer>
59
+ <integer>26</integer>
60
60
  </dict>
61
- <key>columnSelection</key>
62
- <false/>
63
61
  <key>firstVisibleColumn</key>
64
62
  <integer>0</integer>
65
63
  <key>firstVisibleLine</key>
66
64
  <integer>0</integer>
67
- <key>selectFrom</key>
68
- <dict>
69
- <key>column</key>
70
- <integer>115</integer>
71
- <key>line</key>
72
- <integer>22</integer>
73
- </dict>
74
- <key>selectTo</key>
75
- <dict>
76
- <key>column</key>
77
- <integer>127</integer>
78
- <key>line</key>
79
- <integer>22</integer>
80
- </dict>
81
65
  </dict>
82
66
  <key>lib/howlingmine/config.rb</key>
83
67
  <dict>
@@ -98,28 +82,28 @@
98
82
  <key>caret</key>
99
83
  <dict>
100
84
  <key>column</key>
101
- <integer>10</integer>
85
+ <integer>0</integer>
102
86
  <key>line</key>
103
- <integer>13</integer>
87
+ <integer>72</integer>
104
88
  </dict>
105
89
  <key>firstVisibleColumn</key>
106
90
  <integer>0</integer>
107
91
  <key>firstVisibleLine</key>
108
- <integer>0</integer>
92
+ <integer>91</integer>
109
93
  </dict>
110
94
  <key>test/issue_test.rb</key>
111
95
  <dict>
112
96
  <key>caret</key>
113
97
  <dict>
114
98
  <key>column</key>
115
- <integer>3</integer>
99
+ <integer>31</integer>
116
100
  <key>line</key>
117
- <integer>125</integer>
101
+ <integer>145</integer>
118
102
  </dict>
119
103
  <key>firstVisibleColumn</key>
120
104
  <integer>0</integer>
121
105
  <key>firstVisibleLine</key>
122
- <integer>94</integer>
106
+ <integer>114</integer>
123
107
  </dict>
124
108
  </dict>
125
109
  <key>openDocuments</key>
@@ -22,6 +22,10 @@ module HowlingMine
22
22
  def journals
23
23
  RestClient.post("#{HowlingMine::Config.protocol}://#{HowlingMine::Config.host}:#{HowlingMine::Config.port}/howling_mine/journals", :api_key => HowlingMine::Config.api_key, :issue_id => HowlingMine::Config.params[:issue_id])
24
24
  end
25
+
26
+ def find
27
+ RestClient.post("#{HowlingMine::Config.protocol}://#{HowlingMine::Config.host}:#{HowlingMine::Config.port}/howling_mine/find", HowlingMine::Config.params.merge(:api_key => HowlingMine::Config.api_key))
28
+ end
25
29
  end
26
30
  end
27
31
 
@@ -37,35 +37,14 @@ module HowlingMine
37
37
  end
38
38
  end
39
39
 
40
+ def self.find(method = :all, params = {})
41
+ params[:method] = method
42
+ HowlingMine::Config.params.merge!(params)
43
+ build_issues(HowlingMine::Client.find)
44
+ end
45
+
40
46
  def self.all
41
- project = JSON.parse(HowlingMine::Client.projects).find do |p|
42
- p['identifier'] == HowlingMine::Config.project
43
- end
44
- project_id = ''
45
- if ! project.nil?
46
- project_id = project['id']
47
- else
48
- raise Exception.new("#{HowlingMine::Config.project} project not found in target Redmine")
49
- end
50
- issues = []
51
- client = HowlingMine::Client
52
- JSON.parse(client.issues).each do |i|
53
- next if i['project_id'] != project_id
54
- issue = Issue.new
55
- issue.subject = i['subject']
56
- issue.description = i['description']
57
- issue.id = i['id'].to_i
58
- issue.raw = i
59
- issue.created_on = i['created_on']
60
- issue.updated_on = i['updated_on']
61
- if i['custom_fields']
62
- i['custom_fields'].each do |k,v|
63
- issue.custom_fields[k.to_sym] = v
64
- end
65
- end
66
- issues << issue
67
- end
68
- issues
47
+ build_issues(HowlingMine::Client.issues)
69
48
  end
70
49
 
71
50
  def updated_on
@@ -77,11 +56,11 @@ module HowlingMine
77
56
  end
78
57
 
79
58
  def self.first
80
- all.first
59
+ find :first
81
60
  end
82
61
 
83
62
  def self.last
84
- all.last
63
+ find :last
85
64
  end
86
65
 
87
66
  def status
@@ -91,7 +70,7 @@ module HowlingMine
91
70
  end
92
71
 
93
72
  def self.get(ticket_no)
94
- all.find do |i| ticket_no.to_i == i.id end
73
+ find ticket_no.to_i
95
74
  end
96
75
 
97
76
  def journal
@@ -102,5 +81,44 @@ module HowlingMine
102
81
  HowlingMine::Config.params.merge! params
103
82
  JSON.parse(client.journals)
104
83
  end
84
+
85
+ private
86
+ def self.build_issues(json)
87
+ issues = []
88
+ elems = JSON.parse json
89
+ if elems.is_a? Array
90
+ elems.each do |i|
91
+ issue = Issue.new
92
+ issue.subject = i['subject']
93
+ issue.description = i['description']
94
+ issue.id = i['id'].to_i
95
+ issue.raw = i
96
+ issue.created_on = i['created_on']
97
+ issue.updated_on = i['updated_on']
98
+ if i['custom_fields']
99
+ i['custom_fields'].each do |k,v|
100
+ issue.custom_fields[k.to_sym] = v
101
+ end
102
+ end
103
+ issues << issue
104
+ end
105
+ return issues
106
+ else
107
+ i = elems
108
+ issue = Issue.new
109
+ issue.subject = i['subject']
110
+ issue.description = i['description']
111
+ issue.id = i['id'].to_i
112
+ issue.raw = i
113
+ issue.created_on = i['created_on']
114
+ issue.updated_on = i['updated_on']
115
+ if i['custom_fields']
116
+ i['custom_fields'].each do |k,v|
117
+ issue.custom_fields[k.to_sym] = v
118
+ end
119
+ end
120
+ return issue
121
+ end
122
+ end
105
123
  end
106
124
  end
data/lib/howlingmine.rb CHANGED
@@ -10,5 +10,5 @@ require "#{File.join(File.dirname(__FILE__),'howlingmine/client')}"
10
10
  require "#{File.join(File.dirname(__FILE__),'howlingmine/issue')}"
11
11
 
12
12
  module HowlingMine
13
- VERSION = '0.1.3'
13
+ VERSION = '0.1.4'
14
14
  end
data/script/console ADDED
@@ -0,0 +1,33 @@
1
+ #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
2
+ #
3
+ # irb.rb - intaractive ruby
4
+ # $Release Version: 0.9.5 $
5
+ # $Revision: 11708 $
6
+ # $Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
7
+ # by Keiju ISHITSUKA(keiju@ruby-lang.org)
8
+ #
9
+
10
+ require "irb"
11
+ require File.join(File.dirname(__FILE__), "../lib/howlingmine.rb")
12
+
13
+ include HowlingMine
14
+
15
+ HowlingMine::Config.host = 'redmine.local'
16
+ HowlingMine::Config.port = 80 # default
17
+ HowlingMine::Config.use_ssl = false # default
18
+ HowlingMine::Config.project = 'howlingmine'
19
+ HowlingMine::Config.tracker = 'Bug' # default
20
+ HowlingMine::Config.api_key = 'woiun@34lkju8ou'
21
+
22
+ if __FILE__ == $0
23
+ IRB.start(__FILE__)
24
+ else
25
+ # check -e option
26
+ if /^-e$/ =~ $0
27
+ IRB.start(__FILE__)
28
+ else
29
+ IRB.setup(__FILE__)
30
+ end
31
+ end
32
+
33
+
data/test/issue_test.rb CHANGED
@@ -122,5 +122,29 @@ class TestIssue < Test::Unit::TestCase
122
122
  assert issue.unexistant_method98847
123
123
  end
124
124
  end
125
+
126
+ def test_find
127
+ assert HowlingMine::Issue.find(:all).size == 0
128
+ issue = HowlingMine::Issue.new
129
+ issue.subject = 'issue number 1'
130
+ issue.description = 'description'
131
+ issue.custom_fields[:foofield1] = 'value1'
132
+ assert issue.save
133
+ issue = HowlingMine::Issue.find :first
134
+ assert issue != nil
135
+ assert issue.subject == 'issue number 1'
136
+ issue = HowlingMine::Issue.find :last
137
+ assert issue != nil
138
+ assert issue.subject == 'issue number 1'
139
+ issue = HowlingMine::Issue.find 1
140
+ assert issue != nil
141
+ assert issue.subject == 'issue number 1'
142
+ assert_raises RestClient::ResourceNotFound do
143
+ HowlingMine::Issue.find 0
144
+ end
145
+ assert_raises RestClient::ResourceNotFound do
146
+ HowlingMine::Issue.find 2
147
+ end
148
+ end
125
149
 
126
150
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: howlingmine-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Rubio
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-16 00:00:00 +01:00
12
+ date: 2009-12-23 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -66,6 +66,7 @@ files:
66
66
  - lib/howlingmine/issue.rb
67
67
  - redmine_test_files/database.yml
68
68
  - redmine_test_files/redmine.db
69
+ - script/console
69
70
  - test/issue_test.rb
70
71
  has_rdoc: true
71
72
  homepage: http://github.com/rubiojr/howlingmine-client