mingle-macro-development-toolkit 1.3.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{History.txt → History} +11 -0
- data/{LICENSE.txt → LICENSE} +0 -0
- data/{README.txt → README} +4 -2
- data/Rakefile +15 -40
- data/bin/new_mingle_macro +25 -137
- data/lib/mingle_macro_development_toolkit.rb +4 -0
- data/lib/mingle_macro_development_toolkit/loaders.rb +5 -0
- data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/base.rb +19 -0
- data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/card_type_loader.rb +15 -0
- data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/card_types_loader.rb +10 -0
- data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/card_types_property_definitions_loader.rb +12 -0
- data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/project_loader.rb +16 -0
- data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/project_variables_loader.rb +10 -0
- data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/property_definition_loader.rb +16 -0
- data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/property_definitions_loader.rb +10 -0
- data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/property_values_loader.rb +10 -0
- data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/team_loader.rb +10 -0
- data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/base.rb +85 -0
- data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/card_type_loader.rb +19 -0
- data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/card_types_loader.rb +14 -0
- data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/card_types_property_definitions_loader.rb +32 -0
- data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/project_loader.rb +26 -0
- data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/project_variables_loader.rb +14 -0
- data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/property_definition_loader.rb +20 -0
- data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/property_definitions_loader.rb +14 -0
- data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/property_values_loader.rb +14 -0
- data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/team_loader.rb +14 -0
- data/templates/Rakefile +23 -0
- data/{getting_started.txt → templates/getting_started.txt} +93 -93
- data/templates/init.rb +1 -0
- data/{example → templates/lib}/macro.rb +0 -0
- data/{test/project_data → templates/test/data/exports}/macro_toolkit_test_template.mingle +0 -0
- data/{test/fixtures/sample → templates/test/data/fixtures}/card_types.yml +0 -0
- data/{test/fixtures/sample → templates/test/data/fixtures}/project_variables.yml +0 -0
- data/{test/fixtures/sample → templates/test/data/fixtures}/projects.yml +0 -0
- data/{test/fixtures/sample → templates/test/data/fixtures}/property_definitions.yml +0 -0
- data/{test/fixtures/sample → templates/test/data/fixtures}/property_type_mappings.yml +0 -0
- data/{test/fixtures/sample → templates/test/data/fixtures}/property_values.yml +0 -0
- data/{test/fixtures/sample → templates/test/data/fixtures}/users.yml +0 -0
- data/{example → templates/test/integration}/integration_test.rb +4 -5
- data/templates/test/integration/integration_test_helper.rb +23 -0
- data/templates/test/test_helper.rb +4 -0
- data/{example → templates/test/unit}/unit_test.rb +7 -7
- data/templates/test/unit/unit_test_helper.rb +13 -0
- data/test/data/exports/macro_toolkit_test_template.mingle +0 -0
- data/test/data/fixtures/card_types.yml +37 -0
- data/test/data/fixtures/project_variables.yml +7 -0
- data/test/data/fixtures/projects.yml +4 -0
- data/test/data/fixtures/property_definitions.yml +51 -0
- data/test/data/fixtures/property_type_mappings.yml +81 -0
- data/test/data/fixtures/property_values.yml +19 -0
- data/test/data/fixtures/users.yml +16 -0
- data/test/integration/integration_test_helper.rb +3 -13
- data/test/integration/{rest_loader_test.rb → restful_loaders_test.rb} +4 -4
- data/test/test_helper.rb +2 -0
- data/test/unit/{fixture_loader_test.rb → fixture_loaders_test.rb} +2 -2
- data/test/unit/unit_test_helper.rb +7 -6
- metadata +101 -100
- data/example/Rakefile +0 -6
- data/example/deploy.rake +0 -10
- data/example/init.rb +0 -10
- data/example/integration_test_helper.rb +0 -31
- data/example/unit_test_helper.rb +0 -13
- data/lib/macro_development_toolkit.rb +0 -29
- data/lib/macro_development_toolkit/mingle/card_type.rb +0 -41
- data/lib/macro_development_toolkit/mingle/card_type_property_definition.rb +0 -26
- data/lib/macro_development_toolkit/mingle/project.rb +0 -168
- data/lib/macro_development_toolkit/mingle/project_variable.rb +0 -24
- data/lib/macro_development_toolkit/mingle/property_definition.rb +0 -105
- data/lib/macro_development_toolkit/mingle/property_value.rb +0 -67
- data/lib/macro_development_toolkit/mingle/user.rb +0 -33
- data/lib/macro_development_toolkit/mingle_model_loader.rb +0 -151
- data/tasks/test.rake +0 -16
- data/test/integration/rest_loader.rb +0 -233
- data/test/unit/fixture_loader.rb +0 -109
@@ -1,67 +0,0 @@
|
|
1
|
-
module Mingle
|
2
|
-
|
3
|
-
# Copyright 2009 ThoughtWorks, Inc. All rights reserved.
|
4
|
-
class PropertyValue
|
5
|
-
|
6
|
-
def initialize(property_value)
|
7
|
-
@property_value = property_value
|
8
|
-
end
|
9
|
-
|
10
|
-
# *returns*: The display value of this value
|
11
|
-
# Use the result of this method to display this value on the UI
|
12
|
-
# For the various property types, the following are the values you can expect to see
|
13
|
-
# * Managed/Unmanaged text : The string value of the value
|
14
|
-
# * Managed/Unmanaged numeric : The numeric string representation of the value
|
15
|
-
# * Date : The list of values this property has on all cards on the project, formatted using the project date format
|
16
|
-
# * User : The name of the user
|
17
|
-
# * Formula : Either the date or the numeric value, formatted as above
|
18
|
-
# * Card : The number of the card, followed by the name of the card
|
19
|
-
def display_value
|
20
|
-
@property_value.display_value
|
21
|
-
end
|
22
|
-
|
23
|
-
# *returns*: The identifier that is used to represent this value in the database
|
24
|
-
# You will most likely not have to use this value in your macros
|
25
|
-
# For the various property types, the following are the values you can expect to see
|
26
|
-
# * Managed/Unmanaged text : The string value of the value
|
27
|
-
# * Managed/Unmanaged numeric : The numeric string representation of the value
|
28
|
-
# * Date : The canonical date format, as stored in the database
|
29
|
-
# * User : The id of the user in the database
|
30
|
-
# * Formula : Either the date or the numeric value, formatted as above
|
31
|
-
# * Card : The id of the card in the database
|
32
|
-
def db_identifier
|
33
|
-
@property_value.db_identifier
|
34
|
-
end
|
35
|
-
|
36
|
-
# *returns*: A representation of this value that is unique and representable in a URL
|
37
|
-
# Use the result of this method if in any links that you want to build to point back into Mingle
|
38
|
-
# For the various property types, the following are the values you can expect to see
|
39
|
-
# * Managed/Unmanaged text : The string value of the value
|
40
|
-
# * Managed/Unmanaged numeric : The numeric string representation of the value
|
41
|
-
# * Date : The list of values this property has on all cards on the project, formatted using the project date format
|
42
|
-
# * User : The login of the user
|
43
|
-
# * Formula : Either the date or the numeric value, formatted as above
|
44
|
-
# * Card : The number of the card, followed by the name of the card
|
45
|
-
def url_identifier
|
46
|
-
@property_value.url_identifier
|
47
|
-
end
|
48
|
-
|
49
|
-
# *returns*: The hex color code for this PropertyValue
|
50
|
-
def color
|
51
|
-
@property_value.color.gsub('#', '')
|
52
|
-
end
|
53
|
-
|
54
|
-
# *returns*: The PropertyDefinition that this value belongs to
|
55
|
-
def property_definition
|
56
|
-
@property_definition_loader.load
|
57
|
-
end
|
58
|
-
|
59
|
-
def to_s
|
60
|
-
"PropertyValue[display_value=#{display_value},db_identifier=#{db_identifier},url_identifier=#{url_identifier}]"
|
61
|
-
end
|
62
|
-
|
63
|
-
attr_writer :property_definition_loader
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Mingle
|
2
|
-
# Copyright 2009 ThoughtWorks, Inc. All rights reserved.
|
3
|
-
|
4
|
-
# A lightweight model of a user in Mingle.
|
5
|
-
class User
|
6
|
-
|
7
|
-
def initialize(full_user)
|
8
|
-
@full_user = full_user
|
9
|
-
end
|
10
|
-
|
11
|
-
# *returns*: The login of the user as configured in Mingle
|
12
|
-
def login
|
13
|
-
@full_user.login
|
14
|
-
end
|
15
|
-
|
16
|
-
# *returns*: The full name of the user as configured in Mingle
|
17
|
-
def name
|
18
|
-
@full_user.name
|
19
|
-
end
|
20
|
-
|
21
|
-
# *returns*: The version control user name of the user as configured in Mingle
|
22
|
-
def version_control_user_name
|
23
|
-
@full_user.version_control_user_name
|
24
|
-
end
|
25
|
-
|
26
|
-
# *returns*: The email address of the user as configured in Mingle
|
27
|
-
def email
|
28
|
-
@full_user.email
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
@@ -1,151 +0,0 @@
|
|
1
|
-
# Copyright 2010 ThoughtWorks, Inc. All rights reserved.
|
2
|
-
|
3
|
-
# MingleModelLoaders understand how to load a graph of lightweight objects from
|
4
|
-
# the Mingle model objects at runtime, when the custom macro is deployed into production.
|
5
|
-
module MingleModelLoaders
|
6
|
-
class Base
|
7
|
-
def initialize(project, macro_context=nil, alert_receiver=nil)
|
8
|
-
@project = project
|
9
|
-
@macro_context = macro_context
|
10
|
-
@alert_receiver = alert_receiver
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class ProjectLoader < Base
|
15
|
-
def project
|
16
|
-
@proj ||= load
|
17
|
-
end
|
18
|
-
|
19
|
-
def load
|
20
|
-
project = Mingle::Project.new(@project, :content_provider => @macro_context[:content_provider], :alert_receiver => @alert_receiver)
|
21
|
-
project.card_types_loader = CardTypesLoader.new(@project)
|
22
|
-
project.property_definitions_loader = PropertyDefinitionsLoader.new(@project)
|
23
|
-
project.team_loader = TeamLoader.new(@project)
|
24
|
-
project.project_variables_loader = ProjectVariablesLoader.new(@project)
|
25
|
-
project
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class CardTypesLoader
|
30
|
-
def initialize(project)
|
31
|
-
@project = project
|
32
|
-
end
|
33
|
-
|
34
|
-
def load
|
35
|
-
@project.with_active_project do
|
36
|
-
@project.card_types.collect do |ct|
|
37
|
-
CardTypeLoader.new(ct)
|
38
|
-
end.sort_by {|loader| loader.card_type.position}
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class CardTypeLoader
|
44
|
-
def initialize(ct)
|
45
|
-
@ct = ct
|
46
|
-
end
|
47
|
-
|
48
|
-
def card_type
|
49
|
-
@card_type ||= load
|
50
|
-
end
|
51
|
-
|
52
|
-
def load
|
53
|
-
ct = Mingle::CardType.new(@ct)
|
54
|
-
ct.card_types_property_definitions_loader = CardTypesPropertyDefinitionsLoader.new(@ct)
|
55
|
-
ct
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class PropertyDefinitionsLoader
|
60
|
-
def initialize(project)
|
61
|
-
@project = project
|
62
|
-
end
|
63
|
-
|
64
|
-
def load
|
65
|
-
@project.with_active_project do
|
66
|
-
(@project.predefined_property_definitions + @project.all_property_definitions).collect do |pd|
|
67
|
-
PropertyDefinitionLoader.new(pd)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
class PropertyDefinitionLoader
|
74
|
-
def initialize(pd)
|
75
|
-
@pd = pd
|
76
|
-
end
|
77
|
-
|
78
|
-
def property_definition
|
79
|
-
@property_definition ||= load
|
80
|
-
end
|
81
|
-
|
82
|
-
def load
|
83
|
-
pd = Mingle::PropertyDefinition.new(@pd)
|
84
|
-
pd.card_types_property_definitions_loader = CardTypesPropertyDefinitionsLoader.new(@pd)
|
85
|
-
pd.values_loader = PropertyValuesLoader.new(@pd)
|
86
|
-
pd
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
class CardTypesPropertyDefinitionsLoader
|
91
|
-
def initialize(card_type_or_property_definition)
|
92
|
-
@card_type_or_property_definition = card_type_or_property_definition
|
93
|
-
end
|
94
|
-
|
95
|
-
def load
|
96
|
-
if @card_type_or_property_definition.respond_to?(:property_type_mappings)
|
97
|
-
@card_type_or_property_definition.property_type_mappings.collect do |mapping|
|
98
|
-
ct = CardTypeLoader.new(mapping.card_type)
|
99
|
-
pd = PropertyDefinitionLoader.new(mapping.property_definition)
|
100
|
-
OpenStruct.new(:card_type => ct.load, :property_definition => pd.load)
|
101
|
-
end
|
102
|
-
else #pre_defined_property
|
103
|
-
@card_type_or_property_definition.project.with_active_project do |project|
|
104
|
-
project.card_types.collect do |card_type|
|
105
|
-
ct = CardTypeLoader.new(card_type)
|
106
|
-
pd = PropertyDefinitionLoader.new(@card_type_or_property_definition)
|
107
|
-
OpenStruct.new(:card_type => ct.load, :property_definition => pd.load)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
class PropertyValuesLoader
|
115
|
-
def initialize(property_definition)
|
116
|
-
@property_definition = property_definition
|
117
|
-
end
|
118
|
-
|
119
|
-
def load
|
120
|
-
@property_definition.light_property_values.collect do |pv|
|
121
|
-
property_value = Mingle::PropertyValue.new(pv)
|
122
|
-
property_value.property_definition_loader = PropertyDefinitionLoader.new(@property_definition)
|
123
|
-
property_value
|
124
|
-
end.compact
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
class TeamLoader
|
129
|
-
def initialize(project)
|
130
|
-
@project = project
|
131
|
-
end
|
132
|
-
|
133
|
-
def load
|
134
|
-
@project.with_active_project do
|
135
|
-
@project.users.collect { |user| Mingle::User.new(user) }
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
class ProjectVariablesLoader
|
141
|
-
def initialize(project)
|
142
|
-
@project = project
|
143
|
-
end
|
144
|
-
|
145
|
-
def load
|
146
|
-
@project.with_active_project do
|
147
|
-
@project.project_variables.collect { |plv| Mingle::ProjectVariable.new(plv) }
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
data/tasks/test.rake
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
namespace :test do
|
2
|
-
|
3
|
-
Rake::TestTask.new(:units) do |t|
|
4
|
-
t.libs << "test/unit"
|
5
|
-
t.pattern = 'test/unit/*_test.rb'
|
6
|
-
t.verbose = true
|
7
|
-
end
|
8
|
-
|
9
|
-
Rake::TestTask.new(:integration) do |t|
|
10
|
-
t.libs << "test/integration"
|
11
|
-
t.pattern = 'test/integration/*_test.rb'
|
12
|
-
t.verbose = true
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
@@ -1,233 +0,0 @@
|
|
1
|
-
#Copyright 2010 ThoughtWorks, Inc. All rights reserved.
|
2
|
-
|
3
|
-
module RESTfulLoaders
|
4
|
-
|
5
|
-
class RemoteError < StandardError
|
6
|
-
def self.parse(response_body)
|
7
|
-
Hash.from_xml(response_body)['errors'].delete("error")
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
module LoaderHelper
|
12
|
-
|
13
|
-
def extract(key, container)
|
14
|
-
container[key] ? container[key][key.singularize] : []
|
15
|
-
end
|
16
|
-
|
17
|
-
def get(resource)
|
18
|
-
url = URI.parse(resource)
|
19
|
-
get_request = Net::HTTP::Get.new(url.request_uri)
|
20
|
-
get_request.basic_auth(url.user, url.password)
|
21
|
-
response = Net::HTTP.start(url.host, url.port) { |http| http.request(get_request) }
|
22
|
-
if response.code.to_s != "200"
|
23
|
-
raise RemoteError, RemoteError.parse(response.body)
|
24
|
-
end
|
25
|
-
Hash.from_xml(response.body)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class MqlExecutor < SimpleDelegator
|
30
|
-
include LoaderHelper
|
31
|
-
|
32
|
-
def initialize(resource, error_handler, delegator)
|
33
|
-
super(delegator)
|
34
|
-
@uri = URI.parse(resource)
|
35
|
-
@error_handler = error_handler
|
36
|
-
@version = /(\/api\/([^\/]*))\//.match(@uri.request_uri)[2]
|
37
|
-
end
|
38
|
-
|
39
|
-
def execute_mql(mql)
|
40
|
-
from_xml_data(get(url_for(:action => "execute_mql", :query => "mql=#{mql}")))
|
41
|
-
rescue => e
|
42
|
-
@error_handler.alert(e.message)
|
43
|
-
[]
|
44
|
-
end
|
45
|
-
|
46
|
-
def can_be_cached?(mql)
|
47
|
-
from_xml_data(get(url_for(:action => "can_be_cached", :query => "mql=#{mql}")))
|
48
|
-
rescue => e
|
49
|
-
@error_handler.alert(e.message)
|
50
|
-
[]
|
51
|
-
end
|
52
|
-
|
53
|
-
def format_number_with_project_precision(number)
|
54
|
-
from_xml_data(get(url_for(:action => "format_number_to_project_precision", :query => "number=#{number}")))
|
55
|
-
rescue => e
|
56
|
-
@error_handler.alert(e.message)
|
57
|
-
[]
|
58
|
-
end
|
59
|
-
|
60
|
-
def format_date_with_project_date_format(date)
|
61
|
-
from_xml_data(get(url_for(:action => "format_string_to_date_format", :query => "date=#{date}")))
|
62
|
-
rescue => e
|
63
|
-
@error_handler.alert(e.message)
|
64
|
-
[]
|
65
|
-
end
|
66
|
-
|
67
|
-
def url_for(params)
|
68
|
-
relative_path = URI.escape("/api/#{@version}/projects/#{identifier}/cards/#{params[:action]}.xml?#{params[:query]}")
|
69
|
-
@uri.merge(relative_path).to_s
|
70
|
-
end
|
71
|
-
|
72
|
-
def from_xml_data(data)
|
73
|
-
if data.is_a?(Hash) && data.keys.size == 1
|
74
|
-
from_xml_data(data.values.first)
|
75
|
-
else
|
76
|
-
data
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
class ProjectLoader
|
82
|
-
include LoaderHelper
|
83
|
-
|
84
|
-
def initialize(resource, error_handler)
|
85
|
-
@resource = resource
|
86
|
-
@error_handler = error_handler
|
87
|
-
end
|
88
|
-
|
89
|
-
def project
|
90
|
-
@project ||= load
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
|
95
|
-
def load
|
96
|
-
proj = OpenStruct.new(get(@resource)).project
|
97
|
-
project = MqlExecutor.new(@resource, @error_handler, Mingle::Project.new(OpenStruct.new(proj), nil))
|
98
|
-
project.card_types_loader = CardTypesLoader.new(proj)
|
99
|
-
project.property_definitions_loader = PropertyDefinitionsLoader.new(proj)
|
100
|
-
project.team_loader = TeamLoader.new(proj)
|
101
|
-
project.project_variables_loader = ProjectVariablesLoader.new(proj)
|
102
|
-
project
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
class CardTypesLoader
|
108
|
-
include LoaderHelper
|
109
|
-
|
110
|
-
def initialize(project)
|
111
|
-
@project = project
|
112
|
-
end
|
113
|
-
|
114
|
-
def load
|
115
|
-
extract('card_types', @project).collect { |ct| CardTypeLoader.new(@project, ct) }.sort_by { |loader| loader.card_type.position }
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
class CardTypeLoader
|
120
|
-
|
121
|
-
def initialize(project, ct)
|
122
|
-
@project = project
|
123
|
-
@ct = ct
|
124
|
-
end
|
125
|
-
|
126
|
-
def card_type
|
127
|
-
@card_type ||= load
|
128
|
-
end
|
129
|
-
|
130
|
-
def load
|
131
|
-
card_type = Mingle::CardType.new(OpenStruct.new(@ct))
|
132
|
-
card_type.card_types_property_definitions_loader = CardTypesPropertyDefinitionsLoader.new(@project, 'card_type_id' => @ct['id'])
|
133
|
-
card_type
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
class PropertyDefinitionsLoader
|
138
|
-
include LoaderHelper
|
139
|
-
|
140
|
-
def initialize(project)
|
141
|
-
@project = project
|
142
|
-
end
|
143
|
-
|
144
|
-
def load
|
145
|
-
extract('property_definitions', @project).collect { |pd| PropertyDefinitionLoader.new(@project, pd) }
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
class PropertyDefinitionLoader
|
150
|
-
def initialize(project, pd)
|
151
|
-
@project = project
|
152
|
-
@pd = pd
|
153
|
-
end
|
154
|
-
|
155
|
-
def property_definition
|
156
|
-
@property_definition ||= load
|
157
|
-
end
|
158
|
-
|
159
|
-
def load
|
160
|
-
@property_definition = Mingle::PropertyDefinition.new(OpenStruct.new(@pd))
|
161
|
-
@property_definition.card_types_property_definitions_loader = CardTypesPropertyDefinitionsLoader.new(@project, 'property_definition_id' => @pd['id'])
|
162
|
-
@property_definition.values_loader = PropertyValuesLoader.new(@pd)
|
163
|
-
@property_definition
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
class PropertyValuesLoader
|
168
|
-
include LoaderHelper
|
169
|
-
|
170
|
-
def initialize(property_definition)
|
171
|
-
@property_definition = property_definition
|
172
|
-
end
|
173
|
-
|
174
|
-
def load
|
175
|
-
extract('values', @property_definition).collect {|value| Mingle::PropertyValue.new(OpenStruct.new(value))}
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
class CardTypesPropertyDefinitionsLoader
|
181
|
-
include LoaderHelper
|
182
|
-
|
183
|
-
def initialize(project, params)
|
184
|
-
@project = project
|
185
|
-
@params = params
|
186
|
-
end
|
187
|
-
|
188
|
-
def load
|
189
|
-
mappings = extract('card_types', @project).collect do |card_type|
|
190
|
-
mapping = card_type['card_types_property_definitions'].values
|
191
|
-
end.flatten
|
192
|
-
|
193
|
-
pds = extract('property_definitions', @project)
|
194
|
-
cts = extract('card_types', @project)
|
195
|
-
mappings.collect do |mapping|
|
196
|
-
if (match?(mapping))
|
197
|
-
pd = pds.find { |pd| pd['id'] && pd['id'] == mapping['property_definition_id'] }
|
198
|
-
ct = cts.find { |ct| ct['id'] == mapping['card_type_id'] }
|
199
|
-
OpenStruct.new(:card_type => CardTypeLoader.new(@project, ct).load, :property_definition => PropertyDefinitionLoader.new(@project, pd).load)
|
200
|
-
end
|
201
|
-
end.compact
|
202
|
-
end
|
203
|
-
|
204
|
-
private
|
205
|
-
def match?(mapping)
|
206
|
-
@params.all? { |key, value| value == mapping[key] }
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
class TeamLoader
|
211
|
-
include LoaderHelper
|
212
|
-
|
213
|
-
def initialize(project)
|
214
|
-
@project = project
|
215
|
-
end
|
216
|
-
|
217
|
-
def load
|
218
|
-
(extract('users', @project) || []).collect{ |user| Mingle::User(OpenStruct.new(user))}
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
class ProjectVariablesLoader
|
223
|
-
include LoaderHelper
|
224
|
-
|
225
|
-
def initialize(project)
|
226
|
-
@project = project
|
227
|
-
end
|
228
|
-
|
229
|
-
def load
|
230
|
-
extract('project_variables', @project).collect {|pv| Mingle::ProjectVariable.new(OpenStruct.new(pv))}
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|