backlog_jp 0.0.6
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 +43 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +1 -0
- data/TODO.md +38 -0
- data/backlog_jp.gemspec +23 -0
- data/lib/backlog_jp/_version.rb +3 -0
- data/lib/backlog_jp/client.rb +32 -0
- data/lib/backlog_jp/common.rb +101 -0
- data/lib/backlog_jp/configuration.rb +16 -0
- data/lib/backlog_jp/interface.rb +9 -0
- data/lib/backlog_jp/project/common.rb +49 -0
- data/lib/backlog_jp/project/component.rb +32 -0
- data/lib/backlog_jp/project/issue.rb +105 -0
- data/lib/backlog_jp/project/issue_type.rb +32 -0
- data/lib/backlog_jp/project/version.rb +48 -0
- data/lib/backlog_jp/project.rb +130 -0
- data/lib/backlog_jp/user.rb +0 -0
- data/lib/backlog_jp.rb +3 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d127e6f10a8f49a928418bb5ffc563ce2dccd246
|
4
|
+
data.tar.gz: 50a121f489af8b417318478fa4e9aea4c8b6e370
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eff4d3dba77ea51d3fd453f98b2c53a12e08d01c3b7124ada274c9d59d7afe3f6eb4f772a1b73c2c4e1e0292fa45cf08bd1c6728d3a1d469fbd907c3ba58b7f7
|
7
|
+
data.tar.gz: 20914d56059c701946bdddb7611cbd7a28f0e1bb7e18ca2f8ef336d911b4d240acc054326f672d98f854846bf68bc3af816e77ae59bc04bf1e0f4daf59ddff95
|
data/.gitignore
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
|
19
|
+
*.sublime-project
|
20
|
+
*.sublime-workspace
|
21
|
+
|
22
|
+
.rvmrc
|
23
|
+
vendor/bundle
|
24
|
+
|
25
|
+
/log/*
|
26
|
+
/tmp/*
|
27
|
+
/public/system/*
|
28
|
+
**.orig
|
29
|
+
rerun.txt
|
30
|
+
pickle-email-*.html
|
31
|
+
.project
|
32
|
+
|
33
|
+
### OSX ###
|
34
|
+
.DS_Store
|
35
|
+
.AppleDouble
|
36
|
+
.LSOverride
|
37
|
+
Icon
|
38
|
+
|
39
|
+
# Thumbnails
|
40
|
+
._*
|
41
|
+
|
42
|
+
run.sh
|
43
|
+
sandbox.rb
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 y13i
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# BacklogJp
|
2
|
+
|
3
|
+
A Rubyish interface for Backlog.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
* Ruby 2.0.0 or later
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'backlog_jp'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install backlog_jp
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write more usage instructions here
|
26
|
+
|
27
|
+
require "backlog_jp"
|
28
|
+
|
29
|
+
BacklogJp.configure do |config|
|
30
|
+
config.space = ENV["BACKLOG_SPACE"]
|
31
|
+
config.username = ENV["BACKLOG_USERNAME"]
|
32
|
+
config.password = ENV["BACKLOG_PASSWORD"]
|
33
|
+
end
|
34
|
+
|
35
|
+
all_projects = BacklogJp::Project.all # Array of all projects.
|
36
|
+
project = all_projects.first # A Project object.
|
37
|
+
project.issue_types # Array of project's issue types.
|
38
|
+
|
39
|
+
# etc...
|
40
|
+
# work in progress
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it ( http://github.com/y13i/backlog_jp/fork )
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/TODO.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# TODO
|
2
|
+
|
3
|
+
とりあえず作る
|
4
|
+
|
5
|
+
## まだ実装してないBacklog XMLRPC API一覧
|
6
|
+
|
7
|
+
* backlog.getUsers
|
8
|
+
* backlog.getIssue
|
9
|
+
* backlog.getIssue
|
10
|
+
* backlog.getComments
|
11
|
+
* backlog.countIssue
|
12
|
+
* backlog.findIssue
|
13
|
+
* backlog.createIssue
|
14
|
+
* backlog.updateIssue
|
15
|
+
* backlog.switchStatus
|
16
|
+
* backlog.addComment
|
17
|
+
* backlog.getTimeline
|
18
|
+
* backlog.getProjectSummary
|
19
|
+
* backlog.getProjectSummaries
|
20
|
+
* backlog.getUser
|
21
|
+
* backlog.getUserIcon
|
22
|
+
* backlog.getActivityTypes
|
23
|
+
* backlog.getStatuses
|
24
|
+
* backlog.getResolutions
|
25
|
+
* backlog.getPriorities
|
26
|
+
* backlog.getCustomFields
|
27
|
+
* backlog.getChildIssues
|
28
|
+
* backlog.admin.getUsers
|
29
|
+
* backlog.admin.addUser
|
30
|
+
* backlog.admin.updateUser
|
31
|
+
* backlog.admin.deleteUser
|
32
|
+
* backlog.admin.getProjectUsers
|
33
|
+
* backlog.admin.addProjectUser
|
34
|
+
* backlog.admin.updateProjectUsers
|
35
|
+
* backlog.admin.deleteProjectUser
|
36
|
+
* backlog.admin.addCustomField
|
37
|
+
* backlog.admin.updateCustomField
|
38
|
+
* backlog.admin.deleteCustomField
|
data/backlog_jp.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'backlog_jp/_version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "backlog_jp"
|
8
|
+
spec.version = BacklogJp::VERSION
|
9
|
+
spec.authors = ["y13i"]
|
10
|
+
spec.email = ["email@y13i.com"]
|
11
|
+
spec.summary = %q{A Rubyish interface for Backlog.}
|
12
|
+
spec.description = %q{A Rubyish, object-oriented interface for project management service Backlog's XML-RPC API.}
|
13
|
+
spec.homepage = "http://github.com/y13i/backlog_jp"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake", "~> 0"
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "xmlrpc/client"
|
2
|
+
require_relative "configuration"
|
3
|
+
|
4
|
+
module BacklogJp
|
5
|
+
# Wrapping class of Backlog's XMLRPC API.
|
6
|
+
#
|
7
|
+
# eg. XMLRPC method "backlog.createIssue" can be called as...
|
8
|
+
#
|
9
|
+
# +BacklogJp.client.create_issue summery: "Issue title", description: "Issue body"+
|
10
|
+
class Client < ::XMLRPC::Client
|
11
|
+
private
|
12
|
+
def method_missing method, *args
|
13
|
+
send :call, "backlog.#{camelize method.to_s}", *args
|
14
|
+
end
|
15
|
+
|
16
|
+
def camelize string
|
17
|
+
string.sub(/\Aadmin_/, "admin.").gsub(/_[a-z]/){|match| match.chars.last.upcase}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns a Client with configuration.
|
22
|
+
def self.client
|
23
|
+
@client ||= Client.new_from_hash(
|
24
|
+
host: "#{configuration.space}.backlog.jp",
|
25
|
+
path: "/XML-RPC",
|
26
|
+
port: 443,
|
27
|
+
use_ssl: true,
|
28
|
+
user: configuration.username,
|
29
|
+
password: configuration.password,
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require "date"
|
2
|
+
|
3
|
+
module BacklogJp::Common
|
4
|
+
def self.included klass
|
5
|
+
klass.class_eval do
|
6
|
+
class << self
|
7
|
+
private
|
8
|
+
|
9
|
+
def find_by_seed method, attributes = {}
|
10
|
+
array_response = BacklogJp.client.send method
|
11
|
+
|
12
|
+
array_response.map do |item|
|
13
|
+
array.push new_from_response item
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def cud_seed method, required_attributes, attributes = {}
|
18
|
+
require_attribute attributes, *required_attributes
|
19
|
+
new_from_response BacklogJp.client.send(method, attributes)
|
20
|
+
end
|
21
|
+
|
22
|
+
def new_from_response response
|
23
|
+
attributes = @attr_r + @attr_a
|
24
|
+
new *attributes.map{|attribute| response[attribute.to_s]}
|
25
|
+
end
|
26
|
+
|
27
|
+
def require_attribute attributes, *keys
|
28
|
+
fail ArgumentError, "#{keys.join ", "} is required." if keys.map{|key| attributes[key].nil?}.any?
|
29
|
+
end
|
30
|
+
|
31
|
+
def date_to_s attributes
|
32
|
+
attributes.each do |key, value|
|
33
|
+
attributes[key] = value.strftime "%Y%m%d" if value.is_a? Date
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def == other
|
41
|
+
eql? other
|
42
|
+
end
|
43
|
+
|
44
|
+
def eql? other
|
45
|
+
return false unless self.class == other.class
|
46
|
+
|
47
|
+
(attr_a + attr_r).all? do |attribute|
|
48
|
+
send(attribute) == other.send(attribute)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def changed? *attributes
|
53
|
+
attributes = attr_a if attributes.empty?
|
54
|
+
|
55
|
+
attributes.any? do |attribute|
|
56
|
+
attribute_changed? attribute
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def changed_attributes
|
61
|
+
attr_a.inject Hash.new do |hash, attribute|
|
62
|
+
if changed? attribute
|
63
|
+
hash.merge attribute => send(attribute)
|
64
|
+
else
|
65
|
+
hash
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def save
|
71
|
+
if changed?
|
72
|
+
saved = self.class.update attributes_to_save
|
73
|
+
@unsaved = nil
|
74
|
+
saved
|
75
|
+
else
|
76
|
+
fail "Attributes not changed."
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def attributes_to_save
|
83
|
+
changed_attributes.reject {|key, value| value.nil?}.merge id: id
|
84
|
+
end
|
85
|
+
|
86
|
+
def unsaved
|
87
|
+
@unsaved ||= self.class.find_by id: id
|
88
|
+
end
|
89
|
+
|
90
|
+
def attribute_changed? attribute
|
91
|
+
send(attribute) != unsaved.send(attribute)
|
92
|
+
end
|
93
|
+
|
94
|
+
def attr_r
|
95
|
+
self.class.instance_variable_get :@attr_r
|
96
|
+
end
|
97
|
+
|
98
|
+
def attr_a
|
99
|
+
self.class.instance_variable_get :@attr_a
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module BacklogJp
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :space, :username, :password
|
4
|
+
end
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :configuration
|
8
|
+
|
9
|
+
# Sets configuration with a block.
|
10
|
+
def configure &block
|
11
|
+
self.configuration ||= Configuration.new
|
12
|
+
yield configuration
|
13
|
+
configuration
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module BacklogJp::Project::Common
|
2
|
+
def self.included klass
|
3
|
+
klass.class_eval do
|
4
|
+
class << self
|
5
|
+
private
|
6
|
+
|
7
|
+
def find_by_seed method, attributes = {}
|
8
|
+
require_attribute attributes, :project_id
|
9
|
+
array_response = BacklogJp.client.send method, attributes[:project_id]
|
10
|
+
|
11
|
+
array_response.map do |item|
|
12
|
+
new_from_response item.merge "project_id" => attributes[:project_id]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def cud_seed method, required_attributes, attributes = {}
|
17
|
+
require_attribute attributes, *required_attributes
|
18
|
+
new_from_response BacklogJp.client.send(method, attributes).merge "project_id" => attributes[:project_id]
|
19
|
+
end
|
20
|
+
|
21
|
+
def new_from_response response
|
22
|
+
attributes = @attr_r + @attr_a << :project_id
|
23
|
+
new *attributes.map{|attribute| response[attribute.to_s]}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def destroy attributes = {}
|
30
|
+
attributes[:id] = id
|
31
|
+
attributes[:project_id] = @project_id
|
32
|
+
self.class.delete attributes
|
33
|
+
end
|
34
|
+
|
35
|
+
def issues
|
36
|
+
attributes = {project_id: @project_id}.merge self.class.to_s.gsub(/[A-Z]/) {|match| "_#{match.downcase}"}[1..-1].intern => id
|
37
|
+
BacklogJp::Project::Issue.find_by attributes
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def attributes_to_save
|
43
|
+
changed_attributes.merge id: id, project_id: @project_id
|
44
|
+
end
|
45
|
+
|
46
|
+
def unsaved
|
47
|
+
@unsaved ||= self.class.find_by(project_id: @project_id).find {|item| id == item.id}
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class BacklogJp::Project::Component
|
2
|
+
include BacklogJp::Common
|
3
|
+
include BacklogJp::Project::Common
|
4
|
+
|
5
|
+
attr_reader *@attr_r = %i[id]
|
6
|
+
attr_accessor *@attr_a = %i[name]
|
7
|
+
|
8
|
+
def initialize id, name, project_id
|
9
|
+
@id = id
|
10
|
+
@name = name
|
11
|
+
@project_id = project_id
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def find_by attributes = {}
|
16
|
+
find_by_seed :get_components, attributes
|
17
|
+
end
|
18
|
+
|
19
|
+
def create attributes = {}
|
20
|
+
cud_seed :add_component, %i[project_id name], attributes
|
21
|
+
end
|
22
|
+
|
23
|
+
def update attributes = {}
|
24
|
+
cud_seed :update_component, %i[project_id id], attributes
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete attributes = {}
|
28
|
+
require_attribute attributes, :project_id, :id
|
29
|
+
new_from_response BacklogJp.client.delete_component(attributes[:id]).merge "project_id" => attributes[:project_id]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
class BacklogJp::Project::Issue
|
2
|
+
include BacklogJp::Common
|
3
|
+
include BacklogJp::Project::Common
|
4
|
+
|
5
|
+
attr_reader *@attr_r = %i[id key url created_user_id created_on updated_on]
|
6
|
+
attr_accessor *@attr_a = %i[summery parent_issue_id description due_date start_date estimated_hours actual_hours issue_type priority resolution status components versions milestones assigner_id]
|
7
|
+
|
8
|
+
def initialize id, key, url, created_user_id, created_on, updated_on, summery, parent_issue_id, description, due_date, start_date, estimated_hours, actual_hours, issue_type, priority, resolution, status, components, versions, milestones, assigner_id
|
9
|
+
@id = id
|
10
|
+
@key = key
|
11
|
+
@url = url
|
12
|
+
@created_user_id = created_user_id
|
13
|
+
@created_on = created_on
|
14
|
+
@updated_on = updated_on
|
15
|
+
@summery = summery
|
16
|
+
@parent_issue_id = parent_issue_id
|
17
|
+
@description = description
|
18
|
+
@due_date = due_date
|
19
|
+
@start_date = start_date
|
20
|
+
@estimated_hours = estimated_hours
|
21
|
+
@actual_hours = actual_hours
|
22
|
+
@issue_type = issue_type
|
23
|
+
@priority = priority
|
24
|
+
@resolution = resolution
|
25
|
+
@status = status
|
26
|
+
@components = components
|
27
|
+
@versions = versions
|
28
|
+
@milestones = milestones
|
29
|
+
@assigner_id = assigner_id
|
30
|
+
end
|
31
|
+
|
32
|
+
class << self
|
33
|
+
def find_by attributes = {}
|
34
|
+
case attributes.keys
|
35
|
+
when ->(k){k.include? :id}
|
36
|
+
BacklogJp.client.get_issue attributes[:id]
|
37
|
+
when ->(k){k.include? :key}
|
38
|
+
BacklogJp.client.get_issue attributes[:key]
|
39
|
+
when ->(k){k.include? :project_id}
|
40
|
+
BacklogJp.client.find_issue find_issue_conditions attributes
|
41
|
+
else
|
42
|
+
raise "under construction"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def create attributes = {}
|
47
|
+
cud_seed :add_issue_type, %i[project_id name color], attributes
|
48
|
+
end
|
49
|
+
|
50
|
+
def update attributes = {}
|
51
|
+
cud_seed :update_issue_type, %i[project_id id], attributes
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def find_issue_conditions attributes = {}
|
57
|
+
attributes.inject Hash.new do |hash, (key, value)|
|
58
|
+
hash.merge case key.intern
|
59
|
+
when :project_id, :issue_type_id, :version_id, :status_id, :priority_id, :assigner_id, :created_user_id, :resolution_id
|
60
|
+
find_by_key_camelize key, value
|
61
|
+
when :parent_child_issue
|
62
|
+
find_by_parent_child_issue_seed key, value
|
63
|
+
when :created_on_min, :created_on_max, :updated_on_min, :updated_on_max, :start_date_min, :start_date_max, :due_date_min, :due_date_max
|
64
|
+
find_by_value_date_to_s key, value
|
65
|
+
when :sort
|
66
|
+
{sort: value.to_s.upcase}
|
67
|
+
when :order
|
68
|
+
find_by_order_seed key, value
|
69
|
+
else
|
70
|
+
{key => value}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def find_by_key_camelize key, value
|
76
|
+
{key.to_s.gsub(/_[a-z]/){|match| match.chars.last.upcase}.intern => value}
|
77
|
+
end
|
78
|
+
|
79
|
+
def find_by_parent_child_issue_seed key, value
|
80
|
+
{
|
81
|
+
parent_child_issue: case value
|
82
|
+
when :except_child then 1
|
83
|
+
when :child then 2
|
84
|
+
when :not_related then 3
|
85
|
+
when :parent then 4
|
86
|
+
when 1..4 then value
|
87
|
+
else fail ArgumentError
|
88
|
+
end
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def find_by_value_date_to_s key, value
|
93
|
+
{key => value.strftime("%Y%m%d")}
|
94
|
+
end
|
95
|
+
|
96
|
+
def find_by_order_seed key, value
|
97
|
+
{
|
98
|
+
order: case value
|
99
|
+
when 1, :asc, :ascend then 1
|
100
|
+
when 2, :desc, :descend then 2
|
101
|
+
end
|
102
|
+
}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class BacklogJp::Project::IssueType
|
2
|
+
include BacklogJp::Common
|
3
|
+
include BacklogJp::Project::Common
|
4
|
+
|
5
|
+
attr_reader *@attr_r = %i[id]
|
6
|
+
attr_accessor *@attr_a = %i[name color]
|
7
|
+
|
8
|
+
def initialize id, name, color, project_id
|
9
|
+
@id = id
|
10
|
+
@name = name
|
11
|
+
@color = color
|
12
|
+
@project_id = project_id
|
13
|
+
end
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def find_by attributes = {}
|
17
|
+
find_by_seed :get_issue_types, attributes
|
18
|
+
end
|
19
|
+
|
20
|
+
def create attributes = {}
|
21
|
+
cud_seed :add_issue_type, %i[project_id name color], attributes
|
22
|
+
end
|
23
|
+
|
24
|
+
def update attributes = {}
|
25
|
+
cud_seed :update_issue_type, %i[project_id id], attributes
|
26
|
+
end
|
27
|
+
|
28
|
+
def delete attributes = {}
|
29
|
+
cud_seed :delete_issue_type, %i[project_id id], attributes
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class BacklogJp::Project::Version
|
2
|
+
include BacklogJp::Common
|
3
|
+
include BacklogJp::Project::Common
|
4
|
+
|
5
|
+
attr_reader *@attr_r = %i[id]
|
6
|
+
attr_accessor *@attr_a = %i[name start_date due_date archived]
|
7
|
+
|
8
|
+
def initialize id, name, start_date, due_date, archived, project_id
|
9
|
+
@id = id
|
10
|
+
@name = name
|
11
|
+
@start_date = Date.parse start_date if start_date and start_date != ""
|
12
|
+
@due_date = Date.parse due_date if due_date and due_date != ""
|
13
|
+
@archived = archived
|
14
|
+
@project_id = project_id
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def find_by attributes = {}
|
19
|
+
require_attribute attributes, :project_id
|
20
|
+
|
21
|
+
# This API... why doesn't it return due_date and start_date?
|
22
|
+
# http://www.backlog.jp/api/method2_1.html
|
23
|
+
array_response = BacklogJp.client.get_versions attributes[:project_id]
|
24
|
+
|
25
|
+
array_response.each do |version|
|
26
|
+
version["due_date"] = version["date"]
|
27
|
+
version.delete "date"
|
28
|
+
end
|
29
|
+
|
30
|
+
array_response.inject Array.new do |array, item|
|
31
|
+
array.push new_from_response item.merge "project_id" => attributes[:project_id]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def create attributes = {}
|
36
|
+
cud_seed :add_version, %i[project_id name color], date_to_s(attributes)
|
37
|
+
end
|
38
|
+
|
39
|
+
def update attributes = {}
|
40
|
+
cud_seed :update_version, %i[project_id id], date_to_s(attributes)
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete attributes = {}
|
44
|
+
require_attribute attributes, :project_id, :id
|
45
|
+
new_from_response BacklogJp.client.delete_version(attributes[:id]).merge "project_id" => attributes[:project_id]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
class BacklogJp::Project
|
2
|
+
include BacklogJp::Common
|
3
|
+
|
4
|
+
attr_reader *@attr_r = %i[id url created_on updated_on]
|
5
|
+
attr_accessor *@attr_a = %i[name key use_parent_child_issue text_formatting_rule archived use_chart]
|
6
|
+
|
7
|
+
def initialize id, url, created_on, updated_on, name, key, use_parent_child_issue, text_formatting_rule, archived, use_chart
|
8
|
+
@id = id
|
9
|
+
@url = url
|
10
|
+
@created_on = DateTime.parse created_on if created_on
|
11
|
+
@updated_on = DateTime.parse updated_on if updated_on
|
12
|
+
@name = name
|
13
|
+
@key = key
|
14
|
+
@use_parent_child_issue = use_parent_child_issue
|
15
|
+
@text_formatting_rule = text_formatting_rule
|
16
|
+
@archived = archived
|
17
|
+
@use_chart = use_chart
|
18
|
+
end
|
19
|
+
|
20
|
+
class << self
|
21
|
+
# Returns all projects as a array.
|
22
|
+
def all
|
23
|
+
array_response = begin
|
24
|
+
BacklogJp.client.admin_get_projects
|
25
|
+
rescue
|
26
|
+
BacklogJp.client.get_projects
|
27
|
+
end
|
28
|
+
|
29
|
+
array_response.map do |project|
|
30
|
+
new_from_response project
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns a array of specified attribute from all projects.
|
35
|
+
def distinct *attributes
|
36
|
+
fail ArgumentError, "Specify at least one attribute." if attributes.empty?
|
37
|
+
|
38
|
+
all.map do |item|
|
39
|
+
if attributes.size == 1
|
40
|
+
item.send attributes.first
|
41
|
+
else
|
42
|
+
attributes.map do |attribute|
|
43
|
+
item.send attribute
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def find_by attributes = {}
|
50
|
+
new_from_response BacklogJp.client.get_project case attributes.keys
|
51
|
+
when ->(k){k.include? :id}
|
52
|
+
attributes[:id]
|
53
|
+
when ->(k){k.include? :key}
|
54
|
+
attributes[:key].to_s
|
55
|
+
else
|
56
|
+
fail ArgumentError, "Give a hash with :id (Integer) or :key (Symbol or String) as a key."
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def [] arg
|
61
|
+
case arg
|
62
|
+
when Integer then find_by id: arg
|
63
|
+
when String, Symbol then find_by key: arg.to_s
|
64
|
+
else fail ArgumentError, "Give a Integer (for id), String or Symbol (for key)."
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def create attributes = {}
|
69
|
+
cud_seed :admin_add_project, %i[key name], attributes
|
70
|
+
end
|
71
|
+
|
72
|
+
def update attributes = {}
|
73
|
+
cud_seed :admin_update_project, %i[id], attributes
|
74
|
+
end
|
75
|
+
|
76
|
+
def delete attributes = {}
|
77
|
+
require_attribute attributes, :id
|
78
|
+
new_from_response BacklogJp.client.admin_delete_project attributes[:id]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
alias_method :created_at, :created_on
|
83
|
+
alias_method :updated_at, :updated_on
|
84
|
+
|
85
|
+
def components
|
86
|
+
self.class::Component.find_by project_id: id
|
87
|
+
end
|
88
|
+
|
89
|
+
alias_method :categories, :components
|
90
|
+
|
91
|
+
def add_component attributes
|
92
|
+
attributes[:project_id] = id
|
93
|
+
self.class::Component.create attributes
|
94
|
+
end
|
95
|
+
|
96
|
+
alias_method :add_category, :add_component
|
97
|
+
alias_method :create_component, :add_component
|
98
|
+
alias_method :create_category, :add_component
|
99
|
+
|
100
|
+
def versions
|
101
|
+
self.class::Version.find_by project_id: id
|
102
|
+
end
|
103
|
+
|
104
|
+
alias_method :milestones, :versions
|
105
|
+
|
106
|
+
def add_version attributes
|
107
|
+
attributes[:project_id] = id
|
108
|
+
self.class::Version.create attributes
|
109
|
+
end
|
110
|
+
|
111
|
+
alias_method :add_milestone, :add_version
|
112
|
+
alias_method :create_version, :add_version
|
113
|
+
alias_method :create_milestone, :add_version
|
114
|
+
|
115
|
+
def issue_types
|
116
|
+
self.class::IssueType.find_by project_id: id
|
117
|
+
end
|
118
|
+
|
119
|
+
def add_issue_type attributes
|
120
|
+
attributes[:project_id] = id
|
121
|
+
self.class::IssueType.create attributes
|
122
|
+
end
|
123
|
+
|
124
|
+
alias_method :create_issue_type, :add_issue_type
|
125
|
+
|
126
|
+
def issues attributes = {}
|
127
|
+
attributes.merge project_id: id
|
128
|
+
self.class::Issue.find_by attributes
|
129
|
+
end
|
130
|
+
end
|
File without changes
|
data/lib/backlog_jp.rb
ADDED
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: backlog_jp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- y13i
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A Rubyish, object-oriented interface for project management service Backlog's
|
42
|
+
XML-RPC API.
|
43
|
+
email:
|
44
|
+
- email@y13i.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- TODO.md
|
55
|
+
- backlog_jp.gemspec
|
56
|
+
- lib/backlog_jp.rb
|
57
|
+
- lib/backlog_jp/_version.rb
|
58
|
+
- lib/backlog_jp/client.rb
|
59
|
+
- lib/backlog_jp/common.rb
|
60
|
+
- lib/backlog_jp/configuration.rb
|
61
|
+
- lib/backlog_jp/interface.rb
|
62
|
+
- lib/backlog_jp/project.rb
|
63
|
+
- lib/backlog_jp/project/common.rb
|
64
|
+
- lib/backlog_jp/project/component.rb
|
65
|
+
- lib/backlog_jp/project/issue.rb
|
66
|
+
- lib/backlog_jp/project/issue_type.rb
|
67
|
+
- lib/backlog_jp/project/version.rb
|
68
|
+
- lib/backlog_jp/user.rb
|
69
|
+
homepage: http://github.com/y13i/backlog_jp
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.2.2
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: A Rubyish interface for Backlog.
|
93
|
+
test_files: []
|