bowtie-io 1.0.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 +7 -0
- data/bin/bowtie +39 -0
- data/lib/bowtie.rb +19 -0
- data/lib/bowtie/command.rb +14 -0
- data/lib/bowtie/commands/serve.rb +57 -0
- data/lib/bowtie/middleware/proxy.rb +15 -0
- data/lib/bowtie/middleware/rewrite.rb +22 -0
- data/lib/bowtie/middleware/static.rb +35 -0
- data/lib/bowtie/settings.rb +10 -0
- data/lib/bowtie/version.rb +3 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5360d7e0e671fa845bddcfe5a6cda678b8dcfb01
|
4
|
+
data.tar.gz: bad2df10cd7c15a48acc6623a413f5cdc74a7a78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23e077ba6c186549ac386df5e73bbb5453ed3505eb03e489f7011654ca43af459af5089a2dadb3901b3879f5174f100cead1b499fb9d6aa8ca4064371f42053e
|
7
|
+
data.tar.gz: f6b491ba5338b2cbbb8da49ad0f9a432f84ed4b842c3ce33f7490aaffb953ab510f90438fa00ea1b12d1bdac6bffa200322f5caa9d504deae5172f14b0cc45e1
|
data/bin/bowtie
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# BowTie is based heavily on and utilizes the Jekyll blogging platform.
|
4
|
+
# (https://github.com/jekyll/jekyll)
|
5
|
+
|
6
|
+
STDOUT.sync = true
|
7
|
+
|
8
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
|
9
|
+
|
10
|
+
require 'bowtie'
|
11
|
+
require 'mercenary'
|
12
|
+
|
13
|
+
Mercenary.program(:bowtie) do |p|
|
14
|
+
p.version Bowtie::VERSION
|
15
|
+
p.description "bowtie is a Jekyll-based API frontend development tool"
|
16
|
+
p.syntax 'bowtie <subcommand> [options]'
|
17
|
+
|
18
|
+
jekyll_commands = Jekyll::Command.subclasses
|
19
|
+
jekyll_commands.delete Jekyll::Commands::Serve
|
20
|
+
jekyll_commands.delete Jekyll::Commands::New
|
21
|
+
jekyll_commands.delete Jekyll::Commands::Build
|
22
|
+
|
23
|
+
bowtie_commands = Bowtie::Command.subclasses
|
24
|
+
|
25
|
+
(jekyll_commands + bowtie_commands).each { |c| c.init_with_program(p) }
|
26
|
+
|
27
|
+
p.action do |args, options|
|
28
|
+
if args.empty?
|
29
|
+
Jekyll.logger.error "A subcommand is required"
|
30
|
+
puts p
|
31
|
+
else
|
32
|
+
unless p.has_command?(args.first)
|
33
|
+
Jekyll.logger.abort_with "Invalid command. Use --help for more information"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# vim: set syntax=ruby
|
data/lib/bowtie.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'json'
|
3
|
+
require 'jekyll'
|
4
|
+
require 'rack'
|
5
|
+
require 'rack/streaming_proxy'
|
6
|
+
|
7
|
+
module Bowtie
|
8
|
+
module Middleware
|
9
|
+
autoload :Proxy, 'bowtie/middleware/proxy'
|
10
|
+
autoload :Static, 'bowtie/middleware/static'
|
11
|
+
autoload :Rewrite, 'bowtie/middleware/rewrite'
|
12
|
+
end
|
13
|
+
|
14
|
+
autoload :Settings, 'bowtie/settings'
|
15
|
+
autoload :VERSION, 'bowtie/version'
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'bowtie/command'
|
19
|
+
require 'bowtie/commands/serve'
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Bowtie
|
2
|
+
module Commands
|
3
|
+
class Serve < Command
|
4
|
+
class << self
|
5
|
+
def init_with_program(prog)
|
6
|
+
command = Jekyll::Commands::Serve.init_with_program(prog)
|
7
|
+
command.description 'Development server'
|
8
|
+
command.actions.clear
|
9
|
+
|
10
|
+
command.action do |args, options|
|
11
|
+
options['serving'] = true
|
12
|
+
options['watch'] = true unless options.key?('watch')
|
13
|
+
|
14
|
+
Jekyll::Commands::Build.process(options)
|
15
|
+
Bowtie::Commands::Serve.process(options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def process(options)
|
20
|
+
Rack::Server.start(app: application(options),
|
21
|
+
Port: options['port'] || 4000,
|
22
|
+
Host: options['host'],
|
23
|
+
daemonize: options['detach'])
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def application(options)
|
28
|
+
options = Jekyll.configuration(options)
|
29
|
+
|
30
|
+
Rack::Builder.new do
|
31
|
+
use Rack::CommonLogger
|
32
|
+
use Rack::ShowExceptions
|
33
|
+
use Bowtie::Middleware::Rewrite, options
|
34
|
+
|
35
|
+
# User management provided by BowTie /users/*
|
36
|
+
map '/users' do
|
37
|
+
use Bowtie::Middleware::Proxy
|
38
|
+
end
|
39
|
+
|
40
|
+
# Bowtie APIs available at /bowtie/*
|
41
|
+
map '/bowtie' do
|
42
|
+
use Bowtie::Middleware::Proxy
|
43
|
+
end
|
44
|
+
|
45
|
+
# Static file server
|
46
|
+
use Bowtie::Middleware::Static, urls: [''],
|
47
|
+
root: options['destination'],
|
48
|
+
index: 'index.html'
|
49
|
+
|
50
|
+
# Backend API proxy through BowTie
|
51
|
+
run Bowtie::Middleware::Proxy.new(nil)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Bowtie::Middleware
|
2
|
+
class Proxy < Rack::StreamingProxy::Proxy
|
3
|
+
def destination_uri(rack_request)
|
4
|
+
fqdn = Bowtie::Settings['project']['fqdn']['development']
|
5
|
+
base_url = "https://#{fqdn}"
|
6
|
+
path = rack_request.path
|
7
|
+
|
8
|
+
rack_request.env[:proxy_addon_headers] = {
|
9
|
+
'X-Forwarded-Host' => fqdn
|
10
|
+
}
|
11
|
+
|
12
|
+
URI.join(base_url, path).to_s
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Rewrites header values referencing the fqdn to make redirects behave
|
2
|
+
# nicely without requiring overrides on the BowTie platform.
|
3
|
+
|
4
|
+
module Bowtie::Middleware
|
5
|
+
class Rewrite
|
6
|
+
def initialize(app, options)
|
7
|
+
@app = app
|
8
|
+
@remote_base_url = "https://#{Bowtie::Settings['project']['fqdn']['development']}"
|
9
|
+
@local_base_url = "http://#{options['host']}:#{options['port']}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
status, headers, response = @app.call(env)
|
14
|
+
|
15
|
+
headers.each do |k, v|
|
16
|
+
headers[k] = v.gsub(@remote_base_url, @local_base_url)
|
17
|
+
end
|
18
|
+
|
19
|
+
[status, headers, response]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Bowtie::Middleware
|
2
|
+
class Static
|
3
|
+
def initialize(app, options)
|
4
|
+
@app = app
|
5
|
+
@options = options
|
6
|
+
@rack_static = Rack::Static.new(app, options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
status, response, headers = @rack_static.call(env)
|
11
|
+
status = status.to_i
|
12
|
+
|
13
|
+
if status != 200 && !status.between?(300, 399)
|
14
|
+
status, response, headers = @app.call(env)
|
15
|
+
status = status.to_i
|
16
|
+
|
17
|
+
if status == 404
|
18
|
+
env['PATH_INFO'] = '/404.html'
|
19
|
+
elsif status == 403
|
20
|
+
env['PATH_INFO'] = '/403.html'
|
21
|
+
elsif status.between?(500, 599)
|
22
|
+
env['PATH_INFO'] = '/500.html'
|
23
|
+
elsif status.between?(400, 499)
|
24
|
+
env['PATH_INFO'] = '/400.html'
|
25
|
+
else
|
26
|
+
return [status, response, headers]
|
27
|
+
end
|
28
|
+
|
29
|
+
return @rack_static.call(env)
|
30
|
+
else
|
31
|
+
[status, response, headers]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bowtie-io
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Kassemi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bowtie-io-rack-streaming-proxy
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
description: Client interface to the BowTie frontend development service
|
56
|
+
email:
|
57
|
+
- james@seedworthy.com
|
58
|
+
executables:
|
59
|
+
- bowtie
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- bin/bowtie
|
64
|
+
- lib/bowtie.rb
|
65
|
+
- lib/bowtie/command.rb
|
66
|
+
- lib/bowtie/commands/serve.rb
|
67
|
+
- lib/bowtie/middleware/proxy.rb
|
68
|
+
- lib/bowtie/middleware/rewrite.rb
|
69
|
+
- lib/bowtie/middleware/static.rb
|
70
|
+
- lib/bowtie/settings.rb
|
71
|
+
- lib/bowtie/version.rb
|
72
|
+
homepage: https://bowtie.io
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Contains command line interface for interacting with BowTie Projects and
|
96
|
+
tools for local development
|
97
|
+
test_files: []
|