activerse 1.0.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 +61 -0
- data/Rakefile +27 -0
- data/lib/activerse.rb +7 -0
- data/lib/activerse/configs.rb +18 -0
- data/lib/activerse/dsl.rb +51 -0
- data/lib/activerse/railtie.rb +4 -0
- data/lib/activerse/version.rb +3 -0
- data/lib/generators/activerse/fill_generator.rb +17 -0
- data/lib/generators/activerse/install_generator.rb +54 -0
- data/lib/generators/templates/README +27 -0
- data/lib/generators/templates/activerse.rb +28 -0
- data/lib/tasks/activerse_tasks.rake +6 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b3f87b8fda678a8ab7c759cede469f763fb274a32fb4175e5880c57dd5a727d7
|
4
|
+
data.tar.gz: db6972302af44ff6904b39487c4dffa8673c2bfb2796e9a01472a6448328bf44
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 790f6fac64046ba696e21f1fe5cdb829393bf53ac491fae52234fb81a81ae7b688db6258b4aa98ba93b340a71dd9b3a3e7c0c9bcdf338a7db5788d9ccae59a4b
|
7
|
+
data.tar.gz: 3bb700d7ad6c5cd353562c6d462a447c3f88c68ef11decab45e4b264116ebb0f3f19efaef734cd9db975940b13a61b6f1356aa0ba12d3c016aa58c2dff6ed68f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 Pietro Moro
|
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,61 @@
|
|
1
|
+
# WIP: Activerse
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/activerse.svg)](https://badge.fury.io/rb/activerse)
|
3
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/fe0e9c2138d24d10a268e72491562fec)](https://www.codacy.com/manual/pietromoro/activerse?utm_source=github.com&utm_medium=referral&utm_content=pietromoro/activerse&utm_campaign=Badge_Grade)
|
4
|
+
|
5
|
+
This gem is currently in the process of being made.
|
6
|
+
|
7
|
+
**DISCLAMER** All text is either temporary or not yet implemented. It is only a proposal of how the library could work
|
8
|
+
|
9
|
+
<a href="https://www.buymeacoffee.com/pietromoro" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
Run `rails generate activerse:install` to create the configuration file, as well as uncheking your `credentials.yml.enc` file from version control and adding it to the `.gitignore`. Then you can setup how you want your credentials file to look like in the initializer
|
13
|
+
file `activerse.rb` like this:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
config.credentials do
|
17
|
+
section "Email configuration", :email do
|
18
|
+
set :port, to: ask("Port:")
|
19
|
+
set :email, to: ask("Email:")
|
20
|
+
set :pwd, to: ask("Auth Token:")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
```
|
24
|
+
See the wiki for more informations.
|
25
|
+
|
26
|
+
In the `config/initializers/activese.rb` file you can specify more general settings.
|
27
|
+
|
28
|
+
See the wiki or directly the initializer file for more configuration options.
|
29
|
+
|
30
|
+
## Installation
|
31
|
+
Add this line to your application's Gemfile:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
gem 'activerse'
|
35
|
+
```
|
36
|
+
|
37
|
+
And then execute:
|
38
|
+
```bash
|
39
|
+
$ bundle
|
40
|
+
```
|
41
|
+
|
42
|
+
Or install it yourself as:
|
43
|
+
```bash
|
44
|
+
$ gem install activerse
|
45
|
+
```
|
46
|
+
|
47
|
+
To create all necessary setup and files run:
|
48
|
+
```bash
|
49
|
+
$ rails g activerse:install
|
50
|
+
```
|
51
|
+
|
52
|
+
When ready to fill your credentials run:
|
53
|
+
```bash
|
54
|
+
$ rails g activerse:fill
|
55
|
+
```
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
Contributions will be welome when first few iterations will be going out.
|
59
|
+
|
60
|
+
## License
|
61
|
+
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,27 @@
|
|
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 = 'Activerse'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'bundler/gem_tasks'
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
|
21
|
+
Rake::TestTask.new(:test) do |t|
|
22
|
+
t.libs << 'test'
|
23
|
+
t.pattern = 'test/**/*_test.rb'
|
24
|
+
t.verbose = false
|
25
|
+
end
|
26
|
+
|
27
|
+
task default: :test
|
data/lib/activerse.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Activerse
|
2
|
+
module Configs
|
3
|
+
mattr_accessor :finalize_behaviour
|
4
|
+
@@finalize_behaviour = :restart_server
|
5
|
+
|
6
|
+
mattr_accessor :strip_whitespaces
|
7
|
+
@@strip_whitespaces = true
|
8
|
+
|
9
|
+
def self.setup
|
10
|
+
yield self
|
11
|
+
end
|
12
|
+
|
13
|
+
mattr_reader :internal_structure
|
14
|
+
def self.credentials(&block)
|
15
|
+
@@internal_structure = block
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Activerse
|
2
|
+
class Dsl
|
3
|
+
def initialize(hash = {})
|
4
|
+
@credentials = hash
|
5
|
+
@current_keys = []
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
def section title, sym = nil, &block
|
10
|
+
guess = `tput cols`.to_i
|
11
|
+
guess == 0 ? 80 : guess
|
12
|
+
puts " #{title.to_s} ".center(guess, '=')
|
13
|
+
@current_keys.push sym.nil? ? title.to_sym : sym.to_sym
|
14
|
+
instance_eval(&block)
|
15
|
+
@current_keys.pop
|
16
|
+
puts '-' * guess
|
17
|
+
end
|
18
|
+
|
19
|
+
def subsection name, &block
|
20
|
+
@current_keys.push name.to_sym
|
21
|
+
instance_eval(&block)
|
22
|
+
@current_keys.pop
|
23
|
+
end
|
24
|
+
|
25
|
+
def set key, to: nil
|
26
|
+
last = @current_keys.inject(@credentials) { |structure, key| structure[key] ||= {} }
|
27
|
+
last[key.to_sym] = to
|
28
|
+
end
|
29
|
+
|
30
|
+
def ask question, echo: true
|
31
|
+
print question + " "
|
32
|
+
if Activerse::Configs.strip_whitespaces
|
33
|
+
return gets.chomp.strip
|
34
|
+
else
|
35
|
+
return gets.chomp
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def ask_and_set key, question, *args
|
40
|
+
last = @current_keys.inject(@credentials) { |structure, key| structure[key] ||= {} }
|
41
|
+
last_value = last[key.to_sym].nil? ? "" : last[key.to_sym]
|
42
|
+
response = ask("#{question} (#{last_value})", *args)
|
43
|
+
last[key.to_sym] = response.blank? ? last_value : response
|
44
|
+
end
|
45
|
+
|
46
|
+
def save_to_database model, *args
|
47
|
+
model.create!(*args)
|
48
|
+
set model.to_sym, to: true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Activerse
|
4
|
+
module Generators
|
5
|
+
class FillGenerator < ::Rails::Generators::Base
|
6
|
+
desc "Fill out the credentials file and run startup code"
|
7
|
+
|
8
|
+
def fill_out
|
9
|
+
current_credentials = YAML.load(Rails.application.credentials.read)
|
10
|
+
current_credentials.symbolize_keys!
|
11
|
+
dsl = Activerse::Dsl.new(current_credentials)
|
12
|
+
dsl.instance_eval(&Activerse::Configs.internal_structure)
|
13
|
+
Rails.application.credentials.write YAML.dump(dsl.instance_eval("@credentials"))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Activerse
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < ::Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../../templates", __FILE__)
|
7
|
+
|
8
|
+
desc "Initialize activerse (creates the initializer file)"
|
9
|
+
|
10
|
+
def copy_templates
|
11
|
+
template "activerse.rb", "config/initializers/activerse.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def ensure_credentials_files
|
15
|
+
key_path = Rails.application.config.credentials.key_path
|
16
|
+
credentials_path = Rails.application.config.credentials.content_path
|
17
|
+
encryption_key_file_generator.add_key_file(key_path) unless File.exists? key_path
|
18
|
+
credentials_generator.add_credentials_file_silently unless File.exists? credentials_path
|
19
|
+
end
|
20
|
+
|
21
|
+
def update_git
|
22
|
+
return unless Dir.exists? ".git"
|
23
|
+
if File.exists? "config/credentials.enc.yml"
|
24
|
+
git rm: "--cached config/credentials.enc.yml"
|
25
|
+
end
|
26
|
+
|
27
|
+
append_to_file ".gitignore", <<-GIT
|
28
|
+
# Ignore credentials file (Activerse)
|
29
|
+
config/master.key
|
30
|
+
config/credentials.enc.yml
|
31
|
+
GIT
|
32
|
+
end
|
33
|
+
|
34
|
+
def show_readme
|
35
|
+
readme "README" if behavior == :invoke
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def encryption_key_file_generator
|
40
|
+
require "rails/generators"
|
41
|
+
require "rails/generators/rails/encryption_key_file/encryption_key_file_generator"
|
42
|
+
|
43
|
+
Rails::Generators::EncryptionKeyFileGenerator.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def credentials_generator
|
47
|
+
require "rails/generators"
|
48
|
+
require "rails/generators/rails/credentials/credentials_generator"
|
49
|
+
|
50
|
+
Rails::Generators::CredentialsGenerator.new
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
===========================================================
|
2
|
+
|
3
|
+
Activerse installed.
|
4
|
+
Remember to use the initializer file to create your
|
5
|
+
desired credentials structure. You may run
|
6
|
+
|
7
|
+
rails g activerse:fill
|
8
|
+
|
9
|
+
to fill out your credentials file. Addition made into the
|
10
|
+
initializer will reflect on the credentials file upon
|
11
|
+
reissuing this command.
|
12
|
+
|
13
|
+
|
14
|
+
You may want to regenerate your master key with
|
15
|
+
|
16
|
+
rake activerse:regenkeys
|
17
|
+
|
18
|
+
or generate fresh credentials with
|
19
|
+
|
20
|
+
EDITOR="vim" rails credentials:edit
|
21
|
+
|
22
|
+
|
23
|
+
Remember that either your config/credentials.yml.enc
|
24
|
+
and your config/master.key files *must not* be under
|
25
|
+
source control.
|
26
|
+
|
27
|
+
===========================================================
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This is the configuration file for activerse.
|
4
|
+
# In here you can customize some general configuration
|
5
|
+
# options as well as per page actions.
|
6
|
+
Activerse::Configs.setup do |config|
|
7
|
+
|
8
|
+
# Block that will be called in the context of a controller
|
9
|
+
# before finalize_behaviour gets called and after all
|
10
|
+
# credentials have been configured.
|
11
|
+
# config.on_finalize
|
12
|
+
# # your code here
|
13
|
+
# end
|
14
|
+
|
15
|
+
# The behaviour that activerse should use when all
|
16
|
+
# configurations have been set up.
|
17
|
+
# Possible values are :reload_routes, :restart_server.
|
18
|
+
config.finalize_behaviour = :restart_server
|
19
|
+
|
20
|
+
# Strip whitespaces from entered values.
|
21
|
+
config.strip_whitespaces = true
|
22
|
+
|
23
|
+
# Configure the structure of the credentials file
|
24
|
+
# with the custom DLS.
|
25
|
+
config.credentials do
|
26
|
+
# code here
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activerse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pietro Moro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.4.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.4.1
|
41
|
+
description: Rails gem that allows a project to be distributed over multiple companies,
|
42
|
+
without having to set specific credentials in a file, allowing to distribute only
|
43
|
+
it's structure with a web ui.
|
44
|
+
email:
|
45
|
+
- pietromoro@programmer.net
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- MIT-LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/activerse.rb
|
54
|
+
- lib/activerse/configs.rb
|
55
|
+
- lib/activerse/dsl.rb
|
56
|
+
- lib/activerse/railtie.rb
|
57
|
+
- lib/activerse/version.rb
|
58
|
+
- lib/generators/activerse/fill_generator.rb
|
59
|
+
- lib/generators/activerse/install_generator.rb
|
60
|
+
- lib/generators/templates/README
|
61
|
+
- lib/generators/templates/activerse.rb
|
62
|
+
- lib/tasks/activerse_tasks.rake
|
63
|
+
homepage: https://github.com/pietromoro/activerse
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubygems_version: 3.1.4
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Generate initial settings and configurations with a web interface.
|
86
|
+
test_files: []
|