gem_recent-updates 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT LICENSE
2
+
3
+ Copyright (c) 2010 Oliver Steele
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.rdoc ADDED
@@ -0,0 +1,33 @@
1
+ == Description
2
+
3
+ Displays a list of recently updated gems, and the diffs of their change or history files relative
4
+ to the previously installed version.
5
+
6
+ == Install
7
+
8
+ Install the gem with:
9
+
10
+ gem source -a http://gems.github.com && sudo gem install osteele-gem_recent-updates
11
+
12
+ == Examples
13
+
14
+ bash> gem recent-updates
15
+
16
+ == Bugs/Tickets
17
+
18
+ Please submit tickets through {github's issue tracker}[http://github.com/osteele/gem_recent-updates/issues].
19
+
20
+ == TODO
21
+
22
+ * Tests!
23
+
24
+ == LICENSE
25
+
26
+ See LICENSE.txt
27
+
28
+ == CREDITS
29
+
30
+ Thanks to {Gabriel Horner}[http://tagaholic.me/2009/04/23/how-to-write-a-rubygem-command-plugin.html]
31
+ for the gem command example and howto.
32
+
33
+ The paging code is from {Nathan Weizenbaum}[http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby].
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ begin
6
+ require 'rcov/rcovtask'
7
+ Rcov::RcovTask.new do |t|
8
+ t.libs << 'test'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ t.rcov_opts = ["-T -x '/Library/Ruby/*'"]
11
+ t.verbose = true
12
+ end
13
+ rescue LoadError
14
+ $stderr.puts "Rcov not available. Install it for rcov-related tasks with:"
15
+ $stderr.puts " sudo gem install rcov"
16
+ end
17
+
18
+ begin
19
+ require 'jeweler'
20
+ Jeweler::Tasks.new do |s|
21
+ s.name = 'gem_recent-updates'
22
+ s.description = "Adds a gem command that displays the new portions of the history files of recently updated gems."
23
+ s.summary = "A gem command plugin that displays the tops of the history files of recently updated gems."
24
+ s.email = "gabriel.horner@gmail.com"
25
+ s.homepage = "http://github.com/osteele/gem_recent-updates"
26
+ s.authors = ["Oliver Steele"]
27
+ s.has_rdoc = true
28
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
29
+ s.files = FileList["[A-Z]*", "{bin,lib,test}/**/*"]
30
+ s.add_dependency 'term-ansicolor'
31
+ end
32
+
33
+ rescue LoadError
34
+ $stderr.puts "Jeweler not available. Install it for jeweler-related tasks with:"
35
+ $stderr.puts " sudo gem install jeweler"
36
+ end
37
+
38
+ Rake::TestTask.new do |t|
39
+ t.libs << 'lib'
40
+ t.pattern = 'test/**/*_test.rb'
41
+ t.verbose = false
42
+ end
43
+
44
+ Rake::RDocTask.new do |rdoc|
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = 'test'
47
+ rdoc.options << '--line-numbers' << '--inline-source'
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
51
+
52
+ task :default => :test
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 1
3
+ :patch: 0
4
+ :major: 0
@@ -0,0 +1,85 @@
1
+ require 'term/ansicolor'
2
+ require 'shellwords'
3
+
4
+ class Gem::Commands::RecentUpdatesCommand < Gem::Command
5
+ def initialize
6
+ super 'recent-updates', "Display the recent histories of recently updated gems"
7
+
8
+ add_option('--since TIME', Float, 'Number of days back to look') do |value, options|
9
+ options[:days] = value
10
+ end
11
+ end
12
+
13
+ def description # :nodoc:
14
+ """Displays the new portions of the history files of recently updated gems."""
15
+ end
16
+
17
+ def execute
18
+ days = options[:days] || 7
19
+ since = Time.now - days * 24 * 60 * 60
20
+ names = Gem.source_index.map do |name, spec|
21
+ mtime = Dir["#{spec.full_gem_path}/**/*.*"].map { |file|
22
+ File.mtime(file)
23
+ }.min
24
+ spec if mtime > since
25
+ end.compact
26
+
27
+ run_pager
28
+
29
+ changes = names.map do |spec|
30
+ name, version = spec.name, spec.version
31
+ dep = Gem::Dependency.new name, Gem::Requirement.default
32
+ specs = Gem.source_index.search dep
33
+ prev = specs.select { |s| s.version < version }.sort.last
34
+ next unless prev
35
+ "#{Term::ANSIColor::red}#{name} #{version.version}#{Term::ANSIColor::black}:\n" +
36
+ change_summary(spec, prev) + "\n"
37
+ end.compact
38
+
39
+ if changes.any?
40
+ puts "Changes since #{since}:\n\n"
41
+ puts changes.join("\n")
42
+ else
43
+ puts "No changes since #{since}."
44
+ end
45
+ end
46
+
47
+ private
48
+ def change_summary(spec, other)
49
+ change_file_pattern = '{CHANGE,RELEASE}*'
50
+ change_file = Dir[File.join(spec.full_gem_path, change_file_pattern)].first
51
+ return "no change history" unless change_file
52
+ prev_change_file = File.join(other.full_gem_path, File.basename(change_file))
53
+ prev_change_file = Dir[File.join(other.full_gem_path, change_file_pattern)].first unless File.exists?(prev_change_file)
54
+ return File.read(change_file) unless File.exists?(prev_change_file)
55
+ lines = `diff -d #{Shellwords::shellescape prev_change_file} #{Shellwords::shellescape change_file}`.lines.grep(/^>/)
56
+ return lines.map {|s| s.sub(/^> /, '')}.join
57
+ end
58
+
59
+ # from http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby
60
+ def run_pager
61
+ return if PLATFORM =~ /win32/
62
+ return unless STDOUT.tty?
63
+
64
+ read, write = IO.pipe
65
+
66
+ unless Kernel.fork # Child process
67
+ STDOUT.reopen(write)
68
+ STDERR.reopen(write) if STDERR.tty?
69
+ read.close
70
+ write.close
71
+ return
72
+ end
73
+
74
+ # Parent process, become pager
75
+ STDIN.reopen(read)
76
+ read.close
77
+ write.close
78
+
79
+ ENV['LESS'] = '-FRsX' # Don't page if the input is short enough
80
+
81
+ Kernel.select [STDIN] # Wait until we have input before we start the pager
82
+ pager = ENV['PAGER'] || 'less'
83
+ exec pager rescue exec "/bin/sh", "-c", pager
84
+ end
85
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems/command_manager'
2
+
3
+ Gem::CommandManager.instance.register_command :"recent-updates"
4
+
5
+ class << Gem::Commands
6
+ alias_method :original_const_get, :const_get
7
+
8
+ # replace interpolated "abc-def" -> "abcDef", if name ends in "Command"
9
+ def const_get(name)
10
+ name = name.to_s.gsub(/-(\w)/) { |s| s[1..-1].upcase }.intern if name.to_s =~ /Command$/
11
+ self.original_const_get(name)
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem_recent-updates
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Oliver Steele
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-02 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: term-ansicolor
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ description: Adds a gem command that displays the new portions of the history files of recently updated gems.
33
+ email: gabriel.horner@gmail.com
34
+ executables: []
35
+
36
+ extensions: []
37
+
38
+ extra_rdoc_files:
39
+ - LICENSE.txt
40
+ - README.rdoc
41
+ files:
42
+ - LICENSE.txt
43
+ - README.rdoc
44
+ - Rakefile
45
+ - VERSION.yml
46
+ - lib/rubygems/commands/recent-updates_command.rb
47
+ - lib/rubygems_plugin.rb
48
+ has_rdoc: true
49
+ homepage: http://github.com/osteele/gem_recent-updates
50
+ licenses: []
51
+
52
+ post_install_message:
53
+ rdoc_options:
54
+ - --charset=UTF-8
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ requirements: []
72
+
73
+ rubyforge_project:
74
+ rubygems_version: 1.3.6
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: A gem command plugin that displays the tops of the history files of recently updated gems.
78
+ test_files: []
79
+