ecom_core 1.0.4
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/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +24 -0
- data/app/controllers/concerns/ecom/core/lookupable.rb +44 -0
- data/app/controllers/concerns/ecom/core/resource_typeable.rb +43 -0
- data/app/controllers/ecom/core/application_controller.rb +7 -0
- data/app/controllers/ecom/core/crew_types_controller.rb +7 -0
- data/app/controllers/ecom/core/equipment_types_controller.rb +7 -0
- data/app/controllers/ecom/core/material_types_controller.rb +7 -0
- data/app/models/ecom/core/application_module.rb +7 -0
- data/app/models/ecom/core/application_record.rb +7 -0
- data/app/models/ecom/core/crew.rb +14 -0
- data/app/models/ecom/core/crew_time.rb +10 -0
- data/app/models/ecom/core/crew_type.rb +6 -0
- data/app/models/ecom/core/currency.rb +7 -0
- data/app/models/ecom/core/equipment_type.rb +6 -0
- data/app/models/ecom/core/lookup.rb +7 -0
- data/app/models/ecom/core/material_type.rb +6 -0
- data/app/models/ecom/core/menu.rb +10 -0
- data/app/models/ecom/core/overtime_type.rb +6 -0
- data/app/models/ecom/core/product_type.rb +10 -0
- data/app/models/ecom/core/project.rb +15 -0
- data/app/models/ecom/core/resource_type.rb +9 -0
- data/app/models/ecom/core/stakeholder.rb +11 -0
- data/app/models/ecom/core/stakeholder_type.rb +7 -0
- data/app/models/ecom/core/task.rb +10 -0
- data/app/models/ecom/core/task_template.rb +34 -0
- data/app/models/ecom/core/task_template_type.rb +7 -0
- data/app/models/ecom/core/user.rb +18 -0
- data/app/models/ecom/core/user_role.rb +12 -0
- data/app/models/ecom/core/work_component.rb +14 -0
- data/app/models/ecom/core/work_component_template.rb +11 -0
- data/app/models/ecom/core/work_product.rb +70 -0
- data/app/models/ecom/core/work_product_template.rb +14 -0
- data/app/serializers/ecom/core/lookup_serializer.rb +8 -0
- data/app/serializers/ecom/core/resource_type_serializer.rb +8 -0
- data/config/database.ci.yml +12 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20190101112620_create_ecom_core_lookups.rb +10 -0
- data/db/migrate/20191119010518_create_ecom_core_task_template_types.rb +13 -0
- data/db/migrate/20191119012030_create_ecom_core_task_templates.rb +15 -0
- data/db/migrate/20191119013236_create_ecom_core_work_product_templates.rb +15 -0
- data/db/migrate/20191119144141_create_ecom_core_stakeholder_types.rb +10 -0
- data/db/migrate/20191119144618_create_ecom_core_stakeholders.rb +19 -0
- data/db/migrate/20191119145711_create_ecom_core_resource_types.rb +15 -0
- data/db/migrate/20191201131341_create_ecom_core_product_types.rb +14 -0
- data/db/migrate/20191201134420_create_ecom_core_work_component_templates.rb +23 -0
- data/db/migrate/20191201145816_create_ecom_core_currencies.rb +10 -0
- data/db/migrate/20191201145848_create_ecom_core_projects.rb +34 -0
- data/db/migrate/20191202103735_create_ecom_core_tasks.rb +17 -0
- data/db/migrate/20191202105355_create_task_templates_resource_types.rb +16 -0
- data/db/migrate/20191202220752_create_ecom_core_application_modules.rb +10 -0
- data/db/migrate/20191202220832_create_ecom_core_users.rb +24 -0
- data/db/migrate/20191202220953_create_ecom_core_user_roles.rb +22 -0
- data/db/migrate/20191202221423_create_ecom_core_menus.rb +25 -0
- data/db/migrate/20191202235434_create_ecom_core_work_products.rb +35 -0
- data/db/migrate/20191206104247_create_ecom_core_work_components.rb +30 -0
- data/db/migrate/20191225100054_create_ecom_core_crews.rb +17 -0
- data/db/migrate/20191225211712_create_ecom_core_crew_times.rb +17 -0
- data/lib/ecom/core.rb +4 -0
- data/lib/ecom/core/engine.rb +25 -0
- data/lib/ecom/core/version.rb +5 -0
- data/lib/ecom_core.rb +5 -0
- data/lib/tasks/ecom_core_tasks.rake +4 -0
- data/spec/factories/ecom/core/application_modules.rb +6 -0
- data/spec/factories/ecom/core/crew_times.rb +10 -0
- data/spec/factories/ecom/core/crew_types.rb +5 -0
- data/spec/factories/ecom/core/crews.rb +12 -0
- data/spec/factories/ecom/core/currencies.rb +6 -0
- data/spec/factories/ecom/core/equipment_types.rb +5 -0
- data/spec/factories/ecom/core/lookups.rb +6 -0
- data/spec/factories/ecom/core/material_types.rb +5 -0
- data/spec/factories/ecom/core/menus.rb +9 -0
- data/spec/factories/ecom/core/overtime_types.rb +5 -0
- data/spec/factories/ecom/core/product_types.rb +7 -0
- data/spec/factories/ecom/core/projects.rb +23 -0
- data/spec/factories/ecom/core/resource_types.rb +8 -0
- data/spec/factories/ecom/core/stakeholder_types.rb +5 -0
- data/spec/factories/ecom/core/stakeholders.rb +13 -0
- data/spec/factories/ecom/core/task_template_types.rb +6 -0
- data/spec/factories/ecom/core/task_templates.rb +15 -0
- data/spec/factories/ecom/core/tasks.rb +10 -0
- data/spec/factories/ecom/core/user_roles.rb +6 -0
- data/spec/factories/ecom/core/users.rb +9 -0
- data/spec/factories/ecom/core/work_component_templates.rb +11 -0
- data/spec/factories/ecom/core/work_components.rb +18 -0
- data/spec/factories/ecom/core/work_product_templates.rb +9 -0
- data/spec/factories/ecom/core/work_products.rb +22 -0
- metadata +300 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2eec84a7dcc3c35ddfd3d6dfcdcad40816ac302ac6995b28296b3336474fc8e4
|
4
|
+
data.tar.gz: a01a7b9d66c927e4299ab9615ecb2aa0b7a6a8ae22c93f9fbe5e948308172732
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 819d09f03f844f651635bacbf267fe27e68b337431db55048daa3b639868d920d25ba3b0d7d6814af45ff23aeafd014749a5dbe21f60310f2252676748426019
|
7
|
+
data.tar.gz: d776a777a0f7691f0561fcaf561a9518b594004bdc5ff5f43b54b14ddddacc4f3c4709fa7b66b23f50674a6eb64c59a8e2d8f7138c178f0cf3b4385eac944c26
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 Henock L.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Ecom Core
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'ecom_core'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install ecom_model
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'EcomCore'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
require 'rspec/core/rake_task'
|
24
|
+
RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
module Lookupable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
before_action :set_clazz
|
8
|
+
end
|
9
|
+
|
10
|
+
def index
|
11
|
+
render json: ResourceTypeSerializer.new(@clazz.all)
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
lookup = @clazz.new(lookup_params)
|
16
|
+
if lookup.save
|
17
|
+
render json: LookupSerializer.new(lookup), status: :created
|
18
|
+
else
|
19
|
+
render json: { success: false, errors: lookup.errors }, status: :unprocessable_entity
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
lookup = @clazz.find(params[:id])
|
25
|
+
if lookup.update(lookup_params)
|
26
|
+
render json: LookupSerializer.new(lookup)
|
27
|
+
else
|
28
|
+
render json: { success: false, errors: lookup.errors }, status: :unprocessable_entity
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def set_clazz
|
36
|
+
@clazz = "Ecom::Core::#{controller_name.classify}".constantize
|
37
|
+
end
|
38
|
+
|
39
|
+
def lookup_params
|
40
|
+
params.require(:lookup).permit(:name)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
module ResourceTypeable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
before_action :set_clazz
|
8
|
+
end
|
9
|
+
|
10
|
+
def index
|
11
|
+
render json: ResourceTypeSerializer.new(@clazz.all)
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
resource_type = @clazz.new(resource_type_params)
|
16
|
+
if resource_type.save
|
17
|
+
render json: ResourceTypeSerializer.new(resource_type), status: :created
|
18
|
+
else
|
19
|
+
render json: { success: false, errors: resource_type.errors }, status: :unprocessable_entity
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
resource_type = @clazz.find(params[:id])
|
25
|
+
if resource_type.update(resource_type_params)
|
26
|
+
render json: ResourceTypeSerializer.new(resource_type)
|
27
|
+
else
|
28
|
+
render json: { success: false, errors: resource_type.errors }, status: :unprocessable_entity
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def set_clazz
|
35
|
+
@clazz = "Ecom::Core::#{controller_name.classify}".constantize
|
36
|
+
end
|
37
|
+
|
38
|
+
def resource_type_params
|
39
|
+
params.require(:resource_type).permit(:code, :name, :base_unit)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class Crew < ApplicationRecord
|
4
|
+
PERMANENT = 'Permanent'.freeze
|
5
|
+
TEMPORARY = 'Temporary'.freeze
|
6
|
+
|
7
|
+
belongs_to :crew_type
|
8
|
+
|
9
|
+
validates :name, :qualification, presence: true
|
10
|
+
validates :wage, presence: true, if: ->(o) { o.employment == PERMANENT }
|
11
|
+
validates :wage, absence: true, if: ->(o) { o.employment == TEMPORARY }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class Project < ApplicationRecord
|
4
|
+
belongs_to :employer, class_name: 'Ecom::Core::Stakeholder'
|
5
|
+
belongs_to :contractor, class_name: 'Ecom::Core::Stakeholder'
|
6
|
+
belongs_to :consultant, class_name: 'Ecom::Core::Stakeholder'
|
7
|
+
belongs_to :project_manager, class_name: 'Ecom::Core::Stakeholder'
|
8
|
+
belongs_to :task_template
|
9
|
+
belongs_to :currency
|
10
|
+
|
11
|
+
validates :name, :location, :contract_number, :date_contract_signed, :commencement_date, :completion_date,
|
12
|
+
:contract_amount, :advance_payment, :retention, presence: true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class TaskTemplate < ApplicationRecord
|
4
|
+
has_ancestry
|
5
|
+
|
6
|
+
belongs_to :task_template_type
|
7
|
+
has_one :work_product_template
|
8
|
+
has_and_belongs_to_many :resource_types, join_table: 'ecom_core_task_templates_resource_types'
|
9
|
+
|
10
|
+
validates :name, :code, presence: true
|
11
|
+
validates :code, uniqueness: true
|
12
|
+
delegate(:name, to: :task_template_type, prefix: true)
|
13
|
+
|
14
|
+
def full_name
|
15
|
+
parent_name = parent&.name
|
16
|
+
return name unless parent_name
|
17
|
+
|
18
|
+
"#{name} - #{parent_name}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def crew_types
|
22
|
+
resource_types.where(type: 'Ecom::Core::CrewType')
|
23
|
+
end
|
24
|
+
|
25
|
+
def material_types
|
26
|
+
resource_types.where(type: 'Ecom::Core::MaterialType')
|
27
|
+
end
|
28
|
+
|
29
|
+
def equipment_types
|
30
|
+
resource_types.where(type: 'Ecom::Core::EquipmentType')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class User < ApplicationRecord
|
4
|
+
has_secure_password
|
5
|
+
|
6
|
+
has_and_belongs_to_many :user_roles, join_table: 'ecom_core_users_user_roles'
|
7
|
+
|
8
|
+
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i.freeze
|
9
|
+
validates :first_name, :last_name, :active, presence: true
|
10
|
+
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false }
|
11
|
+
validates :password, length: { minimum: 6 }
|
12
|
+
|
13
|
+
def full_name
|
14
|
+
"#{first_name} #{last_name}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|