thecore_servers 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +36 -0
- data/app/assets/config/thecore_servers_manifest.js +0 -0
- data/app/models/application_record.rb +3 -0
- data/app/models/protocol.rb +17 -0
- data/app/models/server.rb +17 -0
- data/config/initializers/thecore_server_after_initialize.rb +5 -0
- data/config/locales/it.models.yml +20 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20170705071150_create_protocols.rb +14 -0
- data/db/migrate/20170705071338_create_servers.rb +20 -0
- data/db/migrate/20170718152811_add_protocol_to_protocol.rb +23 -0
- data/lib/abilities_thecore_servers_concern.rb +23 -0
- data/lib/tasks/thecore_servers_tasks.rake +4 -0
- data/lib/thecore_servers.rb +5 -0
- data/lib/thecore_servers/engine.rb +15 -0
- data/lib/thecore_servers/version.rb +3 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c12ffa462501902d56522b06916647921280ac6c
|
4
|
+
data.tar.gz: a31c59e5b2c34d6913949ffdd056088dac576eb0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '08f8a25b1bee137cee0de1708d7f17c9b020cd8f71e9a7092548bb137d296f4aad294565d58e6725f05e671e6317848cfa8799ae87a559744a6f46cf9ee5f079'
|
7
|
+
data.tar.gz: 666bffdcb0f058d730d8f8ec67845de0f28c34e535542ca109e2182b01d9cda367324c85d92f1c201ab07eead3852003dcaa182a5a687cc19c33e4f8461756b9
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Gabriele Tassoni
|
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
|
+
# ThecoreServers
|
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 'thecore_servers'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install thecore_servers
|
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](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
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 = 'ThecoreServers'
|
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("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'test'
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
32
|
+
t.verbose = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task default: :test
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Protocol < ApplicationRecord
|
2
|
+
has_many :servers, inverse_of: :protocol, dependent: :destroy
|
3
|
+
|
4
|
+
validates :name, presence: true, uniqueness: true
|
5
|
+
|
6
|
+
rails_admin do
|
7
|
+
visible false
|
8
|
+
# navigation_label I18n.t('admin.settings.label')
|
9
|
+
# navigation_icon 'fa fa-plug'
|
10
|
+
end
|
11
|
+
|
12
|
+
RailsAdmin.config do |config|
|
13
|
+
config.model self.name.underscore.capitalize.classify do
|
14
|
+
visible false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Server < ApplicationRecord
|
2
|
+
belongs_to :protocol, inverse_of: :servers
|
3
|
+
|
4
|
+
validates :address, presence: true, uniqueness: { scope: :protocol }
|
5
|
+
validates :protocol, presence: true
|
6
|
+
|
7
|
+
def self.get_default_for_scope protocol
|
8
|
+
joins(:protocol).where(protocol_default: true, protocols: {name: protocol}).order(updated_at: :desc).first
|
9
|
+
end
|
10
|
+
|
11
|
+
RailsAdmin.config do |config|
|
12
|
+
config.model self.name.underscore.capitalize.classify do
|
13
|
+
navigation_label I18n.t('admin.settings.label')
|
14
|
+
navigation_icon 'fa fa-file'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
it:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
protocol:
|
5
|
+
one: Protocollo
|
6
|
+
other: Protocolli
|
7
|
+
server: Server
|
8
|
+
attributes:
|
9
|
+
protocol:
|
10
|
+
name: Nome
|
11
|
+
description: Descrizione
|
12
|
+
servers: Server
|
13
|
+
server:
|
14
|
+
name: Nome
|
15
|
+
address: Indirizzo
|
16
|
+
protocol: Protocollo
|
17
|
+
protocol_default: Default nel protocollo
|
18
|
+
descriptions:
|
19
|
+
protocol: "Sezione per gestire qualsiasi tipo di protocollo di comunicazione (FTP, SSH, etc.)"
|
20
|
+
server: "Sezione per aggiungere e gestire server sulla rete"
|
data/config/routes.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateProtocols < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
create_table :protocols do |t|
|
4
|
+
t.string :name
|
5
|
+
t.text :description
|
6
|
+
t.integer :port
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
add_index :protocols, :name
|
11
|
+
add_index :protocols, :description
|
12
|
+
add_index :protocols, :port
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateServers < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
create_table :servers do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :address
|
6
|
+
t.string :username
|
7
|
+
t.string :password
|
8
|
+
t.string :path
|
9
|
+
t.references :protocol, foreign_key: true
|
10
|
+
t.boolean :protocol_default
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
add_index :servers, :name
|
15
|
+
add_index :servers, :address
|
16
|
+
add_index :servers, :username
|
17
|
+
add_index :servers, :password
|
18
|
+
add_index :servers, :path
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class AddProtocolToProtocol < ActiveRecord::Migration[5.1]
|
2
|
+
class Protocol < ApplicationRecord
|
3
|
+
has_many :servers, inverse_of: :protocol, dependent: :destroy
|
4
|
+
|
5
|
+
validates :name, presence: true, uniqueness: true
|
6
|
+
|
7
|
+
rails_admin do
|
8
|
+
visible false
|
9
|
+
# navigation_label I18n.t('admin.settings.label')
|
10
|
+
# navigation_icon 'fa fa-plug'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def up
|
15
|
+
%w( ftp http https ssh smb sftp ntp smtp smtps smtp-tls imap imaps imap-tls pop pops pop-tls ).each do |proto|
|
16
|
+
Protocol.create name: proto
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def down
|
21
|
+
Protocol.delete_all
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module ThecoreServerAbilitiesConcern
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
def thecore_servers_abilities user
|
7
|
+
if user
|
8
|
+
# if the user is logged in, it can do certain tasks regardless his role
|
9
|
+
if user.admin?
|
10
|
+
# if the user is an admin, it can do a lot of things, usually
|
11
|
+
can :manage, :all
|
12
|
+
end
|
13
|
+
|
14
|
+
if user.has_role? :role
|
15
|
+
# a specific role, brings specific powers
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# include the extension
|
23
|
+
TheCoreAbilities.send(:include, ThecoreServerAbilitiesConcern)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'thecore'
|
2
|
+
module ThecoreServers
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
|
5
|
+
initializer 'thecore_servers.add_to_migrations' do |app|
|
6
|
+
unless app.root.to_s == root.to_s
|
7
|
+
# APPEND TO MAIN APP MIGRATIONS FROM THIS GEM
|
8
|
+
config.paths['db/migrate'].expanded.each do |expanded_path|
|
9
|
+
app.config.paths['db/migrate'] << expanded_path
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thecore_servers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gabriele Tassoni
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thecore
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
27
|
+
description: Thecorized thecore_servers full description.
|
28
|
+
email:
|
29
|
+
- gabriele.tassoni@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- app/assets/config/thecore_servers_manifest.js
|
38
|
+
- app/models/application_record.rb
|
39
|
+
- app/models/protocol.rb
|
40
|
+
- app/models/server.rb
|
41
|
+
- config/initializers/thecore_server_after_initialize.rb
|
42
|
+
- config/locales/it.models.yml
|
43
|
+
- config/routes.rb
|
44
|
+
- db/migrate/20170705071150_create_protocols.rb
|
45
|
+
- db/migrate/20170705071338_create_servers.rb
|
46
|
+
- db/migrate/20170718152811_add_protocol_to_protocol.rb
|
47
|
+
- lib/abilities_thecore_servers_concern.rb
|
48
|
+
- lib/tasks/thecore_servers_tasks.rake
|
49
|
+
- lib/thecore_servers.rb
|
50
|
+
- lib/thecore_servers/engine.rb
|
51
|
+
- lib/thecore_servers/version.rb
|
52
|
+
homepage: https://www.taris.it
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.6.14
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Thecorized thecore_servers
|
76
|
+
test_files: []
|