infraction 0.0.1

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.
Files changed (2) hide show
  1. data/lib/infraction.rb +58 -0
  2. metadata +61 -0
data/lib/infraction.rb ADDED
@@ -0,0 +1,58 @@
1
+ module Infraction
2
+ class BuildContext
3
+ def exec(&block)
4
+ builder = instance_eval(&block)
5
+ builder.generate
6
+ end
7
+
8
+ end
9
+ def self.nginx(&block)
10
+ Nginx::NginxBuildContext.new.exec &block
11
+ end
12
+ module Nginx
13
+ module Dsl
14
+ def pass_through(host)
15
+ Infraction::Nginx::PassthroughBuilder.new(host)
16
+ end
17
+ end
18
+ class NginxBuildContext < ::Infraction::BuildContext
19
+ include Nginx::Dsl
20
+ end
21
+ class PassthroughBuilder
22
+ def initialize(host)
23
+ @host = host
24
+ end
25
+ def including(subdomain)
26
+ @subdomain = subdomain
27
+ self
28
+ end
29
+ def on(port)
30
+ @port = port
31
+ self
32
+ end
33
+ def forward_to(host)
34
+ @forward_host = host
35
+ self
36
+ end
37
+ def generate
38
+ "server {
39
+ listen #{@port};
40
+ server_name #{hosts};
41
+
42
+ location / {
43
+ proxy_pass http://#{@forward_host};
44
+ proxy_set_header Host $http_host;
45
+ }
46
+
47
+ }"
48
+ end
49
+
50
+ private
51
+
52
+ def hosts
53
+ return @host unless @subdomain
54
+ "#{@host} #{@subdomain}.#{@host}"
55
+ end
56
+ end
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: infraction
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - www-thoughtworks-com
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.14.1
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.14.1
30
+ description: simple infrastructure configuration generator, expressed in ruby
31
+ email: www@thoughtworks.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - lib/infraction.rb
37
+ homepage: https://github.com/www-thoughtworks-com/infraction
38
+ licenses: []
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 1.8.24
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: simple infrastructure configuration generator, expressed in ruby
61
+ test_files: []