gem-changelog 1.0.2 → 1.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e79fe9e95b5f7e96d4c0c4b40253a177ca03894a
4
- data.tar.gz: cf678e101ad9c99146f3d6db6850e1a688c34790
3
+ metadata.gz: 278d47b6a682165ae6107034f31711119c7130e7
4
+ data.tar.gz: 630c5c2a42019701683b428ba3f45f08e2e3f7c2
5
5
  SHA512:
6
- metadata.gz: bc1404bd4db5029707c8eb63edc905c0805f99d0f23c732767d6cb455f7df6394e5b40d92726d4e117a416039bf44845c5f6c036fca902728492174fb2cfa48c
7
- data.tar.gz: aa1b6566d90172a13b5629e0d258101c81e941e89ffb077131ab671a6ea7065c11e1a9b77a05f22035ea6faf80411253ec5f74c789341d8c9f96ac52dc763c8c
6
+ metadata.gz: 33bb0e72f0d3b51050d9ce68f9180d2d7f88a13d332b3d86fb457af34f5178620569bd98a3c14a5add3df375f73fb4391d8cba9ab0de322c619778b7cd1af51d
7
+ data.tar.gz: 560acebb58b1b4ffbf0578f2b74dd59afbcb5fb4c474053d14a459386315ae98e8db48d826d31467475fb6eb04f598ea05a39c3e4346191a038173ed4dcb3a18
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.0.3 (2013-05-31)
2
+
3
+ - Bugfix: `files` method requires spec dir. [kyanny]
4
+ - New option: --lines [LINES] to display first specified LINES of changelog. [KitaitiMakoto]
5
+ - Enhancement: `install`/`update` subcommands now have --changelog [LINES] option. [KitaitiMakoto]
6
+
1
7
  ## 1.0.2 (2013-03-05)
2
8
 
3
9
  - Add "History" to the changelog patterns.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gem
4
4
  module Changelog
5
- VERSION = '1.0.2'
5
+ VERSION = '1.0.3'
6
6
  end
7
7
  end
@@ -13,6 +13,10 @@ class Gem::Commands::ChangelogCommand < Gem::Command
13
13
  add_option '-v VERSION', 'Specify version' do |v|
14
14
  options[:version_requirement] = v
15
15
  end
16
+ add_option '-n', '--lines=LINES', 'Show the first LINES lines of the changelog' do |v|
17
+ raise OptionParser::InvalidArgument, v unless v =~ OptionParser::DecimalInteger
18
+ options[:lines] = v.to_i
19
+ end
16
20
  end
17
21
 
18
22
  def execute
@@ -38,14 +42,19 @@ class Gem::Commands::ChangelogCommand < Gem::Command
38
42
  say('Changelog file could not be found.')
39
43
  else
40
44
  say('Changelog file could not be found. Try -f option with one of following file(s).')
41
- files.each do |file|
45
+ files(spec.gem_dir).each do |file|
42
46
  say('- %s' % file)
43
47
  end
44
48
  end
45
49
  terminate_interaction 1
46
50
  end
47
51
 
48
- system(pager, File.join(spec.gem_dir, changelog_file))
52
+ changelog_path = File.join(spec.gem_dir, changelog_file)
53
+ if options[:lines]
54
+ show_first_lines(changelog_path, options[:lines])
55
+ else
56
+ system(pager, changelog_path)
57
+ end
49
58
  end
50
59
 
51
60
  def usage
@@ -56,6 +65,16 @@ class Gem::Commands::ChangelogCommand < Gem::Command
56
65
  'GEM_NAME name of the gem to show'
57
66
  end
58
67
 
68
+ def find_changelog_file(spec)
69
+ files(spec.gem_dir).sort.find {|file| CHANGELOG_RE === file }
70
+ end
71
+
72
+ def show_first_lines(file_path, number=10)
73
+ open file_path do |file|
74
+ puts file.each_line.take(number)
75
+ end
76
+ end
77
+
59
78
  private
60
79
 
61
80
  CHANGELOG_RE = Regexp.union(/\ACHANGELOG\b/i, /\ACHANGES\b/i, /\AHistory\b/i)
@@ -64,10 +83,6 @@ class Gem::Commands::ChangelogCommand < Gem::Command
64
83
  Dir.entries(dir).select {|e| FileTest.file?(File.join(dir, e)) }
65
84
  end
66
85
 
67
- def find_changelog_file(spec)
68
- files(spec.gem_dir).sort.find {|file| CHANGELOG_RE === file }
69
- end
70
-
71
86
  def pager
72
87
  ENV['PAGER'] || 'more'
73
88
  end
@@ -1,4 +1,26 @@
1
1
  # -*- encoding: UTF-8 -*-
2
2
 
3
3
  require 'rubygems/command_manager'
4
- Gem::CommandManager.instance.register_command :changelog
4
+ require 'rubygems/security'
5
+ require 'rubygems/install_update_options'
6
+ require 'rubygems/commands/changelog_command'
7
+
8
+ Gem::CommandManager.instance.register_command :changelog
9
+
10
+ module Gem::InstallUpdateOptions
11
+ alias install_update_options_without_changelog add_install_update_options
12
+ def add_install_update_options
13
+ install_update_options_without_changelog
14
+
15
+ add_option :'Install/Update', '--changelog [LINES]', 'Show LINES lines the changelog of given gem, LINES defaults to 10' do |value, option|
16
+ next if @gem_changelog_lines
17
+ @gem_changelog_lines = (value && value =~ OptionParser::DecimalInteger) ? value.to_i : 10
18
+ Gem.post_install do |installer|
19
+ command = Gem::Commands::ChangelogCommand.new
20
+ changelog_file = options[:changelog_name] || command.find_changelog_file(installer.spec)
21
+ next unless changelog_file
22
+ puts command.show_first_lines(File.join(installer.spec.gem_dir, changelog_file), @gem_changelog_lines)
23
+ end
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - OZAWA Sakuro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-05 00:00:00.000000000 Z
11
+ date: 2013-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project:
78
- rubygems_version: 2.0.0
78
+ rubygems_version: 2.0.2
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: Show the changelog of given gem