redmine 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Rakefile +8 -0
- data/lib/redmine.rb +34 -0
- data/lib/redmine/base.rb +28 -0
- data/lib/redmine/configuration.rb +9 -0
- data/lib/redmine/exception.rb +19 -0
- data/lib/redmine/issue.rb +14 -0
- data/lib/redmine/version.rb +7 -0
- data/redmine.gemspec +15 -0
- data/test/config.yml.example +2 -0
- data/test/test_rest_redmine.rb +48 -0
- metadata +75 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 92373ffdabbf384251c0dd9fc51593bfdf58ce25
|
4
|
+
data.tar.gz: 016c94bd9f206c1327928fc15c5f0a7b8376f865
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2cd22dc09bd37738a0db25c59de607f256abe5d2c9a6cd021918136a786e4e4a68fe2e06539492ffd4a8b157eee7551d3bbace7227f68a4b63630d07c15c673b
|
7
|
+
data.tar.gz: 7e28d9430230e7959d07fd27160c112ce4a63ed1fe2e1905076ee321e0f65c385599902bfd25b104d2ff64971aab562f0e6289eae6e972c14fed5162eb3e2c22
|
data/.gitignore
ADDED
data/Rakefile
ADDED
data/lib/redmine.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'active_resource'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
require 'redmine/version'
|
5
|
+
require 'redmine/exception'
|
6
|
+
require 'redmine/configuration'
|
7
|
+
require 'redmine/base'
|
8
|
+
require 'redmine/issue'
|
9
|
+
|
10
|
+
module Redmine
|
11
|
+
class << self
|
12
|
+
attr_writer :configuration, :log
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configuration
|
16
|
+
@configuration ||= Configuration.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.configure
|
20
|
+
yield(configuration)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.create_logger
|
24
|
+
@logger = Logger.new(STDOUT)
|
25
|
+
@logger.level = Logger::WARN
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.logger
|
29
|
+
@logger
|
30
|
+
end
|
31
|
+
|
32
|
+
Redmine.create_logger
|
33
|
+
ActiveResource::Base.include_root_in_json = true
|
34
|
+
end
|
data/lib/redmine/base.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Redmine
|
2
|
+
class Base < ActiveResource::Base
|
3
|
+
cattr_accessor :static_headers
|
4
|
+
self.static_headers = headers
|
5
|
+
|
6
|
+
DEFAULTS = {}
|
7
|
+
|
8
|
+
def initialize(attributes = {}, persisted = false)
|
9
|
+
self.class.site = Redmine.configuration.site
|
10
|
+
|
11
|
+
attributes.merge!(self.class::DEFAULTS)
|
12
|
+
attributes.merge!(Redmine.configuration.resources[self.class.element_name.to_sym] || {})
|
13
|
+
|
14
|
+
super(attributes, persisted)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.headers
|
18
|
+
new_headers = static_headers.clone
|
19
|
+
new_headers["X-Redmine-API-Key"] = Redmine.configuration.api_key
|
20
|
+
|
21
|
+
new_headers
|
22
|
+
end
|
23
|
+
|
24
|
+
def encode(options={})
|
25
|
+
send("to_#{self.class.format.extension}", options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Redmine
|
2
|
+
class Exception < RuntimeError
|
3
|
+
attr_accessor :response
|
4
|
+
attr_writer :message
|
5
|
+
|
6
|
+
def initialize message, response=nil
|
7
|
+
@message = message
|
8
|
+
@response = response if response
|
9
|
+
end
|
10
|
+
|
11
|
+
def message
|
12
|
+
@message || self.class.name
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
"#{self.class}: #{@message}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Redmine
|
2
|
+
class Issue < Base
|
3
|
+
schema do
|
4
|
+
integer 'project_id', 'tracker_id', 'status_id', 'priority_id', 'category_id', 'parent_issue_id', 'estimated_hours', 'done_ratio'
|
5
|
+
boolean 'is_private'
|
6
|
+
end
|
7
|
+
|
8
|
+
DEFAULTS = {
|
9
|
+
custom_fields: {},
|
10
|
+
is_private: false,
|
11
|
+
done_ratio: 0
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
data/redmine.gemspec
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path('../lib/redmine/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'redmine'
|
5
|
+
s.version = Redmine::VERSION
|
6
|
+
s.licenses = ['MIT']
|
7
|
+
s.summary = "This is for resources of redmine"
|
8
|
+
s.description = 'A simple REDMINE client, using Active Resource.'
|
9
|
+
s.authors = ["topray"]
|
10
|
+
s.email = 'topray@nowbusking.com'
|
11
|
+
s.files = `git ls-files -z`.split("\0")
|
12
|
+
s.homepage = 'https://github.com/topray/rest-redmine'
|
13
|
+
|
14
|
+
s.add_dependency('activeresource', '~> 4.0.0', '>= 4.0.0')
|
15
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'redmine'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
class RedmineTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
configuration = YAML.load_file('test/config.yml')
|
8
|
+
|
9
|
+
@api_key = configuration["api_key"]
|
10
|
+
@site = configuration["site"]
|
11
|
+
|
12
|
+
Redmine.configure do |config|
|
13
|
+
config.api_key = @api_key
|
14
|
+
config.site = @site
|
15
|
+
config.resources[:issue] = {
|
16
|
+
project_id: 1, # nowplay
|
17
|
+
tracker_id: 1, # bug
|
18
|
+
status_id: 1, # new
|
19
|
+
priority_id: 2, # normal
|
20
|
+
category_id: 1
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
@issue = Redmine::Issue.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_configuration
|
28
|
+
assert_equal @api_key, Redmine.configuration.api_key
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_init_issue
|
32
|
+
assert_equal nil, @issue.id
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_find_issue
|
36
|
+
assert_raises ActiveResource::ResourceNotFound do
|
37
|
+
issue = Redmine::Issue.find(1)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_save_issue
|
42
|
+
issue = Redmine::Issue.new({
|
43
|
+
subject: "안녕안녕"
|
44
|
+
})
|
45
|
+
|
46
|
+
assert_equal true, issue.save
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redmine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- topray
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activeresource
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 4.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 4.0.0
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 4.0.0
|
33
|
+
description: A simple REDMINE client, using Active Resource.
|
34
|
+
email: topray@nowbusking.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- ".gitignore"
|
40
|
+
- Rakefile
|
41
|
+
- lib/redmine.rb
|
42
|
+
- lib/redmine/base.rb
|
43
|
+
- lib/redmine/configuration.rb
|
44
|
+
- lib/redmine/exception.rb
|
45
|
+
- lib/redmine/issue.rb
|
46
|
+
- lib/redmine/version.rb
|
47
|
+
- redmine.gemspec
|
48
|
+
- test/config.yml.example
|
49
|
+
- test/test_rest_redmine.rb
|
50
|
+
homepage: https://github.com/topray/rest-redmine
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.4.5
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: This is for resources of redmine
|
74
|
+
test_files: []
|
75
|
+
has_rdoc:
|