partiarelic 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: 8b415c163efcaa7619f08703bf124bb468269066
4
+ data.tar.gz: ba73cfc99c201f4e9c51edadfe5c67034baf918c
5
+ SHA512:
6
+ metadata.gz: 11ef2a383e838b2e7a75d263d8d80192834393645d70b49c8a92baa22ec298c2b44e13bfac3a5b3c9a3f9199559156f44b922aad13e6708d4d6b422331c506ce
7
+ data.tar.gz: bc5f2b58bae88f4fdadfd4f50c091e4e25001ed7131afd4ea5bbd3e3e46b3cd6499a2960969c5ab4cf87210be381d09428532b42040f2c22959c2453f7d59d4b
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
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.4
5
+ - 2.4.0
6
+ - ruby-head
7
+ before_install: gem install bundler -v 1.14.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in partiarelic.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 shinya-watanabe
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,65 @@
1
+ # Partiarelic
2
+
3
+ [![Build Status](https://travis-ci.org/wata-gh/partiarelic.svg)](https://travis-ci.org/wata-gh/partiarelic)
4
+
5
+ Adds endpoint to enable New Relic manually.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'partiarelic'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install partiarelic
22
+
23
+ ## Usage
24
+
25
+ ### typical Rails app
26
+
27
+ ```ruby
28
+ # Gemfile
29
+ gem 'partiarelic', require: 'partiarelic/rails'
30
+ ```
31
+
32
+ then your Rails application will handle `/_newrelic/manual_start`.
33
+
34
+ ### rack application
35
+
36
+ ```ruby
37
+ # Gemfile
38
+ gem 'partiarelic'
39
+
40
+ # config.ru (middleware)
41
+ use Partiarelic::Middleware, path: '/_newrelic/manual_start'
42
+
43
+ # config.ru (mount)
44
+ map '/_newrelic/manual_start' do
45
+ run Partiarelic::App.new(path: '/_newrelic/manual_start')
46
+ end
47
+ ```
48
+
49
+ ## Development
50
+
51
+ ### Test
52
+
53
+ ```sh
54
+ $ rake spec
55
+ ```
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/wata-gh/partiarelic.
60
+
61
+
62
+ ## License
63
+
64
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
65
+
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "partiarelic"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ 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,26 @@
1
+ require 'pathname'
2
+
3
+ module Partiarelic
4
+ class App
5
+ def initialize(path: nil)
6
+ @path = path
7
+ end
8
+
9
+ ACCEPT_METHODS = ['GET', 'HEAD'].freeze
10
+
11
+ def call(env)
12
+ unless ACCEPT_METHODS.include?(env['REQUEST_METHOD']) && (@path ? env['PATH_INFO'] == @path : true)
13
+ return [404, {'Content-Type' => 'text/plain'}, []]
14
+ end
15
+
16
+ NewRelic::Agent.manual_start
17
+
18
+ headers = {'Content-Type' => 'text/plain'}
19
+ if env['REQUEST_METHOD'] == 'HEAD'
20
+ [200, headers, []]
21
+ else
22
+ [200, headers, [Socket.gethostname]]
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ require 'partiarelic/app'
2
+
3
+ module Partiarelic
4
+ class Middleware
5
+ def initialize(app, options={})
6
+ @app = app
7
+ @options = options
8
+ @partiarelic_app = App.new(options)
9
+ end
10
+
11
+ ACCEPT_METHODS = %w[GET HEAD].freeze
12
+
13
+ def call(env)
14
+ if env['PATH_INFO'] == @options[:path] && ACCEPT_METHODS.include?(env['REQUEST_METHOD'])
15
+ @partiarelic_app.call(env)
16
+ else
17
+ @app.call(env)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ require 'partiarelic'
2
+
3
+ if defined?(Rails)
4
+ module Partiarelic
5
+ class Railtie < Rails::Railtie
6
+ initializer 'partiarelic.rails_middleware' do |app|
7
+ app.middleware.use Partiarelic::Middleware, path: '/_newrelic/manual_start'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Partiarelic
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,3 @@
1
+ require 'partiarelic/version'
2
+ require 'partiarelic/app'
3
+ require 'partiarelic/middleware'
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'partiarelic/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'partiarelic'
8
+ spec.version = Partiarelic::VERSION
9
+ spec.authors = ['wata']
10
+ spec.email = ['wata.gm@gmail.com']
11
+
12
+ spec.summary = %q{Rack middleware and application to enable NewRelic agent.}
13
+ spec.description = %q{Rack middleware and application to enable NewRelic agent.}
14
+ spec.homepage = 'https://github.com/wata-gh/partiarelic'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.14'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ spec.add_development_dependency 'rack-test', '~> 0.6.3'
28
+ spec.add_development_dependency 'pry-byebug', '~> 3.4'
29
+ spec.add_development_dependency 'newrelic_rpm'
30
+
31
+ spec.add_dependency 'rack'
32
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: partiarelic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - wata
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.6.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: newrelic_rpm
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: rack
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Rack middleware and application to enable NewRelic agent.
112
+ email:
113
+ - wata.gm@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - bin/console
126
+ - bin/setup
127
+ - lib/partiarelic.rb
128
+ - lib/partiarelic/app.rb
129
+ - lib/partiarelic/middleware.rb
130
+ - lib/partiarelic/rails.rb
131
+ - lib/partiarelic/version.rb
132
+ - partiarelic.gemspec
133
+ homepage: https://github.com/wata-gh/partiarelic
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.5.2
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Rack middleware and application to enable NewRelic agent.
157
+ test_files: []