passenger_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c96538b9f4c72d79d7c4951a498b812d4cf9efc0
4
+ data.tar.gz: c1af38bf1c52e7f04107f42a246202720fcb4539
5
+ SHA512:
6
+ metadata.gz: 9b4f4fa6a7a82860e5b1a2a9a0606e9c227aee498bd29cd126d34856857ffaa04cac99bb3fd6957c06eb833c618493a80c3b77928619d19588e1c519e0c722f2
7
+ data.tar.gz: f87b4528041e5440bccc496cb32be3a24b326d430d12cec725b5847a73170c8150dae5908d23cd51e58a01beddcc96ef4d8e7bc62af8efb3d9bc0da0528a5edf
data/.dockerignore ADDED
@@ -0,0 +1,6 @@
1
+ .bundle
2
+ .git
3
+ Gemfile.lock
4
+ coverage
5
+ gemfiles
6
+ vendor
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ /gemfiles/
12
+ /vendor/
data/.rubocop.yml ADDED
@@ -0,0 +1,63 @@
1
+ AllCops:
2
+ EnabledByDefault: true
3
+ TargetRubyVersion: 2.4
4
+
5
+ ### customize
6
+
7
+ Layout/MultilineAssignmentLayout:
8
+ EnforcedStyle: same_line
9
+
10
+ Metrics/LineLength:
11
+ IgnoredPatterns:
12
+ - '^ +spec\.(summary|description) +='
13
+
14
+ Metrics/ParameterLists:
15
+ CountKeywordArgs: false
16
+
17
+ Style/Lambda:
18
+ EnforcedStyle: literal
19
+
20
+ Style/LambdaCall:
21
+ EnforcedStyle: braces
22
+
23
+ Style/HashSyntax:
24
+ Exclude:
25
+ - "**/Rakefile"
26
+
27
+ Style/TrailingCommaInArguments:
28
+ EnforcedStyleForMultiline: comma
29
+
30
+ Style/TrailingCommaInLiteral:
31
+ EnforcedStyleForMultiline: comma
32
+
33
+ ### disabled
34
+
35
+ Lint/UnneededSplatExpansion:
36
+ Enabled: false
37
+
38
+ Style/Copyright:
39
+ Enabled: false
40
+
41
+ Style/Documentation:
42
+ Enabled: false
43
+
44
+ Style/DocumentationMethod:
45
+ Enabled: false
46
+
47
+ Style/IfUnlessModifier:
48
+ Enabled: false
49
+
50
+ Style/MethodCallWithArgsParentheses:
51
+ Enabled: false
52
+
53
+ Style/MethodCalledOnDoEndBlock:
54
+ Enabled: false
55
+
56
+ Style/MissingElse:
57
+ Enabled: false
58
+
59
+ Style/SingleLineBlockParams:
60
+ Enabled: false
61
+
62
+ Style/VariableInterpolation:
63
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,30 @@
1
+ dist: trusty
2
+ sudo: false
3
+ language: ruby
4
+
5
+ rvm:
6
+ - 2
7
+ - 1.8
8
+
9
+ install:
10
+ - bundle install --jobs=3 --retry=3
11
+ - appraisal install
12
+
13
+ before_script:
14
+ - |
15
+ if [ "$TRAVIS_PULL_REQUEST" = false -a "$TRAVIS_RUBY_VERSION" = 2 ]; then
16
+ curl -fL -o cc-test-reporter \
17
+ https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
18
+ chmod +x cc-test-reporter
19
+ fi
20
+
21
+ script:
22
+ - if [ -e cc-test-reporter ]; then export COVERAGE=true; fi
23
+ - appraisal rake
24
+ - if [ "$TRAVIS_RUBY_VERSION" = 2 ]; then rubocop -DES; fi
25
+
26
+ after_script:
27
+ - |
28
+ if [ -e cc-test-reporter ]; then
29
+ ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
30
+ fi
data/Appraisals ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'passenger-5.0.10' do
4
+ gem 'passenger', '5.0.10'
5
+ end
6
+
7
+ appraise 'passenger-5.0' do
8
+ gem 'passenger', '~> 5.0.10'
9
+ end
10
+
11
+ appraise 'passenger-5.1.0' do
12
+ gem 'passenger', '5.1.0'
13
+ end
14
+
15
+ appraise 'passenger-5.1' do
16
+ gem 'passenger', '~> 5.1.0'
17
+ end
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at m.ishihara@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in passenger_api.gemspec
8
+ gemspec
9
+
10
+ if RUBY_VERSION > '2.0'
11
+ gem 'rubocop', '0.49.1'
12
+ end
13
+
14
+ if RUBY_VERSION < '2.3'
15
+ gem 'rack', '< 2'
16
+ end
17
+
18
+ if RUBY_VERSION < '1.9'
19
+ gem 'json'
20
+ gem 'rack-test', '< 0.7'
21
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Masaki Takeuchi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # PassengerAPI
2
+
3
+ PassengerAPI is a Rack application to access Passenger internal APIs.
4
+
5
+ [![Build Status](https://travis-ci.org/m4i/passenger_api.svg?branch=master)](https://travis-ci.org/m4i/passenger_api)
6
+ [![Test Coverage](https://codeclimate.com/github/m4i/passenger_api/badges/coverage.svg)](https://codeclimate.com/github/m4i/passenger_api/coverage)
7
+ [![Code Climate](https://codeclimate.com/github/m4i/passenger_api/badges/gpa.svg)](https://codeclimate.com/github/m4i/passenger_api)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'passenger_api'
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Add this line to your application's config.ru:
20
+
21
+ ```ruby
22
+ map('/passenger') { run PassengerAPI.new }
23
+ ```
24
+
25
+ Then, access API.
26
+
27
+ ```
28
+ $ passenger start -d
29
+ $ curl localhost:3000/passenger/pool.txt
30
+ ----------- General information -----------
31
+ Max pool size : 6
32
+ App groups : 1
33
+ Processes : 1
34
+ Requests in top-level queue : 0
35
+
36
+ ----------- Application groups -----------
37
+ /app/public (development):
38
+ App root: /app
39
+ Requests in queue: 0
40
+ * PID: 25915 Sessions: 1 Processed: 3 Uptime: 30s
41
+ CPU: 0% Memory : 7M Last used: 0s ago
42
+ ```
43
+
44
+ Passenger internal APIs are undocumented. If you want to know about them, please see https://github.com/phusion/passenger/issues/1407.
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
+
50
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/m4i/passenger_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
55
+
56
+ ## License
57
+
58
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
59
+
60
+ ## Code of Conduct
61
+
62
+ Everyone interacting in the PassengerAPI project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/m4i/passenger_api/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'passenger_api'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require 'pry'
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'passenger_api/request'
4
+ require 'passenger_api/version'
5
+
6
+ class PassengerAPI
7
+ def initialize
8
+ require 'passenger_api/ext'
9
+ end
10
+
11
+ def call(env)
12
+ to_rack_response(call_api(build_argv(Request.new(env))))
13
+ end
14
+
15
+ private
16
+
17
+ def build_argv(req)
18
+ argv = [req.method, req.path]
19
+ argv << '--data' << req.body unless req.body.empty?
20
+ argv
21
+ end
22
+
23
+ def call_api(argv)
24
+ argv += ['--show-headers']
25
+ catch :response do
26
+ PhusionPassenger::Config::ApiCallCommand.new(argv).run
27
+ end
28
+ end
29
+
30
+ def to_rack_response(res)
31
+ # for Ruby 1.8.7
32
+ # headers = res.each_capitalized.to_h
33
+ headers = {}
34
+ res.each_capitalized { |n, v| headers[n] = v }
35
+
36
+ [res.code, headers, [res.body]]
37
+ end
38
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ unless defined?(PhusionPassenger)
4
+ require 'phusion_passenger'
5
+ PhusionPassenger.locate_directories
6
+ end
7
+ PhusionPassenger.require_passenger_lib 'config/api_call_command'
8
+
9
+ module PhusionPassenger
10
+ module Config
11
+ class ApiCallCommand
12
+ private
13
+
14
+ def print_headers(response)
15
+ throw :response, response
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PassengerAPI
4
+ class Request
5
+ def initialize(env)
6
+ @env = env
7
+ end
8
+
9
+ def method
10
+ @env['REQUEST_METHOD']
11
+ end
12
+
13
+ def path
14
+ path = @env['PATH_INFO']
15
+ path = '/' if path.empty?
16
+ path += "?#{@env['QUERY_STRING']}" unless @env['QUERY_STRING'].empty?
17
+ path
18
+ end
19
+
20
+ def body
21
+ @_body ||= @env['rack.input'].read
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PassengerAPI
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'passenger_api/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'passenger_api'
9
+ spec.version = PassengerAPI::VERSION
10
+ spec.authors = ['Masaki Takeuchi']
11
+ spec.email = ['m.ishihara@gmail.com']
12
+
13
+ spec.summary = 'A Rack application to access Passenger internal APIs'
14
+ spec.description = 'PassengerAPI is a Rack application to access Passenger internal APIs.'
15
+ spec.homepage = 'https://github.com/m4i/passenger_api'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.required_ruby_version = '>= 1.8.7'
26
+
27
+ spec.add_dependency 'passenger', '>= 5.0.10'
28
+
29
+ spec.add_development_dependency 'bundler', '~> 1.15'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'minitest', '~> 5.0'
32
+ spec.add_development_dependency 'appraisal'
33
+ spec.add_development_dependency 'rack-test'
34
+ spec.add_development_dependency 'simplecov'
35
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: passenger_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masaki Takeuchi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: passenger
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.10
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 5.0.10
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: appraisal
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: PassengerAPI is a Rack application to access Passenger internal APIs.
112
+ email:
113
+ - m.ishihara@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".dockerignore"
119
+ - ".gitignore"
120
+ - ".rubocop.yml"
121
+ - ".travis.yml"
122
+ - Appraisals
123
+ - CODE_OF_CONDUCT.md
124
+ - Gemfile
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - bin/console
129
+ - bin/setup
130
+ - lib/passenger_api.rb
131
+ - lib/passenger_api/ext.rb
132
+ - lib/passenger_api/request.rb
133
+ - lib/passenger_api/version.rb
134
+ - passenger_api.gemspec
135
+ homepage: https://github.com/m4i/passenger_api
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: 1.8.7
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.6.11
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: A Rack application to access Passenger internal APIs
159
+ test_files: []