nginx 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nginx.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Kirill Radzikhovskyy
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ # Nginx
2
+
3
+ Very small CLI for nginx configuration.
4
+
5
+ Sorry that I took name nginx.
6
+
7
+
8
+ TODO: Write a gem description
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'nginx'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install nginx
23
+
24
+ ## Usage
25
+
26
+ $ nginx-config add passenger www.example.com.au /path/to/public
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+ # detect nginx prefix
3
+ # get to config
4
+ # inject server statements
5
+ # parse arguments, for now only passenger is supported
6
+
7
+ #TODO fix detection of location of file
8
+ def nginx_conf
9
+ possible_locations = [
10
+ '/usr/local/etc/nginx/nginx.conf',
11
+ '/opt/nginx/conf/nginx.conf'
12
+ ]
13
+ conf = possible_locations.select{|x| File.exists? x }.first
14
+ raise "Could not find confi" unless conf
15
+ return conf
16
+ end
17
+
18
+ def add_server_to_conf conf_string
19
+ puts "Adding: \n #{conf_string}"
20
+ File.open(nginx_conf,'r+') do |f|
21
+ f.seek(-3, IO::SEEK_END)
22
+ f.write conf_string
23
+ f.write "\n}\n"
24
+ end
25
+ end
26
+
27
+
28
+ def add_passenger_server server_name, path_to_public
29
+ string = "
30
+ server {
31
+ listen 80;
32
+ server_name #{server_name};
33
+ root #{path_to_public};
34
+ passenger_enabled on;
35
+ }
36
+ "
37
+ add_server_to_conf string
38
+ end
39
+
40
+
41
+ #initial usage for passenger sites
42
+ puts "sample usage: "
43
+ puts "nginx add passenger www.example.com /home/user/path_to_public"
44
+
45
+ #TODO for now we only supporting passenger related config
46
+ add_passenger_server *ARGV[2..-1]
@@ -0,0 +1,5 @@
1
+ require "nginx/version"
2
+
3
+ module Nginx
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Nginx
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/nginx/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Kirill Radzikhovskyy"]
6
+ gem.email = ["kirillrdy@gmail.com"]
7
+ gem.description = %q{Small gem to manage nginx configuration}
8
+ gem.summary = %q{Gem for managin nginx configurations}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "nginx"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Nginx::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nginx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kirill Radzikhovskyy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-22 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Small gem to manage nginx configuration
15
+ email:
16
+ - kirillrdy@gmail.com
17
+ executables:
18
+ - nginx-config
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - bin/nginx-config
28
+ - lib/nginx.rb
29
+ - lib/nginx/version.rb
30
+ - nginx.gemspec
31
+ homepage: ''
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.23
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Gem for managin nginx configurations
55
+ test_files: []