opskit 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e94137fcc73c0f671ec796e1d923cf6c146f9c8
4
- data.tar.gz: 2a3ee1228bf0744053fcc614240e73cab2c02772
3
+ metadata.gz: 438c4e6212e6b7e5c0b02008ae7b7bc7a488429a
4
+ data.tar.gz: 0860307a8c7d2deadde4dde2e8826c5f716951d8
5
5
  SHA512:
6
- metadata.gz: ff520e6f5edd04a71b136cd7ba22fd466105919a789ae2b647098f4426b0e0912cd12233c5a37fd8a9641485fbdade58cef8a18f9cc62e8e8430baaca2906781
7
- data.tar.gz: a115e7b390915e890b27e079c9c4236ea70c9f8f5117ab41c9067327b7de091b2b5b53df10764fa7d0177b235fc67cb41d5c04a3625a53662ae14e0a5e049aba
6
+ metadata.gz: 7675b7bcf64b4bdb6ce950327af612ee1e535ee295c0153c07a2400d1b53368278592d80f878c3f23670a26458de1062dd69ae3fff1f819ba264d5a36ff20952
7
+ data.tar.gz: 5e16042bd5d6f394b2ed8a01f4384c833b9b4f80e3ec311694b2151a96ffa7fc082ae25b317156dd7371474caaaf846a46afb2acfc11fd8af27a41ef764b6297
data/lib/opskit/cli.rb CHANGED
@@ -1,25 +1,27 @@
1
1
  require 'thor'
2
- require 'thor/group'
2
+ require 'thor/actions'
3
3
  require 'yaml'
4
4
 
5
5
  module OpsKit
6
6
  class OdinSon < Thor
7
- class_option :dry, type: :boolean
7
+ include Thor::Actions
8
8
 
9
- desc "render TEMPLATE", "generate apache vhost for TEMPLATE."
10
- def render(template = nil)
11
- conf = YAML.load_file( '.opskit.yml' ) if File.exist? ( '.opskit.yml' )
12
- conf.keys.each do |key|
13
- conf[(key.to_sym rescue key) || key] = conf.delete(key)
14
- end
15
- vhost = OpsKit::VHost.new( template, conf )
9
+ desc "export", "Generates vhost and host file config"
10
+ def export
11
+ conf = {}
12
+ conf[:url] = ask "What is the dev url?"
13
+ conf[:docroot] = ask "What is the docroot?"
16
14
 
17
- if options[:dry]
18
- puts vhost.render
15
+ if yes?("Is it a custom template? y/n")
16
+ conf[:template_path] = ask "What is the template path?"
19
17
  else
20
- #TODO Should write to site-available
21
- puts vhost.vhost_location
18
+ conf[:template] = ask "What is the template?"
22
19
  end
20
+
21
+ vhost = OpsKit::VHost.new( conf )
22
+
23
+ system "echo '#{vhost.render}' | sudo tee #{ vhost.vhost_location }"
24
+ system "echo '127.0.0.1\t#{ conf[:url]}' | sudo tee -a /etc/hosts"
23
25
  end
24
26
  end
25
27
  end
@@ -1,8 +1,8 @@
1
1
  <VirtualHost *:80>
2
2
  ServerName <%= url %>
3
- DocumentRoot /home/clikex/hoppinger/<%= project %>/<%= docroot %>
3
+ DocumentRoot <%= Dir.pwd %>/<%= docroot %>
4
4
 
5
- <Directory "/home/clikex/hoppinger/projects/<%= project %>/<%= docroot %>/">
5
+ <Directory "<%= Dir.pwd %>/<%= docroot %>/"
6
6
  Options Indexes FollowSymLinks Includes ExecCGI
7
7
  AllowOverride All
8
8
  Require all granted
@@ -1,3 +1,3 @@
1
1
  module OpsKit
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/opskit/vhost.rb CHANGED
@@ -2,19 +2,16 @@ module OpsKit
2
2
  class VHost
3
3
  PROVIDERS = Dir.entries( File.join( File.dirname(__FILE__), "templates/" ) ).select {|f| !File.directory? f}.map{ |e| e.split('.').first.to_sym }
4
4
 
5
- attr_reader :provider, :conf
5
+ attr_reader :conf
6
6
 
7
- def initialize( provider = nil, conf = {} )
8
- @provider = provider
7
+ def initialize( conf = {} )
9
8
  @conf = conf
10
9
  end
11
10
 
12
11
  def render
13
- raise NotImplementedError "No template specified" unless @provider
14
-
15
- if PROVIDERS.include? @provider.to_sym
16
- file_path = File.join( File.dirname(__FILE__), "templates/#{ @provider }.erb.conf" )
17
- elsif @conf[ :template_path ]
12
+ if PROVIDERS.include? @conf[ :template ].to_sym
13
+ file_path = File.join( File.dirname(__FILE__), "templates/#{ @conf[ :template ] }.erb.conf" )
14
+ elsif @conf[ :template ]
18
15
  file_path = @conf[ :template ]
19
16
  end
20
17
 
@@ -24,7 +21,7 @@ module OpsKit
24
21
  end
25
22
 
26
23
  def vhost_location
27
- case @provider.to_sym
24
+ case @conf[ :template ].to_sym
28
25
  when :apache
29
26
  "/etc/apache2/sites-available/#{ @conf[:url] }.conf"
30
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opskit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "ClikeX\n\n"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-22 00:00:00.000000000 Z
11
+ date: 2016-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler