resource_monitor 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d2f558aa24ed692b92657bca03260f2b16c4dcb
4
- data.tar.gz: 951c07c6590528a64ec2b689f2f6a7e7af6cdc9b
3
+ metadata.gz: b9cff3d45a83f8e83d3297d05360bc74aabf34e7
4
+ data.tar.gz: 61dd96132acfdf3b75fa5ffd61f11c1e1c538115
5
5
  SHA512:
6
- metadata.gz: c72ce0bac76d767f0d92a11c3687e14af5a1ff9829d9daf5c85c10ac8d0fd8e339648c0e358ac532fcca043165e476733fc4b3ebe40c07251e936e23b4153624
7
- data.tar.gz: 23cd4a512529aca82144f698f03bf1ce7739a66e293ca0e5fe6d1bffccf6ff659ee91897600d92f6e905a54cea9ccc11be1779d47cdfdd91b20727ef779f8412
6
+ metadata.gz: 11843bbb8f9c150e0687f78fdaa7f936d04682e45cf398e5f96cbc56dcd3651088142e1de4ed1a17d4d5b9d8fd3fd0830d261813925f3d9010502f6a3c5868c8
7
+ data.tar.gz: 117e13d29e5ed610285f992c495256815881b0cce37a5fdd73d9bb2135ccab1f60739f41c9b5302d4d88442d0122a83d966024feb7ff6107eb1585e6cb99621a
File without changes
data/README.md CHANGED
@@ -8,7 +8,9 @@ Creates a simple page under /resources/ that is updated with CPU/RAM usage in re
8
8
 
9
9
  Although not a major performance hog, this should only be run in production when there is evidence of resource overuse, look under the Usage section for instructions for disabling the gem.
10
10
 
11
- Current Project Status: Usable
11
+ Latest Version: 0.1.2
12
+ Last Feature Set: Engine created, no need to manually install dashboard.
13
+ Recommended Installation: Uninstall dashboard, then remove Gemfile.lock and rebundle.
12
14
 
13
15
  ## Installation
14
16
 
@@ -22,11 +24,7 @@ And then execute:
22
24
 
23
25
  $ bundle install
24
26
 
25
- This following line will add a set of views/controllers/and channels into your app.
26
-
27
- $ rake resource_monitor:install_dashboard
28
-
29
- And then add the following to the top of your application.rb file
27
+ Add the following to the top of your application.rb file
30
28
  You can also only add it to the controllers you think may be causing some issues.
31
29
 
32
30
  ```ruby
@@ -37,15 +35,6 @@ def resource_monitor_app
37
35
  ResourceMonitor.benchmark(self)
38
36
  end
39
37
  ```
40
-
41
- ## Uninstall
42
-
43
- If you added the dashboard to your project, you can remove it using this.
44
-
45
- $ rake resource_monitor:uninstall_dashboard
46
-
47
- This will leave behind a "resource" folder in your views but it's less risky than removing folders from your views folder.
48
-
49
38
  ## Usage
50
39
 
51
40
  You can try out the gem by using
@@ -58,7 +47,7 @@ Once inside irb, you can use the following
58
47
  ResourceMonitor.benchmark(self)
59
48
  ```
60
49
 
61
- Install the dashboard, deploy and browse to /resources/.
50
+ Bundle install and browse to /resources/.
62
51
 
63
52
  If you want to disable this, you can easily comment out the contents of resource_monitor_app or use an ENV variable such as below.
64
53
 
data/Rakefile CHANGED
@@ -1,2 +1,38 @@
1
- require "bundler/gem_tasks"
2
- Dir.glob('lib/tasks/*.rake').each {|r| import r}
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'ResourceMonitor'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ #load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+ load 'lib/tasks/resource_monitor_tasks.rake'
23
+
24
+
25
+
26
+ require 'bundler/gem_tasks'
27
+
28
+ require 'rake/testtask'
29
+
30
+ Rake::TestTask.new(:test) do |t|
31
+ t.libs << 'lib'
32
+ t.libs << 'test'
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = false
35
+ end
36
+
37
+
38
+ task default: :test
@@ -0,0 +1,8 @@
1
+ module ResourceMonitor
2
+ class ResourceChannel < ApplicationCable::Channel
3
+ def subscribed
4
+ stream_from "resources"
5
+ ResourceMonitor.benchmark()
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module ResourceMonitor
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module ResourceMonitor
2
+ class ResourceController < ApplicationController
3
+ def index
4
+ render layout: false
5
+ end
6
+ end
7
+ end
@@ -7,7 +7,7 @@
7
7
  <script>
8
8
  App.cable = ActionCable.createConsumer("//<%= request.host_with_port %>/cable");
9
9
  //App.cable = ActionCable.createConsumer("ws://localhost:3000/websocket");
10
- App.data = App.cable.subscriptions.create({ channel: "ResourceChannel" }, {
10
+ App.data = App.cable.subscriptions.create({ channel: "ResourceMonitor::ResourceChannel" }, {
11
11
  received: function(data) {
12
12
  var json = JSON.parse(data)
13
13
  var process_id = json['process_id']
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ ResourceMonitor::Engine.routes.draw do
2
+ get '/' => 'resource#index'
3
+ end
@@ -0,0 +1,5 @@
1
+ module ResourceMonitor
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace ResourceMonitor
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module ResourceMonitor
2
- VERSION = "0.1.1"
2
+ VERSION = '0.1.2'
3
3
  end
@@ -1,5 +1,5 @@
1
+ require "resource_monitor/engine"
1
2
  require "resource_monitor/version"
2
- require "resource_monitor/railtie" if defined?(Rails)
3
3
 
4
4
  module ResourceMonitor
5
5
  def self.benchmark(controller=nil)
@@ -0,0 +1,31 @@
1
+ namespace :resource_monitor do
2
+ # Works perfectly as a quick test environment.
3
+ task :console do
4
+ # require 'irb'
5
+ # require 'irb/completion'
6
+ # require 'resource_monitor' # You know what to do.
7
+ # ARGV.clear
8
+ # IRB.start
9
+ puts "This functionality is broken in engine mode. Research further."
10
+ end
11
+
12
+ # Works correctly.
13
+ task :install_dashboard do
14
+ if defined?(Rails)
15
+ puts "Add the following to your routes/config.rb\n"
16
+ puts "mount ResourceMonitor::Engine => '/resources'"
17
+ else
18
+ puts "This installer should be run inside a Rails project."
19
+ end
20
+ end
21
+
22
+ # Does nothing at all.
23
+ task :uninstall_dashboard do
24
+ if defined?(Rails)
25
+ puts "Remove the following to your routes/config.rb\n"
26
+ puts "mount ResourceMonitor::Engine => '/resources'"
27
+ else
28
+ puts "This uninstaller should be run inside a Rails project."
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resource_monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lazaro Herrera
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-09 00:00:00.000000000 Z
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.2
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.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -17,7 +31,7 @@ dependencies:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
33
  version: '1.14'
20
- type: :development
34
+ type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
@@ -31,7 +45,7 @@ dependencies:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
47
  version: '10.0'
34
- type: :development
48
+ type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
@@ -45,7 +59,7 @@ dependencies:
45
59
  - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
- type: :development
62
+ type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
@@ -60,21 +74,18 @@ executables: []
60
74
  extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
63
- - ".gitignore"
64
- - CODE_OF_CONDUCT.md
65
- - Gemfile
66
- - LICENSE.txt
77
+ - MIT-LICENSE
67
78
  - README.md
68
79
  - Rakefile
69
- - app/channels/resource_channel.rb
70
- - app/controllers/resource_controller.rb
71
- - app/views/resource/index.html.erb
72
- - bin/setup
80
+ - app/channels/resource_monitor/resource_channel.rb
81
+ - app/controllers/resource_monitor/application_controller.rb
82
+ - app/controllers/resource_monitor/resource_controller.rb
83
+ - app/views/resource_monitor/resource/index.html.erb
84
+ - config/routes.rb
73
85
  - lib/resource_monitor.rb
74
- - lib/resource_monitor/railtie.rb
86
+ - lib/resource_monitor/engine.rb
75
87
  - lib/resource_monitor/version.rb
76
- - lib/tasks/rm_console.rake
77
- - resource_monitor.gemspec
88
+ - lib/tasks/resource_monitor_tasks.rake
78
89
  homepage: http://writecodeeveryday.github.io/projects/resource_monitor
79
90
  licenses:
80
91
  - MIT
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
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 lazherrera@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 DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in resource_monitor.gemspec
4
- gemspec
@@ -1,6 +0,0 @@
1
- class ResourceChannel < ApplicationCable::Channel
2
- def subscribed
3
- stream_from "resources"
4
- ResourceMonitor.benchmark()
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- class ResourceController < ApplicationController
2
- def index
3
- render layout: false
4
- end
5
- end
data/bin/setup DELETED
@@ -1,8 +0,0 @@
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
@@ -1,5 +0,0 @@
1
- class ResourceMonitor::Railtie < Rails::Railtie
2
- rake_tasks do
3
- load 'tasks/rm_console.rake'
4
- end
5
- end
@@ -1,39 +0,0 @@
1
- namespace :resource_monitor do
2
- # Works perfectly as a quick test environment.
3
- task :console do
4
- require 'irb'
5
- require 'irb/completion'
6
- require 'resource_monitor' # You know what to do.
7
- ARGV.clear
8
- IRB.start
9
- end
10
-
11
- # Works correctly.
12
- task :install_dashboard do
13
- if defined?(Rails)
14
- path = Gem.loaded_specs['resource_monitor'].full_gem_path
15
- puts "Copying from #{path}/app/ to #{Rails.root.to_s}/app/"
16
- FileUtils.cp_r "#{path}/app/.", "#{Rails.root.to_s}/app/"
17
- puts "IMPORTANT: Remember to add the following route to your config/routes.rb"
18
- puts "get '/resources/' => 'resource#index'"
19
- else
20
- puts "This installer should be run inside a Rails project."
21
- end
22
- end
23
-
24
- # Does nothing at all.
25
- task :uninstall_dashboard do
26
- if defined?(Rails)
27
- path = Gem.loaded_specs['resource_monitor'].full_gem_path
28
- records = Dir.glob("#{path}/app/**/**").select { |f| File.file?(f) }
29
- records.each do |item|
30
- puts "Removing #{Rails.root.to_s}#{item.split(path)[1]}"
31
- FileUtils.rm "#{Rails.root.to_s}#{item.split(path)[1]}"
32
- end
33
- puts "IMPORTANT: Remember to remove the following route from your config/routes.rb"
34
- puts "get '/resources/' => 'resource#index'"
35
- else
36
- puts "This uninstaller should be run inside a Rails project."
37
- end
38
- end
39
- end
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'resource_monitor/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "resource_monitor"
8
- spec.version = ResourceMonitor::VERSION
9
- spec.authors = ["Lazaro Herrera"]
10
- spec.email = ["lazherrera@gmail.com"]
11
-
12
- spec.summary = %q{A Rails 5 ActionCable gem for simple resource usage monitoring.}
13
- spec.description = %q{This gem creates a dashboard for monitoring of ongoing CPU/RAM usage of your processes.}
14
- spec.homepage = "http://writecodeeveryday.github.io/projects/resource_monitor"
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 "actioncable"
27
- end