redmine-ruby 0.1.0 → 0.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.
@@ -10,14 +10,14 @@ GEM
10
10
  multi_json (~> 1.3)
11
11
  thread_safe (~> 0.1)
12
12
  tzinfo (~> 0.3.37)
13
- atomic (1.1.9)
13
+ atomic (1.1.10)
14
14
  builder (3.1.4)
15
- faraday (0.8.7)
16
- multipart-post (~> 1.1)
15
+ faraday (0.8.8)
16
+ multipart-post (~> 1.2.0)
17
17
  faraday_middleware (0.9.0)
18
18
  faraday (>= 0.7.4, < 0.9)
19
19
  git (1.2.5)
20
- her (0.6.7)
20
+ her (0.6.8)
21
21
  activemodel (>= 3.0.0)
22
22
  activesupport (>= 3.0.0)
23
23
  faraday (~> 0.8)
@@ -42,7 +42,7 @@ GEM
42
42
  shoulda-context (1.1.3)
43
43
  shoulda-matchers (2.2.0)
44
44
  activesupport (>= 3.0.0)
45
- thread_safe (0.1.0)
45
+ thread_safe (0.1.2)
46
46
  atomic
47
47
  tzinfo (0.3.37)
48
48
 
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # redmine-ruby
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/redmine-ruby.png)](http://badge.fury.io/rb/redmine-ruby)
4
+ [![Code Climate](https://codeclimate.com/github/GeneralScripting/redmine-ruby.png)](https://codeclimate.com/github/GeneralScripting/redmine-ruby)
3
5
 
4
6
  ## Installation
5
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -6,6 +6,8 @@ require 'redmine-ruby/middleware/xml_parser.rb'
6
6
  require 'redmine-ruby/base.rb'
7
7
  require 'redmine-ruby/project.rb'
8
8
  require 'redmine-ruby/issue.rb'
9
+ require 'redmine-ruby/upload.rb'
10
+ require 'redmine-ruby/time_entry.rb'
9
11
 
10
12
  module Redmine
11
13
  class Client
@@ -26,8 +28,10 @@ module Redmine
26
28
  def resource(name, options={})
27
29
  klass = "Redmine::#{name.to_s.classify}".constantize
28
30
  the_api = api
31
+ the_token = token
29
32
  Class.new(klass) do |c|
30
33
  c.uses_api the_api
34
+ c.api_token the_token
31
35
  c.element_name name.to_s.underscore.to_sym
32
36
  c.collection_path klass.collection_path
33
37
  c.resource_path klass.resource_path
@@ -42,5 +46,13 @@ module Redmine
42
46
  resource(:issue)
43
47
  end
44
48
 
49
+ def uploads
50
+ resource(:upload)
51
+ end
52
+
53
+ def time_entries
54
+ resource(:time_entry)
55
+ end
56
+
45
57
  end
46
58
  end
@@ -2,12 +2,17 @@ module Redmine
2
2
  class Base
3
3
  include Her::Model
4
4
 
5
- parse_root_in_json true
5
+ include_root_in_json true
6
+ parse_root_in_json true, format: :active_model_serializers
6
7
 
7
8
  def self.element_name(name)
8
9
  @_her_root_element = name
9
10
  end
10
11
 
12
+ def self.api_token(token)
13
+ @api_token = token
14
+ end
15
+
11
16
  def self.parse(data)
12
17
  data.keys.include?(root_element) ? data[root_element] : data
13
18
  end
@@ -1,6 +1,6 @@
1
1
  module Redmine
2
2
  class Issue < Base
3
3
  collection_path "projects/:project_id/issues.xml"
4
- resource_path "projects/:project_id/issues/:id.xml"
4
+ resource_path "issues/:id.xml"
5
5
  end
6
6
  end
@@ -0,0 +1,6 @@
1
+ module Redmine
2
+ class TimeEntry < Base
3
+ collection_path "time_entries.xml"
4
+ resource_path "time_entries/:id.xml"
5
+ end
6
+ end
@@ -0,0 +1,22 @@
1
+ module Redmine
2
+ class Upload < Base
3
+ collection_path "uploads.xml"
4
+ resource_path "attachments/:id.xml"
5
+
6
+ def self.create(data)
7
+ uri = URI.parse( her_api.base_uri )
8
+ req = Net::HTTP::Post.new('/uploads.xml', initheader = {'Content-Type' => 'application/octet-stream', 'X-Redmine-API-Key' => @api_token })
9
+ req.body = data
10
+ response = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }
11
+ if response.code.to_i == 201
12
+ parser = Redmine::Middleware::XmlParser.new
13
+ data = parser.parse(response.body)
14
+ data[:data][:upload]["token"]
15
+ else
16
+ raise response.message
17
+ end
18
+ end
19
+
20
+
21
+ end
22
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "redmine-ruby"
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jan Schwenzien"]
12
- s.date = "2013-07-01"
12
+ s.date = "2013-08-01"
13
13
  s.description = "Ruby Redmine Client using Her"
14
14
  s.email = "jan@general-scripting.com"
15
15
  s.extra_rdoc_files = [
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
30
30
  "lib/redmine-ruby/issue.rb",
31
31
  "lib/redmine-ruby/middleware/xml_parser.rb",
32
32
  "lib/redmine-ruby/project.rb",
33
+ "lib/redmine-ruby/time_entry.rb",
34
+ "lib/redmine-ruby/upload.rb",
33
35
  "redmine-ruby.gemspec",
34
36
  "test/helper.rb",
35
37
  "test/test_redmine-ruby.rb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-01 00:00:00.000000000 Z
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: her
@@ -144,6 +144,8 @@ files:
144
144
  - lib/redmine-ruby/issue.rb
145
145
  - lib/redmine-ruby/middleware/xml_parser.rb
146
146
  - lib/redmine-ruby/project.rb
147
+ - lib/redmine-ruby/time_entry.rb
148
+ - lib/redmine-ruby/upload.rb
147
149
  - redmine-ruby.gemspec
148
150
  - test/helper.rb
149
151
  - test/test_redmine-ruby.rb
@@ -162,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
164
  version: '0'
163
165
  segments:
164
166
  - 0
165
- hash: -3161734950193346019
167
+ hash: 2027505479982214640
166
168
  required_rubygems_version: !ruby/object:Gem::Requirement
167
169
  none: false
168
170
  requirements: