production_toolkit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ac5cbd01cdc200f3745c3c6d5284e7415e663baf
4
+ data.tar.gz: ef2ec20334c5f8d356464ad1812bdd18d99ff59a
5
+ SHA512:
6
+ metadata.gz: 4916bce65c3db2672d2efd8ed236682dfcca8c7c7d3efb33cf84e79a218bf46bfc17057c7ba025df6d4067e27d764511ddf151d2cf7d83b7873b364674940ee3
7
+ data.tar.gz: 7936a044ee6f88722de9d8ac72c24e292f167f9db335a302c6b563008a28767a4cf4e076464efabcfe7d71be59425fbe42f08baa5ddd131fa2b9b78875097f58
@@ -0,0 +1,2 @@
1
+ coverage
2
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,33 @@
1
+ Production Toolkit
2
+ ==================
3
+
4
+ [![Build Status](https://travis-ci.org/sealink/production_toolkit.png?branch=master)](https://travis-ci.org/sealink/production_toolkit)
5
+ [![Coverage Status](https://coveralls.io/repos/sealink/production_toolkit/badge.png)](https://coveralls.io/r/sealink/production_toolkit)
6
+ [![Dependency Status](https://gemnasium.com/sealink/production_toolkit.png?travis)](https://gemnasium.com/sealink/production_toolkit)
7
+ [![Code Climate](https://codeclimate.com/github/sealink/production_toolkit.png)](https://codeclimate.com/github/sealink/production_toolkit)
8
+
9
+ # DESCRIPTION
10
+
11
+ Integrates with SeaLink's production requirements for quality projects
12
+
13
+ # INSTALLATION
14
+
15
+ gem install production_toolkit
16
+
17
+ or add to your Gemfile:
18
+ gem 'production_toolkit'
19
+
20
+ Also add the relevant dependencies of your project:
21
+
22
+ gem 'pansophy', '~> 0.3'
23
+ gem 'unicorn'
24
+ gem 'newrelic_rpm'
25
+ gem 'le'
26
+ gem 'rollbar', '~> 2.4.0'
27
+
28
+ # SYNOPSIS
29
+
30
+ require 'production_toolkit'
31
+
32
+ For examples on most usage see the tests in the spec directory.
33
+ As these contain many basic examples with expected output.
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ desc 'Default: run specs.'
4
+ task :default => :spec
5
+
6
+ require 'rspec/core/rake_task'
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new do |t|
10
+ t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
11
+ # Put spec opts in a file named .rspec in root
12
+ end
@@ -0,0 +1,15 @@
1
+ require 'production_toolkit/railtie' if defined?(Rails)
2
+
3
+ TOOL_DEFAULTS = {
4
+ config_fetcher: 'pansophy',
5
+ error_reporting: 'rollbar',
6
+ log_files: 'le',
7
+ performance_monitor: 'newrelic_rpm',
8
+ server: 'unicorn'
9
+ }
10
+
11
+ TOOL_DEFAULTS.each_pair do |tool_name, default|
12
+ tool = ENV.fetch(tool_name.to_s.upcase, default)
13
+ puts "requriing for #{tool_name} - found #{tool}"
14
+ require tool unless tool == 'off'
15
+ end
@@ -0,0 +1,8 @@
1
+ if defined?(Rails)
2
+ if Rails.env.production?
3
+ require 'le'
4
+ log_entries_key = Rails.application.secrets.log_entries_key
5
+ le = Le.new(log_entries_key, ssl: true)
6
+ Rails.logger = ActiveSupport::TaggedLogging.new(le)
7
+ end
8
+ end
@@ -0,0 +1,59 @@
1
+ class RollbarConfig
2
+ attr_reader :server_token, :client_token, :environment
3
+
4
+ def initialize(config)
5
+ @enabled = config.fetch(:enabled, false)
6
+ if enabled?
7
+ @server_token = config.fetch(:server_token)
8
+ @client_token = config.fetch(:client_token)
9
+ @environment = config.fetch(:environment)
10
+ end
11
+ end
12
+
13
+ def enabled?
14
+ @enabled
15
+ end
16
+ end
17
+
18
+ class RollbarConfigurator
19
+ ERROR_MESSAGE = 'rollbar not defined in secrets.yml'
20
+
21
+ def initialize(configuration)
22
+ @configuration = configuration
23
+ end
24
+
25
+ def configure
26
+ notify_missing_configuration! unless configuration.present?
27
+ configure_rollbar
28
+ end
29
+
30
+ def rollbar_config
31
+ @rollbar_config ||= RollbarConfig.new(configuration.symbolize_keys)
32
+ end
33
+
34
+ private
35
+
36
+ def configure_rollbar
37
+ return unless rollbar_config.enabled?
38
+
39
+ require 'rollbar'
40
+
41
+ ::Rollbar.configure do |config|
42
+ config.enabled = true
43
+ config.access_token = rollbar_config.server_token
44
+ config.environment = rollbar_config.environment
45
+ end
46
+ end
47
+
48
+ def notify_missing_configuration!
49
+ fail ERROR_MESSAGE
50
+ end
51
+ end
52
+
53
+ config = if defined?(Rails)
54
+ Rails.application.secrets.rollbar
55
+ end
56
+ configurator = RollbarConfigurator.new(config)
57
+ configurator.configure
58
+
59
+ Rails.application.config.rollbar = configurator.rollbar_config if defined?(Rails)
@@ -0,0 +1,8 @@
1
+ module ProductionToolkit
2
+ class Railtie < Rails::Railtie
3
+ config.before_initialize do
4
+ require 'production_toolkit/initializers/logging'
5
+ require 'production_toolkit/initializers/rollbar'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module ProductionToolkit
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'production_toolkit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "production_toolkit"
8
+ spec.version = ProductionToolkit::VERSION
9
+ spec.authors = ["Michael Noack"]
10
+ spec.email = ["support@travellink.com.au"]
11
+ spec.description = %q{Integrate production gems for high quality projects.}
12
+ spec.summary = %q{Integrate production gems for high quality projects.}
13
+ spec.homepage = 'http://github.com/sealink/production_toolkit'
14
+
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency 'rollbar', '~> 2.4'
23
+ spec.add_development_dependency 'unicorn', '~> 4.8'
24
+ spec.add_development_dependency 'pansophy', '~> 0.5'
25
+ spec.add_development_dependency 'le', '~> 2.6'
26
+ spec.add_development_dependency 'newrelic_rpm', '~> 3.9'
27
+
28
+ spec.add_development_dependency 'bundler'
29
+ spec.add_development_dependency 'rake'
30
+ spec.add_development_dependency 'rspec'
31
+ spec.add_development_dependency 'rspec-its'
32
+ spec.add_development_dependency 'simplecov'
33
+ spec.add_development_dependency 'simplecov-rcov'
34
+ spec.add_development_dependency 'coveralls'
35
+ spec.add_development_dependency 'travis'
36
+ spec.add_development_dependency 'pry-byebug'
37
+ end
metadata ADDED
@@ -0,0 +1,250 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: production_toolkit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Noack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rollbar
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.4'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: unicorn
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pansophy
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: le
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: newrelic_rpm
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
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: rake
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
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-its
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov-rcov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: coveralls
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: travis
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: pry-byebug
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ description: Integrate production gems for high quality projects.
210
+ email:
211
+ - support@travellink.com.au
212
+ executables: []
213
+ extensions: []
214
+ extra_rdoc_files: []
215
+ files:
216
+ - ".gitignore"
217
+ - Gemfile
218
+ - README.md
219
+ - Rakefile
220
+ - lib/production_toolkit.rb
221
+ - lib/production_toolkit/initializers/logging.rb
222
+ - lib/production_toolkit/initializers/rollbar.rb
223
+ - lib/production_toolkit/railtie.rb
224
+ - lib/production_toolkit/version.rb
225
+ - production_toolkit.gemspec
226
+ homepage: http://github.com/sealink/production_toolkit
227
+ licenses:
228
+ - MIT
229
+ metadata: {}
230
+ post_install_message:
231
+ rdoc_options: []
232
+ require_paths:
233
+ - lib
234
+ required_ruby_version: !ruby/object:Gem::Requirement
235
+ requirements:
236
+ - - ">="
237
+ - !ruby/object:Gem::Version
238
+ version: '0'
239
+ required_rubygems_version: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ requirements: []
245
+ rubyforge_project:
246
+ rubygems_version: 2.4.8
247
+ signing_key:
248
+ specification_version: 4
249
+ summary: Integrate production gems for high quality projects.
250
+ test_files: []