r5 0.1.9 → 0.2.0

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: f2fe3c1fe8a3497514c1d369f89be7da8b55468e
4
- data.tar.gz: aabe9cee584561fa57c95ee7f394ac96acf3ec4c
3
+ metadata.gz: 540310d5e44333f1a92160ada5a8fdbafec7ec04
4
+ data.tar.gz: aaab7f612363a6fde3bda0dcc2838a0e484a08b4
5
5
  SHA512:
6
- metadata.gz: 18d6d0d4d57bfe75621159002b6f01a69644eab0d74ad440ddb43a4d8a6ccca462da3a040ae5ec9ae077e115fc0acf9cad3cf8ca101ea329af0f33db35098663
7
- data.tar.gz: 78a1d9ef28d78aa75037f2d361d064f500b805e4fd03da5429238871476504dd93fc979726919fb7c214af52ee31841bb7ecbfcc0b99ebb8effb7737d74144d7
6
+ metadata.gz: fc37c68af76f13eb3b640db5a9cc77f8350e0f964005d9c9c25e39861cd5fb65ef78ed7586093bb2515830eca752c29c6b2354cafd3d9a1c925635343cfac259
7
+ data.tar.gz: 0b298151bfdabdb627dc7459e1fd391ea480b7d55a597a173604b5e1d627762d2828ad99a4b3f041a5b9e3ecb5cb627eaeffefd16d659b7cec1b6de0a32d9b3b
@@ -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'
@@ -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"
@@ -2,7 +2,7 @@
2
2
  # TODO add checking for existing devise in project
3
3
  add_gem 'devise'
4
4
 
5
- run 'bundle install'
5
+ run 'bundle check && bundle install'
6
6
  run 'rails g devise:install'
7
7
  run 'rails g devise User'
8
8
 
@@ -1,6 +1,6 @@
1
1
  add_gem 'exception_notification'
2
2
 
3
- run 'bundle install'
3
+ run 'bundle check && bundle install'
4
4
 
5
5
  config_file = "#{@project_path}/config/initializers/exception_notification.rb"
6
6
 
@@ -4,5 +4,7 @@ append_to_file "#{@project_path}/.gitignore" do
4
4
  /log/*.log
5
5
  /tmp
6
6
  /db/schema.rb
7
+ .ruby-version
8
+ Gemfile.lock
7
9
  EOF
8
10
  end
@@ -1,6 +1,6 @@
1
1
  # TODO check for existence of it
2
2
  add_gem 'lazy_high_charts'
3
- run 'bundle install'
3
+ run 'bundle check && bundle install'
4
4
  insert_into_file "#{@project_path}/app/assets/javascripts/application.js",
5
5
  after: "//= require_tree .\n" do
6
6
  <<EOF
@@ -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, 'SERVER_NAME', Config.settings['server']['name']
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
- insert_into_file wicked_pdf_conf,
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
 
@@ -1,6 +1,6 @@
1
1
  add_gem 'roo'
2
2
  add_gem "axlsx" # problems with newest version of RubyZip
3
- run 'bundle install'
3
+ run 'bundle check && bundle install'
4
4
  say 'For more information check:', :green
5
5
  say 'https://github.com/randym/axlsx'
6
6
  say 'https://github.com/roo-rb/roo'
@@ -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
- 2.3.0
1
+ version
@@ -1,12 +1,21 @@
1
1
  namespace :server do
2
- SERVER = "USER_NAME@SERVER_NAME"
2
+ STAGE = "STAGE_SERVER"
3
+ PRODUCTION = "PROD_SERVER"
3
4
  PORT = "PORT_NUMBER"
4
- SSH = "-p#{PORT} #{SERVER}"
5
+
5
6
  SERVER_DIR = '/home/www/PROJECT_DIR'
6
7
 
7
- desc "Uploads to #{SERVER} server"
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 #{SSH} "source .zshrc && deploy.sh #{SERVER_DIR} #{change_assets}")
31
+ system %Q(ssh -t #{server_ssh} "source .zshrc && deploy.sh #{SERVER_DIR} #{change_assets}")
23
32
  end
24
33
  end
@@ -1,3 +1,3 @@
1
1
  module R5
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.9
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-05 00:00:00.000000000 Z
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.6.7
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