Hello community,

here is the log from the commit of package rubygem-get_process_mem for 
openSUSE:Factory checked in at 2016-10-10 16:23:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-get_process_mem (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-get_process_mem.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-get_process_mem"

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/rubygem-get_process_mem/rubygem-get_process_mem.changes
  2016-09-30 15:31:08.000000000 +0200
+++ 
/work/SRC/openSUSE:Factory/.rubygem-get_process_mem.new/rubygem-get_process_mem.changes
     2016-10-10 16:23:38.000000000 +0200
@@ -1,0 +2,10 @@
+Wed Sep 14 04:31:14 UTC 2016 - [email protected]
+
+- updated to version 0.2.1
+ see installed CHANGELOG.md
+
+  ## 0.2.1
+  
+  - Windows support.
+
+-------------------------------------------------------------------

Old:
----
  get_process_mem-0.2.0.gem

New:
----
  get_process_mem-0.2.1.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-get_process_mem.spec ++++++
--- /var/tmp/diff_new_pack.0tcfHn/_old  2016-10-10 16:23:40.000000000 +0200
+++ /var/tmp/diff_new_pack.0tcfHn/_new  2016-10-10 16:23:40.000000000 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package rubygem-get_process_mem
 #
-# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -24,14 +24,14 @@
 #
 
 Name:           rubygem-get_process_mem
-Version:        0.2.0
+Version:        0.2.1
 Release:        0
 %define mod_name get_process_mem
 %define mod_full_name %{mod_name}-%{version}
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-BuildRequires:  ruby-macros >= 5
-BuildRequires:  %{ruby}
 BuildRequires:  %{rubygem gem2rpm}
+BuildRequires:  %{ruby}
+BuildRequires:  ruby-macros >= 5
 Url:            https://github.com/schneems/get_process_mem
 Source:         http://rubygems.org/gems/%{mod_full_name}.gem
 Source1:        gem2rpm.yml

++++++ get_process_mem-0.2.0.gem -> get_process_mem-0.2.1.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/.travis.yml new/.travis.yml
--- old/.travis.yml     2014-06-16 21:40:01.000000000 +0200
+++ new/.travis.yml     2016-06-01 18:04:26.000000000 +0200
@@ -1,4 +1,8 @@
 language: ruby
+
+before_install:
+  - gem install bundler -v 1.12.5
+
 rvm:
   - 1.9.3
   - 2.0.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md    2014-06-16 21:40:01.000000000 +0200
+++ new/CHANGELOG.md    2016-06-01 18:04:26.000000000 +0200
@@ -1,3 +1,7 @@
+## 0.2.1
+
+- Windows support.
+
 ## 0.2.0
 
 - Reverting back to RSS for linux until (#7) is resolved
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Gemfile new/Gemfile
--- old/Gemfile 2014-06-16 21:40:01.000000000 +0200
+++ new/Gemfile 2016-06-01 18:04:26.000000000 +0200
@@ -1,3 +1,4 @@
 source "https://rubygems.org";
+gem 'sys-proctable'
 
 gemspec
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md       2014-06-16 21:40:01.000000000 +0200
+++ new/README.md       2016-06-01 18:04:26.000000000 +0200
@@ -12,15 +12,17 @@
 gem 'get_process_mem'
 ```
 
-then run `$ bundle install`
+then run `$ bundle install`.
 
+If you're using Windows you'll also need to have the `sys-proctable` gem.
 
 ## Use It
 
 Get the current process memory usage:
 
 ```ruby
-puts mem = GetProcessMem.new.inspect
+mem = GetProcessMem.new
+puts mem.inspect
 #<GetProcessMem @mb=24.28125 @gb=0.023712158203125 @kb=24864.0 @bytes=25460736 
>
 mem.bytes # => 25460736
 mem.kb    # => 24864.0
@@ -47,14 +49,7 @@
 `rm tmplog`
 ```
 
-On Linux, which provides `/proc/<pid>/smaps`, the default memory type returned 
is PSS, or "proportional set size", where shared memory is divided by the 
number of processes sharing it. On other platforms, the size returned is the 
RSS or the [Resident Set Size](http://en.wikipedia.org/wiki/Resident_set_size), 
basically how much memory the program takes up in RAM at the time, including 
all the shared memory.
-
-The memory type can be specified by passing an options hash:
-
-```ruby
-GetProcessMem.new(Process.pid, mem_type: 'rss')
-```
-
+On Linux, for memory size we return the RSS or the [Resident Set 
Size](http://en.wikipedia.org/wiki/Resident_set_size), basically how much 
memory the program takes up in RAM at the time, including all the shared memory.
 
 
 ## License
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/appveyor.yml new/appveyor.yml
--- old/appveyor.yml    1970-01-01 01:00:00.000000000 +0100
+++ new/appveyor.yml    2016-06-01 18:04:26.000000000 +0200
@@ -0,0 +1,20 @@
+install:
+  - set PATH=C:\Ruby22\bin;%PATH%
+  - bundle install
+
+build: off
+
+before_test:
+  - ruby -v
+  - gem -v
+  - bundle -v
+
+test_script:
+  - bundle exec rake
+
+environment:
+  matrix:
+    - RUBY_VERSION: 23
+    - RUBY_VERSION: 22
+    - RUBY_VERSION: 21
+    - RUBY_VERSION: 200
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/get_process_mem.gemspec new/get_process_mem.gemspec
--- old/get_process_mem.gemspec 2014-06-16 21:40:01.000000000 +0200
+++ new/get_process_mem.gemspec 2016-06-01 18:04:26.000000000 +0200
@@ -18,5 +18,7 @@
   gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
   gem.require_paths = ["lib"]
 
+  gem.add_development_dependency "sys-proctable", "~> 1.0"
   gem.add_development_dependency "rake",  "~> 10.1"
+  gem.add_development_dependency "test-unit", "~> 3.1.0"
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/get_process_mem/version.rb 
new/lib/get_process_mem/version.rb
--- old/lib/get_process_mem/version.rb  2014-06-16 21:40:01.000000000 +0200
+++ new/lib/get_process_mem/version.rb  2016-06-01 18:04:26.000000000 +0200
@@ -1,3 +1,3 @@
 class GetProcessMem
-  VERSION = "0.2.0"
-end
\ No newline at end of file
+  VERSION = "0.2.1"
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/get_process_mem.rb new/lib/get_process_mem.rb
--- old/lib/get_process_mem.rb  2014-06-16 21:40:01.000000000 +0200
+++ new/lib/get_process_mem.rb  2016-06-01 18:04:26.000000000 +0200
@@ -1,7 +1,6 @@
 require 'pathname'
 require 'bigdecimal'
 
-
 # Cribbed from Unicorn Worker Killer, thanks!
 class GetProcessMem
   KB_TO_BYTE = 1024          # 2**10   = 1024
@@ -11,10 +10,24 @@
   ROUND_UP   = BigDecimal.new("0.5")
   attr_reader :pid
 
+  RUNS_ON_WINDOWS = Gem.win_platform?
+
+  if RUNS_ON_WINDOWS
+    begin
+      require 'sys/proctable'
+    rescue LoadError => e
+      message = "Please add `sys-proctable` to your Gemfile for windows 
machines\n"
+      message << e.message
+      raise e, message
+    end
+    include Sys
+  end
+
   def initialize(pid = Process.pid)
+    @status_file  = Pathname.new "/proc/#{pid}/status"
     @process_file = Pathname.new "/proc/#{pid}/smaps"
     @pid          = pid
-    @linux        = @process_file.exist?
+    @linux        = @status_file.exist?
   end
 
   def linux?
@@ -22,7 +35,7 @@
   end
 
   def bytes
-    memory =   linux_memory if linux?
+    memory =   linux_status_memory if linux?
     memory ||= ps_memory
   end
 
@@ -43,18 +56,20 @@
     "#<#{self.class}:0x%08x @mb=#{ mb b } @gb=#{ gb b } @kb=#{ kb b } 
@bytes=#{b}>" % (object_id * 2)
   end
 
-  def mem_type
-    @mem_type
-  end
-
-  def mem_type=(mem_type)
-    @mem_type = mem_type.downcase
+  # linux stores memory info in a file "/proc/#{pid}/status"
+  # If it's available it uses less resources than shelling out to ps
+  def linux_status_memory(file = @status_file)
+    line = file.each_line.detect {|line| line.start_with? 'VmRSS'.freeze }
+    return unless line
+    return unless (_name, value, unit = line.split(nil)).length == 3
+    CONVERSION[unit.downcase!] * value.to_i
+  rescue Errno::EACCES, Errno::ENOENT
+    0
   end
 
-  # linux stores memory info in a file "/proc/#{pid}/smaps"
-  # If it's available it uses less resources than shelling out to ps
+  # linux stores detailed memory info in a file "/proc/#{pid}/smaps"
   def linux_memory(file = @process_file)
-    lines = file.each_line.select {|line| line.match /^Rss/ }
+    lines = file.each_line.select {|line| line.match(/^Rss/) }
     return if lines.empty?
     lines.reduce(0) do |sum, line|
       line.match(/(?<value>(\d*\.{0,1}\d+))\s+(?<unit>\w\w)/) do |m|
@@ -68,11 +83,14 @@
     0
   end
 
-  private
-
   # Pull memory from `ps` command, takes more resources and can freeze
   # in low memory situations
   def ps_memory
-    KB_TO_BYTE * BigDecimal.new(`ps -o rss= -p #{pid}`)
+    if RUNS_ON_WINDOWS
+      size = ProcTable.ps(pid).working_set_size
+      BigDecimal.new(size)
+    else
+      KB_TO_BYTE * BigDecimal.new(`ps -o rss= -p #{pid}`)
+    end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2014-06-16 21:40:01.000000000 +0200
+++ new/metadata        2016-06-01 18:04:26.000000000 +0200
@@ -1,16 +1,30 @@
 --- !ruby/object:Gem::Specification
 name: get_process_mem
 version: !ruby/object:Gem::Version
-  version: 0.2.0
+  version: 0.2.1
 platform: ruby
 authors:
 - Richard Schneeman
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2014-06-16 00:00:00.000000000 Z
+date: 2016-06-01 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
+  name: sys-proctable
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - "~>"
+      - !ruby/object:Gem::Version
+        version: '1.0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - "~>"
+      - !ruby/object:Gem::Version
+        version: '1.0'
+- !ruby/object:Gem::Dependency
   name: rake
   requirement: !ruby/object:Gem::Requirement
     requirements:
@@ -24,6 +38,20 @@
     - - "~>"
       - !ruby/object:Gem::Version
         version: '10.1'
+- !ruby/object:Gem::Dependency
+  name: test-unit
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - "~>"
+      - !ruby/object:Gem::Version
+        version: 3.1.0
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - "~>"
+      - !ruby/object:Gem::Version
+        version: 3.1.0
 description: " Get memory usage of a process in Ruby "
 email:
 - [email protected]
@@ -37,10 +65,12 @@
 - Gemfile
 - README.md
 - Rakefile
+- appveyor.yml
 - get_process_mem.gemspec
 - lib/get_process_mem.rb
 - lib/get_process_mem/version.rb
 - test/fixtures/heroku-bash-smap
+- test/fixtures/heroku-bash-status
 - test/get_process_mem_test.rb
 - test/test_helper.rb
 homepage: https://github.com/schneems/get_process_mem
@@ -63,12 +93,12 @@
       version: '0'
 requirements: []
 rubyforge_project: 
-rubygems_version: 2.2.2
+rubygems_version: 2.5.1
 signing_key: 
 specification_version: 4
 summary: Use GetProcessMem to find out the amount of RAM used by any process
 test_files:
 - test/fixtures/heroku-bash-smap
+- test/fixtures/heroku-bash-status
 - test/get_process_mem_test.rb
 - test/test_helper.rb
-has_rdoc: 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/fixtures/heroku-bash-status 
new/test/fixtures/heroku-bash-status
--- old/test/fixtures/heroku-bash-status        1970-01-01 01:00:00.000000000 
+0100
+++ new/test/fixtures/heroku-bash-status        2016-06-01 18:04:26.000000000 
+0200
@@ -0,0 +1,41 @@
+Name:  bash
+State: S (sleeping)
+Tgid:  3
+Ngid:  0
+Pid:   3
+PPid:  1
+TracerPid:     0
+Uid:   58790   58790   58790   58790
+Gid:   58790   58790   58790   58790
+FDSize:        256
+Groups:        
+VmPeak:          109120 kB
+VmSize:          109120 kB
+VmLck:        0 kB
+VmPin:        0 kB
+VmHWM:     2032 kB
+VmRSS:     2032 kB
+VmData:             356 kB
+VmStk:      136 kB
+VmExe:      956 kB
+VmLib:     2288 kB
+VmPTE:       64 kB
+VmSwap:               0 kB
+Threads:       1
+SigQ:  0/274188
+SigPnd:        0000000000000000
+ShdPnd:        0000000000000000
+SigBlk:        0000000000010000
+SigIgn:        0000000000380004
+SigCgt:        000000004b817efb
+CapInh:        0000000000000000
+CapPrm:        0000000000000000
+CapEff:        0000000000000000
+CapBnd:        0000001ff598cffe
+Seccomp:       2
+Cpus_allowed:  f
+Cpus_allowed_list:     0-3
+Mems_allowed:  00000000,00000001
+Mems_allowed_list:     0
+voluntary_ctxt_switches:       34
+nonvoluntary_ctxt_switches:    35
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/get_process_mem_test.rb 
new/test/get_process_mem_test.rb
--- old/test/get_process_mem_test.rb    2014-06-16 21:40:01.000000000 +0200
+++ new/test/get_process_mem_test.rb    2016-06-01 18:04:26.000000000 +0200
@@ -19,6 +19,11 @@
     assert_in_delta BigDecimal.new("2122240.0"), bytes, delta
   end
 
+  def test_linux_status
+    bytes = @mem.linux_status_memory(fixture_path("heroku-bash-status"))
+    assert_equal bytes, 2080768
+  end
+
   def test_conversions
     bytes = 0
     delta = BigDecimal.new("0.0000001")


Reply via email to