central-support 0.9.0 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 451d424f9bc9a13d968d8eade8c6a63552cb6bed
4
- data.tar.gz: 5302040325454b5352264f0a1391612c8c205f87
3
+ metadata.gz: b807d80bc1d56b7ba93e9d9d70620ff541376464
4
+ data.tar.gz: 6e905a80da91e07e7720baaca0bb2dbdcef133e0
5
5
  SHA512:
6
- metadata.gz: 662a9c310d13e5774305c3f1f0b5e1b316c769c0e0fc867e8e2d9431de11025f174b558a901c77e1842d1b59759b9f8ee79d9c92d47a355f6eb6fa4e64b72a35
7
- data.tar.gz: 03d2b03f614ea4b32d5ac53a48e2c0802abdadd177f607bb7b0b53b79a8f61385e79953605caf1961a318a84343a9add473b2c4fb196275953af49017ef9114f
6
+ metadata.gz: b60fd25879c78493df31d9adfca47faf4d638766fa14fa402363660b141606dfd7ac0f750b22c6dc6196d110f881fb88f351dd52721f7302dd5843d1bca177ea
7
+ data.tar.gz: 2f7dc5ec2905e4f6b130902b40913d240e1ce9a9824af72414c8337b75558c018495645ce64d98a18d0e41e3d4c992b22b696c5602b41e43a10850e94af2160a
@@ -3,6 +3,9 @@ language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
5
  - 2.3.1
6
+ services:
7
+ - postgresql
8
+
6
9
  before_install: gem install bundler -v 1.12.5
7
10
 
8
11
  before_script:
@@ -1,21 +1,165 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 TODO: Write your name
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.md CHANGED
@@ -32,6 +32,10 @@ They are all models that exist in Central and they must also follow a specific d
32
32
 
33
33
  If you want to use this library in another application, refer to the `spec/support/rails_app/` so you know exactly how your new app should look like.
34
34
 
35
+ The application that links against this library must add the main models manually: Team, User, Project, Story, Note, Activity, and the many-to-many relationships, Membership, Enrollment, and Ownership. Again, refer to the spec dummy app example on how to do that.
36
+
37
+ This gem is not intended to have generators of any kind, just easily includable modules (Concerns), and helper libraries for the core of Central.
38
+
35
39
  ## Development
36
40
 
37
41
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -45,5 +49,5 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Codemi
45
49
 
46
50
  ## License
47
51
 
48
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
52
+ The gem is available as open source under the terms of the [LGPL License](https://www.gnu.org/licenses/lgpl-3.0.en.html).
49
53
 
@@ -23,8 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_runtime_dependency "activesupport", "~> 3.2"
27
- spec.add_runtime_dependency "activerecord", "~> 3.2"
26
+ spec.add_runtime_dependency "activesupport", ">= 3.2"
27
+ spec.add_runtime_dependency "activerecord", ">= 3.2"
28
28
  spec.add_runtime_dependency 'enumerize', "~> 2.0"
29
29
  spec.add_runtime_dependency 'transitions', "~> 0.1.9"
30
+ spec.add_runtime_dependency 'calyx', "~> 0.12.1"
30
31
  end
@@ -1,15 +1,17 @@
1
1
  require 'csv'
2
+ require 'enumerize'
3
+ require 'transitions'
4
+ require 'active_record/transitions'
5
+ require 'active_support'
6
+ require 'active_support/concern'
7
+ require 'active_support/core_ext/numeric/time'
8
+ require 'active_model'
2
9
 
3
10
  require "central/support/version"
4
11
  require "central/support/iteration_service"
5
12
  require "central/support/iteration"
6
13
  require "central/support/mattermost"
7
14
 
8
- require 'enumerize'
9
- require 'transitions'
10
- require 'active_record/transitions'
11
- require 'active_support/concern'
12
-
13
15
  require 'central/support/validators/belongs_to_project_validator'
14
16
  require 'central/support/validators/estimate_validator'
15
17
  require 'central/support/validators/changed_validator'
@@ -19,6 +21,7 @@ require 'central/support/concerns/project_concern'
19
21
  require 'central/support/concerns/user_concern'
20
22
  require 'central/support/concerns/team_concern'
21
23
  require 'central/support/concerns/activity_concern'
24
+ require 'central/support/concerns/integration_concern'
22
25
 
23
26
  # Ccompatibility mode for drop-in replacement into Central
24
27
  # TODO: must remove this after the migration from Central is complete
@@ -14,10 +14,53 @@ module Central
14
14
  }
15
15
  end
16
16
 
17
+ def merge_story!(activity)
18
+ return if subject_type != 'Story' # story only
19
+ return if subject_id != activity.subject_id # only merge the exact same story change
20
+ return if updated_at > activity.updated_at # only merge from future changes
21
+ return if activity.subject_changes.blank?
22
+
23
+ self.subject_changes = {} if self.subject_changes.nil?
24
+ self.action = activity.action
25
+
26
+ activity.subject_changes.keys.each do |key|
27
+ if subject_changes[key]
28
+ self.subject_changes[key][-1] = activity.subject_changes[key][-1]
29
+ else
30
+ self.subject_changes[key] = activity.subject_changes[key]
31
+ end
32
+ if self.subject_changes[key].first == self.subject_changes[key].last
33
+ self.subject_changes.delete(key)
34
+ end
35
+ end
36
+ end
37
+
38
+ def decorate
39
+ self
40
+ end
41
+
17
42
  module ClassMethods
18
43
  def fetch_polymorphic(ids, since)
19
- stories = where("subject_type in ('Project', 'Story')").includes(:user, :subject).projects(ids).since(since).to_a
20
- stories + where("subject_type in ('Note', 'Task')").includes(:user, subject: [:story]).projects(ids).since(since).to_a
44
+ stories = where("subject_type in ('Project', 'Story')").
45
+ includes(:user, :subject).
46
+ projects(ids).
47
+ since(since).to_a
48
+ stories += where("subject_type in ('Note', 'Task')").
49
+ includes(:user, subject: [:story]).
50
+ projects(ids).
51
+ since(since).to_a
52
+ stories = stories.group_by { |activity| activity.subject_id }
53
+
54
+ [].tap do |new_activities|
55
+ stories.values.each do |activities|
56
+ sub_list = activities.sort_by { |story| story.updated_at }
57
+ first_story = sub_list.shift
58
+ while sub_list.size > 0
59
+ first_story.merge_story!(sub_list.shift)
60
+ end
61
+ new_activities << first_story unless first_story.subject_changes.empty?
62
+ end
63
+ end
21
64
  end
22
65
 
23
66
  def grouped_activities(allowed_projects, since)
@@ -0,0 +1,16 @@
1
+ module Central
2
+ module Support
3
+ module IntegrationConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ VALID_INTEGRATIONS = ['mattermost']
8
+
9
+ belongs_to :project
10
+ validates :project, presence: true
11
+ validates :kind, inclusion: { in: VALID_INTEGRATIONS }, presence: true
12
+ validates :data, presence: true
13
+ end
14
+ end
15
+ end
16
+ end
@@ -5,6 +5,8 @@ module Central
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
+ has_many :integrations, dependent: :destroy
9
+
8
10
  has_many :ownerships
9
11
  has_many :teams, through: :ownerships
10
12
 
@@ -5,8 +5,14 @@ module Central
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
+ ROLES = %w(manager developer guest).freeze
9
+
8
10
  validates :name, :username, :initials, presence: true
9
11
  validates :username, uniqueness: true
12
+
13
+ extend Enumerize
14
+ extend ActiveModel::Naming
15
+ enumerize :role, in: ROLES
10
16
  end
11
17
  end
12
18
  end
@@ -158,7 +158,9 @@ module Central
158
158
  current_iteration = Iteration.new(self, current_iteration_number, velocity_value)
159
159
  backlog_iteration = Iteration.new(self, current_iteration_number + 1, velocity_value)
160
160
  iterations = [current_iteration, backlog_iteration]
161
- @backlog.each do |story|
161
+ @backlog.
162
+ select { |story| story.column != '#chilly_bin' }.
163
+ each do |story|
162
164
  if current_iteration.can_take_story?(story)
163
165
  current_iteration << story
164
166
  else
@@ -3,6 +3,23 @@ require "uri"
3
3
 
4
4
  module Central
5
5
  module Support
6
+ module MattermostHelper
7
+ def send_mattermost(integration, message)
8
+ Central::Support::Mattermost.send(real_private_uri(integration.data['private_uri'] ),
9
+ integration.data['channel'],
10
+ integration.data['bot_username'],
11
+ message)
12
+ end
13
+
14
+ private def real_private_uri(private_uri)
15
+ if private_uri.starts_with? "INTEGRATION_URI"
16
+ ENV[private_uri]
17
+ else
18
+ private_uri
19
+ end
20
+ end
21
+ end
22
+
6
23
  class Mattermost
7
24
  def self.send(private_uri, project_channel, bot_username, message)
8
25
  Mattermost.new(private_uri, project_channel, bot_username).send(message)
@@ -1,5 +1,5 @@
1
1
  module Central
2
2
  module Support
3
- VERSION = "0.9.0"
3
+ VERSION = "0.9.2"
4
4
  end
5
5
  end
@@ -0,0 +1,22 @@
1
+ require 'securerandom'
2
+ require 'rails/generators'
3
+ require 'rails/generators/base'
4
+ require 'rails/generators/active_record'
5
+
6
+ module Central
7
+ module Generators
8
+ class InstallGenerator < Rails::Generators::Base
9
+ include ActiveRecord::Generators::Migration
10
+
11
+ source_root File.expand_path("../templates", __FILE__)
12
+
13
+ def create_migrations
14
+ Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
15
+ name = File.basename(filepath)
16
+ migration_template "migrations/#{name}", "db/migrate/#{name}", skip: true
17
+ sleep 1
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ class AddRoleFieldToUsers < ActiveRecord::Migration
2
+ def change
3
+ add_column :users, :role, :string, null: false, default: 'developer'
4
+ end
5
+ end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: central-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Akita
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-20 00:00:00.000000000 Z
11
+ date: 2016-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.1.9
69
+ - !ruby/object:Gem::Dependency
70
+ name: calyx
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.12.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.12.1
69
83
  description: Extraction of part of the intelligence behind Central
70
84
  email:
71
85
  - boss@akitaonrails.com
@@ -89,6 +103,7 @@ files:
89
103
  - lib/central/support/concerns/activity_concern/callbacks.rb
90
104
  - lib/central/support/concerns/activity_concern/scopes.rb
91
105
  - lib/central/support/concerns/activity_concern/validations.rb
106
+ - lib/central/support/concerns/integration_concern.rb
92
107
  - lib/central/support/concerns/project_concern.rb
93
108
  - lib/central/support/concerns/project_concern/associations.rb
94
109
  - lib/central/support/concerns/project_concern/attributes.rb
@@ -119,6 +134,8 @@ files:
119
134
  - lib/central/support/validators/changed_validator.rb
120
135
  - lib/central/support/validators/estimate_validator.rb
121
136
  - lib/central/support/version.rb
137
+ - lib/generators/central/install_generator.rb
138
+ - lib/generators/central/templates/migrations/add_role_field_to_users.rb
122
139
  homepage: https://github.com/Codeminer-42/central-support
123
140
  licenses:
124
141
  - MIT
@@ -139,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
156
  version: '0'
140
157
  requirements: []
141
158
  rubyforge_project:
142
- rubygems_version: 2.6.6
159
+ rubygems_version: 2.5.1
143
160
  signing_key:
144
161
  specification_version: 4
145
162
  summary: Support library for the Central project