boxenprofiler 0.0.1

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: d3baa024f6f489a55edc42010a172d86483a0b22
4
+ data.tar.gz: 3f3d5f0cf683286f36e2bfd082e1d875cf062965
5
+ SHA512:
6
+ metadata.gz: 3949f941ee89f47e056270761b241b3656a98f2f053f8a586c15b3c6610fd0db1744456dccb4ef3eb55f8476a37964a1bc8d007fecc5e7c3ddfcd81fc535b96d
7
+ data.tar.gz: db30cb505a20f0dcb9478bb72c1682490d6eabd394215b15dadd23fbd357e4af0dbdbd7164e7686cb0bc3bbd23f39341d9b7d2a443d32df852b7d592eb2c3432
@@ -0,0 +1,5 @@
1
+ pkg/*.gem
2
+ coverage/
3
+ .coveralls.yml
4
+ .bundle
5
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format Fuubar
2
+ --color
@@ -0,0 +1,2 @@
1
+ Encoding:
2
+ Enabled: false
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ rvm:
5
+ - 2.2.2
6
+ - 2.2.1
7
+ - 2.2.0
8
+ - 2.1.6
9
+ - 2.0.0-p598
10
+ - 1.9.3-p551
11
+ notifications:
12
+ email: false
13
+ irc:
14
+ channels:
15
+ - irc.oftc.net#akerl
16
+ template:
17
+ - '%{repository}/%{branch}/%{build_number}: %{message} -- %{build_url}'
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Les Aker
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.
22
+
@@ -0,0 +1,24 @@
1
+ boxenprofiler
2
+ =========
3
+
4
+ [![Gem Version](https://img.shields.io/gem/v/boxenprofiler.svg)](https://rubygems.org/gems/boxenprofiler)
5
+ [![Dependency Status](https://img.shields.io/gemnasium/akerl/boxenprofiler.svg)](https://gemnasium.com/akerl/boxenprofiler)
6
+ [![Code Climate](https://img.shields.io/codeclimate/github/akerl/boxenprofiler.svg)](https://codeclimate.com/github/akerl/boxenprofiler)
7
+ [![Coverage Status](https://img.shields.io/coveralls/akerl/boxenprofiler.svg)](https://coveralls.io/r/akerl/boxenprofiler)
8
+ [![Build Status](https://img.shields.io/travis/akerl/boxenprofiler.svg)](https://travis-ci.org/akerl/boxenprofiler)
9
+ [![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)
10
+
11
+ Profiler for boxen runs, based heavily on [puppet-profiler](https://github.com/rodjek/puppet-profiler)
12
+
13
+ ## Usage
14
+
15
+ Instead of running `boxen`, run `boxenprofiler`. Bam!
16
+
17
+ ## Installation
18
+
19
+ gem install boxenprofiler
20
+
21
+ ## License
22
+
23
+ boxenprofiler is released under the MIT License. See the bundled LICENSE file for details.
24
+
@@ -0,0 +1,14 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ desc 'Run tests'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ desc 'Run Rubocop on the gem'
9
+ RuboCop::RakeTask.new(:rubocop) do |task|
10
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
11
+ task.fail_on_error = true
12
+ end
13
+
14
+ task default: [:spec, :rubocop, :build, :install]
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'boxenprofiler'
4
+
5
+ BoxenProfiler.new.run!
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'boxenprofiler'
3
+ s.version = '0.0.1'
4
+ s.date = Time.now.strftime('%Y-%m-%d')
5
+
6
+ s.summary = 'Profiler for boxen'
7
+ s.description = "Profiler for boxen"
8
+ s.authors = ['Les Aker']
9
+ s.email = 'me@lesaker.org'
10
+ s.homepage = 'https://github.com/akerl/boxenprofiler'
11
+ s.license = 'MIT'
12
+
13
+ s.files = `git ls-files`.split
14
+ s.test_files = `git ls-files spec/*`.split
15
+ s.executables = ['boxenprofiler']
16
+
17
+ s.add_development_dependency 'rubocop', '~> 0.32.0'
18
+ s.add_development_dependency 'rake', '~> 10.4.0'
19
+ s.add_development_dependency 'coveralls', '~> 0.8.0'
20
+ s.add_development_dependency 'rspec', '~> 3.3.0'
21
+ s.add_development_dependency 'fuubar', '~> 2.0.0'
22
+ end
@@ -0,0 +1,14 @@
1
+ require 'boxenprofiler/profiler'
2
+
3
+ ##
4
+ # Main BoxenProfiler class
5
+ module BoxenProfiler
6
+ class << self
7
+ ##
8
+ # Insert a helper .new() method for creating a new Gem object
9
+
10
+ def new(*args)
11
+ self::Profiler.new(*args)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,42 @@
1
+ ##
2
+ # Profile runtime definitions
3
+ module BoxenProfiler
4
+ REGEX_PATTERNS = [
5
+ /^Info: .*([A-Z][^\[]+)\[(.+?)\]: Evaluated in ([\d\.]+) seconds$/,
6
+ /^Notice: Compiled (catalog) .* environment ([^ ]+) in ([\d\.]+) seconds$/
7
+ ]
8
+
9
+ DEFAULT_RESULT_COUNT = 100
10
+
11
+ ##
12
+ # Profiler runtime class
13
+ class Profiler
14
+ def run!
15
+ results = parse(`#{command}`.split("\n"))
16
+ results.sort! { |a, b| b.last <=> a.last }
17
+ write results
18
+ end
19
+
20
+ private
21
+
22
+ def write(results)
23
+ results.lazy.take(DEFAULT_RESULT_COUNT).each do |pclass, name, time|
24
+ puts format('%6.2f - %s[%s]', time, pclass, name)
25
+ end
26
+ end
27
+
28
+ def parse(lines)
29
+ lines.each_with_object([]) do |line, acc|
30
+ next unless REGEX_PATTERNS.find { |pattern| line.match(pattern) }
31
+ pclass, name, time = Regexp.last_match[1..3]
32
+ time = time.to_f
33
+ next if time.zero?
34
+ acc << [pclass, name, time]
35
+ end
36
+ end
37
+
38
+ def command
39
+ 'boxen --profile --no-color'
40
+ end
41
+ end
42
+ end
@@ -0,0 +1 @@
1
+ require 'spec_helper'
@@ -0,0 +1,10 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
5
+ SimpleCov.start do
6
+ add_filter '/spec/'
7
+ end
8
+
9
+ require 'rspec'
10
+ require 'boxenprofiler'
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: boxenprofiler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Les Aker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.32.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.32.0
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.4.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.4.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.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.8.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: 3.3.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: fuubar
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.0
83
+ description: Profiler for boxen
84
+ email: me@lesaker.org
85
+ executables:
86
+ - boxenprofiler
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".rubocop.yml"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE
96
+ - README.md
97
+ - Rakefile
98
+ - bin/boxenprofiler
99
+ - boxenprofiler.gemspec
100
+ - lib/boxenprofiler.rb
101
+ - lib/boxenprofiler/profiler.rb
102
+ - spec/boxenprofiler_spec.rb
103
+ - spec/spec_helper.rb
104
+ homepage: https://github.com/akerl/boxenprofiler
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.4.5
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Profiler for boxen
128
+ test_files:
129
+ - spec/boxenprofiler_spec.rb
130
+ - spec/spec_helper.rb