puma-clocker 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/puma/clocker.rb +21 -0
- data/lib/puma/clocker/seconds_calculator.rb +40 -0
- data/lib/puma/clocker/version.rb +5 -0
- data/output.png +0 -0
- data/puma-clocker.gemspec +26 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 452fd3cef9ea25e9d0d46bd92b48ef77cf78d35f
|
4
|
+
data.tar.gz: 39f1d889790a5a7749ce1f6e5aa23362849ebdb5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cf746b1cf533d29580e9d8bb7e51cd5750aa0c0c1d95a87c7481fd24c6ee064a0fb30a74055f2aa7ca63372bef2f34a8214724349b39c8b4255e86e51e19f18c
|
7
|
+
data.tar.gz: 3a8beaee3624e6a5769c7fe0234c47f2ada4bc16d54a13a68606d2b5e4e9ca7823a983f54ea3e11fa27302c796ea2f46320488023b7ed1a5621db104d6df2bd9
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
puma-clocker
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0.0
|
5
|
+
- 2.2.0
|
6
|
+
env: RAKE_ENV=test RAILS_ENV=test
|
7
|
+
before_install:
|
8
|
+
- 'gem install bundler'
|
9
|
+
script:
|
10
|
+
- 'bundle exec rspec'
|
11
|
+
notifications:
|
12
|
+
email:
|
13
|
+
recipients:
|
14
|
+
- humzashah+travis@gmail.com
|
15
|
+
on_success: never
|
16
|
+
on_failure: always
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 TODO: Write your name
|
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,31 @@
|
|
1
|
+
# Puma::Clocker
|
2
|
+
|
3
|
+
A super-basic gem to calculate the speed of your Rails project's `rails server` command.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add the following to your Rails project's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'puma-clocker'
|
12
|
+
```
|
13
|
+
|
14
|
+
Bundle it!
|
15
|
+
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Time-calculations are done based on the exact time you executed the command. For this, the system's `date` command is used. Its output is passed to `rails s` as an environment variable, like so:
|
20
|
+
|
21
|
+
STARTING_PUMA_ON=$(date) rails s
|
22
|
+
|
23
|
+
or as an abbreviated variable, like so:
|
24
|
+
|
25
|
+
SPO=$(date) rails s
|
26
|
+
|
27
|
+
The time-calculation result will appear in the last line shown right after Puma's own messages:
|
28
|
+
|
29
|
+
![alt text](https://github.com/humzashah/puma-clocker/blob/master/output.png "Passed seconds appear in last line")
|
30
|
+
|
31
|
+
If you are loading other environment variables from a `.env` file, you might be tempted to do the same for `SPO`. However, keep in mind that the start-time considered then will not be the true starting time of the command.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "puma/clocker"
|
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
|
data/bin/setup
ADDED
data/lib/puma/clocker.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "puma"
|
2
|
+
require "puma/clocker/version"
|
3
|
+
|
4
|
+
unless Puma::Server.instance_methods.include?(:handle_servers)
|
5
|
+
raise "puma-clocker v#{Puma::Clocker::VERSION} is incompatible with puma v#{Puma::Const::PUMA_VERSION}. :("
|
6
|
+
end
|
7
|
+
|
8
|
+
require_relative "clocker/seconds_calculator"
|
9
|
+
|
10
|
+
module Puma
|
11
|
+
module Clocker
|
12
|
+
def handle_servers
|
13
|
+
SecondsCalculator.run(ENV['STARTING_PUMA_ON'] || ENV['SPO'])
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Server
|
19
|
+
prepend Clocker
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Accepts default return value of 'date' system command e.g.
|
2
|
+
# Wed Apr 15 19:29:51 CEST 2015
|
3
|
+
|
4
|
+
# Also accepts any argument processable by Time#parse
|
5
|
+
|
6
|
+
class SecondsCalculator < String
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def run(time_string)
|
11
|
+
puts(new(time_string)) if time_string
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def initialize(time_string)
|
19
|
+
super(time_string)
|
20
|
+
find_start_time
|
21
|
+
find_time_taken
|
22
|
+
make_presentable
|
23
|
+
end
|
24
|
+
|
25
|
+
def find_start_time
|
26
|
+
@start_time = Time.parse(self)
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_time_taken
|
30
|
+
@time_taken = current_time - @start_time
|
31
|
+
end
|
32
|
+
|
33
|
+
def current_time
|
34
|
+
Time.new
|
35
|
+
end
|
36
|
+
|
37
|
+
def make_presentable
|
38
|
+
self.gsub!(/^.*$/, "Started server in #{@time_taken} seconds.")
|
39
|
+
end
|
40
|
+
end
|
data/output.png
ADDED
Binary file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'puma/clocker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "puma-clocker"
|
8
|
+
spec.version = Puma::Clocker::VERSION
|
9
|
+
spec.authors = ["Syed Humza Shah"]
|
10
|
+
spec.email = ["humzashah+github@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Rails-on-Puma? Clock your 'rails server' command!"
|
13
|
+
spec.homepage = "https://github.com/humzashah/puma-clocker"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.required_ruby_version = '>= 2.0.0'
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", ">= 1.8"
|
23
|
+
spec.add_development_dependency "rake", ">= 10.0"
|
24
|
+
spec.add_development_dependency "puma"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puma-clocker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Syed Humza Shah
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-15 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.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
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: puma
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- humzashah+github@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .ruby-gemset
|
78
|
+
- .ruby-version
|
79
|
+
- .travis.yml
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- lib/puma/clocker.rb
|
87
|
+
- lib/puma/clocker/seconds_calculator.rb
|
88
|
+
- lib/puma/clocker/version.rb
|
89
|
+
- output.png
|
90
|
+
- puma-clocker.gemspec
|
91
|
+
homepage: https://github.com/humzashah/puma-clocker
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.0.0
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.4.6
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Rails-on-Puma? Clock your 'rails server' command!
|
115
|
+
test_files: []
|