omnifocus-redmine 1.1.0 → 1.2.0

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.
Files changed (4) hide show
  1. data/History.txt +5 -0
  2. data/README.txt +19 -7
  3. data/lib/omnifocus/redmine.rb +24 -8
  4. metadata +35 -17
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 1.2.0 / 2011-02-15
2
+ * Fixed a bug with a missing variable
3
+ * Removed an errant puts
4
+ * Added support for authentication
5
+
1
6
  === 1.1.0 / 2011-02-8
2
7
  * Added ability to run multiple queries.
3
8
 
data/README.txt CHANGED
@@ -6,21 +6,33 @@
6
6
 
7
7
  Plugin for the omnifocus gem to provide synchronization with Redmine Issues.
8
8
 
9
+ This plugin uses the Redmine REST API. It must be enabled by an administrator
10
+ for the plugin to work.
11
+
9
12
  The first time this runs it creates a yaml file in your home directory for
10
- the redmine url and username.
13
+ the configuration data.
14
+
15
+ * redmine_url is required. This is the base url for the redmine repository.
16
+
17
+ * user_id is required. To find your user id login and go to the my account
18
+ page. Your user_id is the number at the end of the url for my account.
11
19
 
12
- The queries config is optional. If it is not included omnifocus-redmine will
13
- pull all open bugs assigned to the specified user.
20
+ * username is optional. It is used if the redmine server requires
21
+ authentication.
14
22
 
15
- To use a custom query or multiple queries you must include a queries parameter
16
- in your config.
23
+ * password is optional. It is used if the redmine server requires
24
+ authentication.
17
25
 
18
- The queries config is an array of strings. These strings will be appended onto a
19
- query of the form: http://your-redmine-url/issues.xml?assigned_to_id=user-id?.
26
+ * queries is optional. It is used for custom queries or multiple queries.
27
+ The queries config is an array of strings. The strings will be appended
28
+ to a query of the form:
29
+ "http://redmine_url/issues.xml?assigned_to_id=user_id".
20
30
 
21
31
  Example:
22
32
  :user_id: 20
23
33
  :redmine_url: http://redmine/
34
+ :username: me
35
+ :password: 1234
24
36
  :queries: ["status_id=1", "status_id=2"]
25
37
 
26
38
  == FEATURES/PROBLEMS:
@@ -1,5 +1,5 @@
1
1
  module OmniFocus::Redmine
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
 
4
4
  def load_or_create_redmine_config
5
5
  path = File.expand_path "~/.omnifocus-redmine.yml"
@@ -7,8 +7,10 @@ module OmniFocus::Redmine
7
7
 
8
8
  unless config then
9
9
  config = {
10
- :user => "Admin User",
10
+ :user_id => "20",
11
11
  :redmine_url => "http://redmine",
12
+ :username => "UserName",
13
+ :password => "Password"
12
14
  }
13
15
 
14
16
  File.open(path, "w") { |f|
@@ -24,22 +26,36 @@ module OmniFocus::Redmine
24
26
  def populate_redmine_tasks
25
27
  config = load_or_create_redmine_config
26
28
  redmine_url = config[:redmine_url]
27
- user_id = config[:user_id]
29
+ user_id = config[:user_id]
30
+ username = config[:username]
31
+ password = config[:password]
32
+
33
+ # Authenticate if the user name and password are defined
34
+ if username and password then
35
+ mechanize.basic_auth(username, password)
36
+ end
37
+
28
38
  default_query = "#{redmine_url}/issues.xml?assigned_to_id=#{user_id}"
29
39
 
30
40
  unless config[:queries]
31
- process_query_results default_query
41
+ process_query_results(default_query, redmine_url)
32
42
  else
33
43
  queries = config[:queries]
34
44
  queries.each do |q|
35
- process_query_results "#{default_query}&#{q}"
45
+ process_query_results("#{default_query}&#{q}", redmine_url)
36
46
  end
37
47
  end
38
48
  end
39
49
 
40
- def process_query_results(query)
41
- puts query
42
- mechanize.get(query)
50
+ def process_query_results(query, redmine_url)
51
+ begin
52
+ mechanize.get(query)
53
+ rescue Mechanize::ResponseCodeError => e
54
+ if e.response_code == "401" then
55
+ abort "Unauthorized. Check username and password in .omnifocus-redmine"
56
+ end
57
+ end
58
+
43
59
  details = Nokogiri.parse(mechanize.current_page.body)
44
60
 
45
61
  issues = details.root.xpath('//issue')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnifocus-redmine
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - aja
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-08 00:00:00 -08:00
18
+ date: 2011-02-15 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -64,19 +64,37 @@ dependencies:
64
64
  version: 2.8.0
65
65
  type: :development
66
66
  version_requirements: *id003
67
- description: "Plugin for the omnifocus gem to provide synchronization with Redmine Issues.\n\n\
68
- The first time this runs it creates a yaml file in your home directory for \n\
69
- the redmine url and username.\n\n\
70
- The queries config is optional. If it is not included omnifocus-redmine will\n\
71
- pull all open bugs assigned to the specified user.\n\n\
72
- To use a custom query or multiple queries you must include a queries parameter\n\
73
- in your config.\n\n\
74
- The queries config is an array of strings. These strings will be appended onto a\n\
75
- query of the form: http://your-redmine-url/issues.xml?assigned_to_id=user-id?.\n\n\
76
- Example:\n\
77
- :user_id: 20\n\
78
- :redmine_url: http://redmine/\n\
79
- :queries: [\"status_id=1\", \"status_id=2\"]"
67
+ description: |-
68
+ Plugin for the omnifocus gem to provide synchronization with Redmine Issues.
69
+
70
+ This plugin uses the Redmine REST API. It must be enabled by an administrator
71
+ for the plugin to work.
72
+
73
+ The first time this runs it creates a yaml file in your home directory for
74
+ the configuration data.
75
+
76
+ * redmine_url is required. This is the base url for the redmine repository.
77
+
78
+ * user_id is required. To find your user id login and go to the my account
79
+ page. Your user_id is the number at the end of the url for my account.
80
+
81
+ * username is optional. It is used if the redmine server requires
82
+ authentication.
83
+
84
+ * password is optional. It is used if the redmine server requires
85
+ authentication.
86
+
87
+ * queries is optional. It is used for custom queries or multiple queries.
88
+ The queries config is an array of strings. The strings will be appended
89
+ to a query of the form:
90
+ "http://redmine_url/issues.xml?assigned_to_id=user_id".
91
+
92
+ Example:
93
+ :user_id: 20
94
+ :redmine_url: http://redmine/
95
+ :username: me
96
+ :password: 1234
97
+ :queries: ["status_id=1", "status_id=2"]
80
98
  email:
81
99
  - kushali@rubyforge.org
82
100
  executables: []