rg_stats 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,52 @@
1
+ # rcov generated
2
+ coverage
3
+
4
+ # rdoc generated
5
+ rdoc
6
+
7
+ # yard generated
8
+ doc
9
+ .yardoc
10
+
11
+ # bundler
12
+ .bundle
13
+
14
+ *.un~
15
+
16
+ *.swp
17
+
18
+ # jeweler generated
19
+ pkg
20
+
21
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
22
+ #
23
+ # * Create a file at ~/.gitignore
24
+ # * Include files you want ignored
25
+ # * Run: git config --global core.excludesfile ~/.gitignore
26
+ #
27
+ # After doing this, these files will be ignored in all your git projects,
28
+ # saving you from having to 'pollute' every project you touch with them
29
+ #
30
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
31
+ #
32
+ # For MacOS:
33
+ #
34
+ #.DS_Store
35
+
36
+ # For TextMate
37
+ #*.tmproj
38
+ #tmtags
39
+
40
+ # For emacs:
41
+ #*~
42
+ #\#*
43
+ #.\#*
44
+
45
+ # For vim:
46
+ #*.swp
47
+
48
+ # For redcar:
49
+ #.redcar
50
+
51
+ # For rubinius:
52
+ #*.rbc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rg_stats.gemspec
4
+ gemspec
5
+
6
+ gem "json"
7
+ gem "yaml"
8
+
9
+ group :development do
10
+ gem "rspec", '~> 2.9.0'
11
+ end
12
+
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rg_stats (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.3)
10
+ json (1.6.5)
11
+ rspec (2.9.0)
12
+ rspec-core (~> 2.9.0)
13
+ rspec-expectations (~> 2.9.0)
14
+ rspec-mocks (~> 2.9.0)
15
+ rspec-core (2.9.0)
16
+ rspec-expectations (2.9.0)
17
+ diff-lcs (~> 1.1.3)
18
+ rspec-mocks (2.9.0)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ json
25
+ rg_stats!
26
+ rspec (~> 2.9.0)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 drKreso
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # RubyGems Statistic
2
+
3
+ Get download statistic of your gems on RubyGems with a push of a button and stop wasting time looking it up in browser...
4
+
5
+ ## Installation
6
+
7
+ $ gem install rg_stats
8
+
9
+ ## Usage
10
+
11
+ $ rg_stats your_user_name
12
+
13
+ ## Caveat
14
+
15
+ User name is case sensitive for example mine is
16
+
17
+ $ rg_stats drKreso
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/rg_stats ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ require 'open-uri'
3
+ require 'yaml'
4
+
5
+ require_relative '../lib/rg_stats/statistic'
6
+
7
+ user_name = ARGV[0]
8
+
9
+ class PersistDataBetweenSessions
10
+
11
+ STORAGE_NAME = "/tmp/ruby_gems_sync.yaml"
12
+ def self.load
13
+ File.exists?(STORAGE_NAME) ? File.open(STORAGE_NAME, "r") { |file| YAML.load(file) } : []
14
+ end
15
+
16
+ def self.save(list)
17
+ File.open(STORAGE_NAME, "w") {|file| file.puts(list.to_yaml) }
18
+ end
19
+ end
20
+
21
+ if user_name.nil?
22
+ puts ""
23
+ puts "Type username on RubyGems as argument: rg_stats user_name"
24
+ puts ""
25
+ exit
26
+ end
27
+
28
+ url = "https://rubygems.org/api/v1/owners/#{user_name}/gems.json"
29
+ data_as_json = open(url)
30
+ old_data = PersistDataBetweenSessions.load
31
+ old_map = {}
32
+ old_data.each do |old_gem_info|
33
+ old_map[old_gem_info[0]] = old_gem_info[1]
34
+ end
35
+
36
+ stat = Statistic.new
37
+ stat.load data_as_json
38
+ puts ""
39
+ puts "*" * 90
40
+ stat.gem_info.each do |gem_info|
41
+ broj_izmjena = gem_info[1] - (old_map[gem_info[0]].nil? ? 0 : old_map[gem_info[0]])
42
+ diff_from_last_time = broj_izmjena == 0 ? "" : " (+\e[32m#{broj_izmjena}\e[0m)"
43
+ puts "%-55s: %8d %8s" % [ gem_info[0] , gem_info[1], diff_from_last_time ]
44
+ end
45
+ puts "*" * 90
46
+ PersistDataBetweenSessions.save(stat.gem_info)
47
+
@@ -0,0 +1,13 @@
1
+ require 'json'
2
+
3
+ class Statistic
4
+ def load(data)
5
+ @data = JSON.load data
6
+ end
7
+
8
+ def gem_info
9
+ @data.reduce([]) do |result, gem_info|
10
+ result << [ gem_info['name'], gem_info['downloads']]
11
+ end.sort! { |a,b| a[1] <=> b[1] }.reverse
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module RgStats
2
+ VERSION = "1.0.0"
3
+ end
data/lib/rg_stats.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "rg_stats/version"
2
+ require "rg_stats/statistic"
3
+
data/rg_stats.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rg_stats/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["drKreso"]
6
+ gem.email = ["kresimir.bojcic@gmail.com"]
7
+ gem.description = %q{Get download statistic of yours gems on RubyGems}
8
+ gem.summary = %q{I am wasting half of my day on checking stats...}
9
+ gem.homepage = "https://github.com/drKreso/rg_stats"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "rg_stats"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = RgStats::VERSION
17
+ end
@@ -0,0 +1,11 @@
1
+ require_relative 'test_data'
2
+ require 'rg_stats'
3
+
4
+ describe Statistic do
5
+ it 'should water my plants' do
6
+ subject.load TEST_DATA
7
+ subject.gem_info.should == [["guerrilla_patch", 485], ["cube", 409]]
8
+ end
9
+ end
10
+
11
+
@@ -0,0 +1,3 @@
1
+ TEST_DATA = <<-DATA
2
+ [{"name":"cube","downloads":409,"version":"1.3.0","version_downloads":107,"authors":"drKreso","info":"Eases the pain I had to go through to get to the data out of XMLA based OLAP provider","project_uri":"http://rubygems.org/gems/cube","gem_uri":"http://rubygems.org/gems/cube-1.3.0.gem","homepage_uri":"http://github.com/drkreso/cube","wiki_uri":null,"documentation_uri":null,"mailing_list_uri":null,"source_code_uri":null,"bug_tracker_uri":null,"dependencies":{"development":[{"name":"bundler","requirements":"~> 1.0.0"},{"name":"jeweler","requirements":"~> 1.6.4"},{"name":"rspec","requirements":"~> 2.3.0"},{"name":"vcr","requirements":">= 0"}],"runtime":[{"name":"guerrilla_patch","requirements":">= 0"},{"name":"savon","requirements":">= 0"},{"name":"webmock","requirements":">= 0"}]}},{"name":"guerrilla_patch","downloads":485,"version":"2.3.1","version_downloads":48,"authors":"drKreso","info":"I am tierd of hunting down monkey patches at large. Caging them inside this gem","project_uri":"http://rubygems.org/gems/guerrilla_patch","gem_uri":"http://rubygems.org/gems/guerrilla_patch-2.3.1.gem","homepage_uri":"http://github.com/drkreso/guerrilla_patch","wiki_uri":null,"documentation_uri":null,"mailing_list_uri":null,"source_code_uri":null,"bug_tracker_uri":null,"dependencies":{"development":[{"name":"bundler","requirements":"~> 1.0.0"},{"name":"jeweler","requirements":"~> 1.6.4"},{"name":"rcov","requirements":">= 0"},{"name":"rspec","requirements":"~> 2.8.0"}],"runtime":[]}}]
3
+ DATA
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rg_stats
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - drKreso
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-06 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Get download statistic of yours gems on RubyGems
15
+ email:
16
+ - kresimir.bojcic@gmail.com
17
+ executables:
18
+ - rg_stats
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - .rspec
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - LICENSE
27
+ - README.md
28
+ - Rakefile
29
+ - bin/rg_stats
30
+ - lib/rg_stats.rb
31
+ - lib/rg_stats/statistic.rb
32
+ - lib/rg_stats/version.rb
33
+ - rg_stats.gemspec
34
+ - spec/rg_stats/statistic_spec.rb
35
+ - spec/rg_stats/test_data.rb
36
+ homepage: https://github.com/drKreso/rg_stats
37
+ licenses: []
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 1.8.17
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: I am wasting half of my day on checking stats...
60
+ test_files:
61
+ - spec/rg_stats/statistic_spec.rb
62
+ - spec/rg_stats/test_data.rb
63
+ has_rdoc: