railsconsole 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/railsconsole +10 -0
  3. data/lib/rails_console.rb +50 -0
  4. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e6a78bb6e676945ed86e06fe19facee274576efa
4
+ data.tar.gz: f75aa85522773793d190a9358cf9a3c0668142a2
5
+ SHA512:
6
+ metadata.gz: d431c7459bce899ee2b859c81cdac89e2c440dfe0a055cfd73242c66adde70b9e3f2c5ea6a37fd6e206c093caa29c792c70604ef5fe062519e1b39b14040f210
7
+ data.tar.gz: a94e6950a2591dbf2cd14ece6d9cdf04797feb7dd6636fa9f59a9a6933e10f9b908de02201bafe7bd99a6852b380462c137d9577319b22dd619babeef25e5528
data/bin/railsconsole ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rails_console'
4
+
5
+ if ARGV.include?('--deploy-file')
6
+ deploy_file = (ARGV - ['--deploy-file']).join(' ')
7
+ RailsConsole.deploy_file(deploy_file)
8
+ end
9
+
10
+ RailsConsole.connection
@@ -0,0 +1,50 @@
1
+ # require 'rails_console/version'
2
+
3
+ module RailsConsole
4
+ BASE_COMMAND = 'ssh -t USER@SERVER \'cd PATH/current && bundle exec rails c production\''
5
+
6
+ @@deploy_file = './config/deploy.rb'
7
+
8
+ def self.deploy_file
9
+ @@deploy_file
10
+ end
11
+
12
+ def self.deploy_file= option
13
+ @@deploy_file = option
14
+ end
15
+
16
+ def self.setup(&block)
17
+ yield self
18
+ end
19
+
20
+ def self.connection
21
+ connection_data = { user: nil, server: nil, path: nil }
22
+
23
+ File.open(@@deploy_file, 'r') do |f|
24
+ f.each_line do |line|
25
+ if line =~ /deploy_to/
26
+ connection_data[:path] = line.match(/"([^"]*)"/)[1]
27
+ end
28
+
29
+ if line =~ /user/
30
+ connection_data[:user] = line.match(/"([^"]*)"/)[1]
31
+ end
32
+
33
+ if line =~ /role/ && line =~ /web/
34
+ connection_data[:server] = line.match(/"([^"]*)"/)[1]
35
+ end
36
+
37
+ end
38
+ end
39
+
40
+ if connection_data.values.include?(nil)
41
+ puts "ERROR to get data from deploy file."
42
+ else
43
+ command = BASE_COMMAND.gsub('USER', connection_data[:user]).gsub('PATH', connection_data[:path]).gsub('SERVER', connection_data[:server])
44
+ puts "Connecting to #{connection_data[:server]} into #{connection_data[:path]}..."
45
+
46
+ system(command)
47
+ end
48
+
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: railsconsole
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Hugo Demiglio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Access of production rails console from deploy file.
14
+ email: hugodemiglio@gmail.com
15
+ executables:
16
+ - railsconsole
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/railsconsole
21
+ - lib/rails_console.rb
22
+ homepage: http://rubygems.org/gems/rails_console
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.6.14.1
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Rails production console!
46
+ test_files: []