r5 0.1.9 → 0.2.0
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 +4 -4
- data/lib/r5/config.rb +24 -0
- data/lib/r5/installations/default.rb +2 -2
- data/lib/r5/recipes/bootstrap.rb +1 -1
- data/lib/r5/recipes/devise.rb +1 -1
- data/lib/r5/recipes/exception_notification.rb +1 -1
- data/lib/r5/recipes/gitignore.rb +2 -0
- data/lib/r5/recipes/lazy_high_charts.rb +1 -1
- data/lib/r5/recipes/upload_app.rb +2 -1
- data/lib/r5/recipes/wicked_pdf.rb +3 -25
- data/lib/r5/recipes/xlsx_support.rb +1 -1
- data/lib/r5/starter.rb +32 -0
- data/lib/r5/template/.ruby-version +1 -1
- data/lib/r5/template/lib/tasks/upload.rake +13 -4
- data/lib/r5/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 540310d5e44333f1a92160ada5a8fdbafec7ec04
|
4
|
+
data.tar.gz: aaab7f612363a6fde3bda0dcc2838a0e484a08b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc37c68af76f13eb3b640db5a9cc77f8350e0f964005d9c9c25e39861cd5fb65ef78ed7586093bb2515830eca752c29c6b2354cafd3d9a1c925635343cfac259
|
7
|
+
data.tar.gz: 0b298151bfdabdb627dc7459e1fd391ea480b7d55a597a173604b5e1d627762d2828ad99a4b3f041a5b9e3ecb5cb627eaeffefd16d659b7cec1b6de0a32d9b3b
|
data/lib/r5/config.rb
CHANGED
@@ -2,6 +2,20 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
class Config
|
4
4
|
|
5
|
+
REQUIRED_STRUCTURE = {'mysql' => {'user' => 'name',
|
6
|
+
'password' => 'password',
|
7
|
+
'host' => 'localhost'},
|
8
|
+
'admin' => {'login' => 'admin',
|
9
|
+
'password' => 'password',
|
10
|
+
'email' => 'admin@example.com',
|
11
|
+
'lastname' => 'administrator'},
|
12
|
+
'notifier' => {'email' => 'code@example.com'},
|
13
|
+
'server' => {'name_prod' => 'production server',
|
14
|
+
'name_stage' => 'stage server',
|
15
|
+
'port' => 'ssh port',
|
16
|
+
'user' => 'user name'}
|
17
|
+
}
|
18
|
+
|
5
19
|
def self.settings
|
6
20
|
if File.exists? "#{ENV['HOME']}/.r5.yml"
|
7
21
|
YAML::load_file("#{ENV['HOME']}/.r5.yml")
|
@@ -9,4 +23,14 @@ class Config
|
|
9
23
|
'You need to create ~/.r5.yml file, check github for example.'
|
10
24
|
end
|
11
25
|
end
|
26
|
+
|
27
|
+
|
28
|
+
# TODO Space for improving structure check - now it is very simple and won't work properly for duplicated keys in deeper structure
|
29
|
+
def self.check_settings
|
30
|
+
all_keys(REQUIRED_STRUCTURE) - all_keys(settings)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.all_keys(hash)
|
34
|
+
hash.flat_map { |k, v| [k] + (v.is_a?(Hash) ? all_keys(v) : []) }
|
35
|
+
end
|
12
36
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# DEFAULT SETTINGS
|
2
|
-
# TODO check ruby version on system and use it in ruby version
|
3
2
|
copy '.ruby-version'
|
3
|
+
gsub_file "#{@project_path}/.ruby-version", /version/, RUBY_VERSION
|
4
4
|
apply 'recipes/gemfile.rb'
|
5
|
-
run 'bundle install'
|
5
|
+
run 'bundle check && bundle install'
|
6
6
|
|
7
7
|
copy 'config/initializers/html_helpers.rb'
|
8
8
|
copy 'config/locales/cs.yml'
|
data/lib/r5/recipes/bootstrap.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
add_gem 'bootstrap-generators'
|
2
2
|
add_gem 'bootstrap-select-rails'
|
3
3
|
add_gem 'scrollbar-rails'
|
4
|
-
run 'bundle install'
|
4
|
+
run 'bundle check && bundle install'
|
5
5
|
# TODO removing is probably not good idea when adding bootstrap to existing project
|
6
6
|
remove 'app/views/layouts/application.html.erb'
|
7
7
|
system "rails generate bootstrap:install"
|
data/lib/r5/recipes/devise.rb
CHANGED
data/lib/r5/recipes/gitignore.rb
CHANGED
@@ -4,6 +4,7 @@ copy path
|
|
4
4
|
|
5
5
|
gsub_file upload_file, 'USER_NAME', Config.settings['server']['user']
|
6
6
|
gsub_file upload_file, 'PORT_NUMBER', Config.settings['server']['port']
|
7
|
-
gsub_file upload_file, '
|
7
|
+
gsub_file upload_file, 'PROD_SERVER', Config.settings['server']['name_prod']
|
8
|
+
gsub_file upload_file, 'STAGE_SERVER', Config.settings['server']['name_stage']
|
8
9
|
|
9
10
|
|
@@ -4,32 +4,10 @@ return say('Wicked_pdf already installed', :red) if File.exists?(wicked_pdf_conf
|
|
4
4
|
|
5
5
|
add_gem 'wicked_pdf'
|
6
6
|
add_gem 'wkhtmltopdf-binary'
|
7
|
-
run 'bundle install'
|
7
|
+
run 'bundle check && bundle install'
|
8
8
|
run 'rails generate wicked_pdf'
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
after: "# https://github.com/mileszs/wicked_pdf/blob/master/README.md\n" do
|
13
|
-
<<RUBY
|
14
|
-
require 'wicked_pdf'
|
15
|
-
require 'rbconfig'
|
16
|
-
|
17
|
-
if RbConfig::CONFIG['host_os'] =~ /linux/
|
18
|
-
arch = RbConfig::CONFIG['host_cpu'] == 'x86_64' ? 'wkhtmltopdf_linux_x64' : 'wkhtmltopdf_linux_386'
|
19
|
-
elsif RbConfig::CONFIG['host_os'] =~ /darwin/
|
20
|
-
arch = 'wkhtmltopdf_darwin_386'
|
21
|
-
else
|
22
|
-
raise "Invalid platform. Must be running Intel-based Linux or OSX."
|
23
|
-
end
|
24
|
-
RUBY
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
gsub_file wicked_pdf_conf, "# exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf')" do
|
29
|
-
<<RUBY
|
30
|
-
exe_path: "\#{ENV['GEM_HOME']}/gems/wkhtmltopdf-binary-\#{Gem.loaded_specs['wkhtmltopdf-binary'].version}/bin/\#{arch}"
|
31
|
-
RUBY
|
32
|
-
|
33
|
-
end
|
10
|
+
say "CHECK https://github.com/mileszs/wicked_pdf", :green
|
11
|
+
say "For server - find binary with which wkhtmltopdf and used it as exe_path in config/initializers/wicked_pdf.rb", :red
|
34
12
|
|
35
13
|
|
data/lib/r5/starter.rb
CHANGED
@@ -8,6 +8,17 @@ class Starter < Thor
|
|
8
8
|
|
9
9
|
def initialize(*args)
|
10
10
|
super
|
11
|
+
unless File.exists? "#{Dir.home}/.r5.yml"
|
12
|
+
say "Need to create config file - answer following question", :green
|
13
|
+
create_config_file
|
14
|
+
end
|
15
|
+
|
16
|
+
unless Config.check_settings.empty?
|
17
|
+
say Config.check_settings, :green
|
18
|
+
say 'Check structure of your config file - it seems you are missing required options mentioned above', :red
|
19
|
+
abort
|
20
|
+
end
|
21
|
+
|
11
22
|
if ARGV[0] =~ /new/
|
12
23
|
@dir = `pwd`.gsub("\n", '')
|
13
24
|
elsif ARGV[0] =~ /add/
|
@@ -93,6 +104,27 @@ class Starter < Thor
|
|
93
104
|
|
94
105
|
# local helpers
|
95
106
|
no_commands do
|
107
|
+
require 'yaml'
|
108
|
+
def create_config_file
|
109
|
+
settings = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc) }
|
110
|
+
settings['mysql']['user'] = ask("Insert name of mysql user:")
|
111
|
+
settings['mysql']['password'] = ask("Insert password for mysql user:")
|
112
|
+
settings['mysql']['host'] = ask("Host of mysql user:", default: 'localhost')
|
113
|
+
settings['admin']['login'] = ask("Login of default admin user:", default: 'admin')
|
114
|
+
settings['admin']['password'] = ask("Password of default password:", default: 'password')
|
115
|
+
settings['admin']['email'] = ask("E-mail of default user:", default: 'admin@example.com')
|
116
|
+
settings['admin']['lastname'] = ask("Lastname of default user:", default: 'administrator')
|
117
|
+
settings['notifier']['email'] = ask("Email for exception notification:", default: 'code@example.com')
|
118
|
+
settings['server']['name_prod'] = ask("Production server adddress:")
|
119
|
+
settings['server']['name_stage'] = ask("Stage server address:")
|
120
|
+
settings['server']['port'] = ask("SSH port for both:")
|
121
|
+
settings['server']['user'] = ask("Name of user on servers:")
|
122
|
+
|
123
|
+
File.open("#{Dir.home}/.r5.yml", 'w') do |file|
|
124
|
+
file.write(settings.to_yaml)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
96
128
|
def source_paths
|
97
129
|
root_path = File.dirname __FILE__
|
98
130
|
[root_path + '/template', root_path]
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
version
|
@@ -1,12 +1,21 @@
|
|
1
1
|
namespace :server do
|
2
|
-
|
2
|
+
STAGE = "STAGE_SERVER"
|
3
|
+
PRODUCTION = "PROD_SERVER"
|
3
4
|
PORT = "PORT_NUMBER"
|
4
|
-
|
5
|
+
|
5
6
|
SERVER_DIR = '/home/www/PROJECT_DIR'
|
6
7
|
|
7
|
-
desc
|
8
|
+
desc 'Uploads to production server'
|
9
|
+
task :upload_production => :environment do
|
10
|
+
app_upload "-p#{PORT} USER_NAME@#{PRODUCTION}"
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'Uploads to stage server'
|
8
14
|
task :upload => :environment do
|
15
|
+
app_upload "-p#{PORT} USER_NAME@#{STAGE}"
|
16
|
+
end
|
9
17
|
|
18
|
+
def app_upload server_ssh
|
10
19
|
puts "Really upload to \033[0;37m#{SERVER_DIR}\033[0;32m ?"
|
11
20
|
STDIN.gets
|
12
21
|
|
@@ -19,6 +28,6 @@ namespace :server do
|
|
19
28
|
print 'Assets change? '
|
20
29
|
puts change_assets = !!(`git diff --name-only HEAD^` =~ /assets/)
|
21
30
|
|
22
|
-
system %Q(ssh -t #{
|
31
|
+
system %Q(ssh -t #{server_ssh} "source .zshrc && deploy.sh #{SERVER_DIR} #{change_assets}")
|
23
32
|
end
|
24
33
|
end
|
data/lib/r5/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r5
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mousse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.5.1
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Rails generator using Thor gem for private usage mostly
|