gem-release 1.0.0 → 2.0.0.dev.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +72 -0
  4. data/{lib/gem_release/templates/LICENSE → MIT-LICENSE.md} +3 -2
  5. data/README.md +646 -0
  6. data/README.md.erb +159 -0
  7. data/TODO.txt +194 -0
  8. data/lib/gem/release.rb +13 -0
  9. data/lib/gem/release/cmds.rb +16 -0
  10. data/lib/gem/release/cmds/base.rb +101 -0
  11. data/lib/gem/release/cmds/bootstrap.rb +222 -0
  12. data/lib/gem/release/cmds/bump.rb +165 -0
  13. data/lib/gem/release/cmds/gemspec.rb +85 -0
  14. data/lib/gem/release/cmds/release.rb +100 -0
  15. data/lib/gem/release/cmds/runner.rb +52 -0
  16. data/lib/gem/release/cmds/tag.rb +93 -0
  17. data/lib/gem/release/config.rb +42 -0
  18. data/lib/gem/release/config/env.rb +49 -0
  19. data/lib/gem/release/config/files.rb +35 -0
  20. data/lib/gem/release/context.rb +76 -0
  21. data/lib/gem/release/context/gem.rb +28 -0
  22. data/lib/gem/release/context/gemspec.rb +41 -0
  23. data/lib/gem/release/context/paths.rb +87 -0
  24. data/lib/gem/release/context/system.rb +36 -0
  25. data/lib/gem/release/data.rb +60 -0
  26. data/lib/gem/release/files/template.rb +61 -0
  27. data/lib/gem/release/files/template/context.rb +30 -0
  28. data/lib/gem/release/files/templates.rb +59 -0
  29. data/lib/gem/release/files/templates/group.rb +47 -0
  30. data/lib/gem/release/files/version.rb +68 -0
  31. data/lib/gem/release/helper.rb +45 -0
  32. data/lib/gem/release/helper/hash.rb +35 -0
  33. data/lib/gem/release/helper/string.rb +43 -0
  34. data/lib/gem/release/support/gem_command.rb +67 -0
  35. data/lib/gem/release/support/registry.rb +59 -0
  36. data/lib/gem/release/templates/.gitignore +8 -0
  37. data/lib/gem/release/templates/Gemfile +3 -0
  38. data/lib/gem/release/templates/gemspec +19 -0
  39. data/lib/gem/release/templates/licenses/mit.md +21 -0
  40. data/lib/gem/release/templates/licenses/mpl-2.md +373 -0
  41. data/lib/gem/release/templates/main.rb +1 -0
  42. data/lib/gem/release/templates/rspec/.rspec +3 -0
  43. data/lib/gem/release/templates/rspec/spec/spec_helper.rb +4 -0
  44. data/lib/gem/release/templates/travis/.travis.yml +1 -0
  45. data/lib/gem/release/templates/version.rb +1 -0
  46. data/lib/gem/release/version.rb +5 -0
  47. data/lib/gem/release/version/number.rb +102 -0
  48. data/lib/rubygems/commands/bootstrap_command.rb +4 -93
  49. data/lib/rubygems/commands/bump_command.rb +4 -110
  50. data/lib/rubygems/commands/gemspec_command.rb +5 -29
  51. data/lib/rubygems/commands/release_command.rb +4 -70
  52. data/lib/rubygems/commands/tag_command.rb +5 -46
  53. data/lib/rubygems_plugin.rb +8 -2
  54. metadata +56 -83
  55. data/lib/core_ext/hash/symbolize_keys.rb +0 -13
  56. data/lib/core_ext/kernel/silence.rb +0 -18
  57. data/lib/core_ext/string/camelize.rb +0 -5
  58. data/lib/gem_release.rb +0 -10
  59. data/lib/gem_release/command_options.rb +0 -31
  60. data/lib/gem_release/configuration.rb +0 -33
  61. data/lib/gem_release/gemspec_template.rb +0 -35
  62. data/lib/gem_release/helpers.rb +0 -104
  63. data/lib/gem_release/template.rb +0 -52
  64. data/lib/gem_release/templates/Gemfile +0 -3
  65. data/lib/gem_release/templates/README.md +0 -1
  66. data/lib/gem_release/templates/Rakefile +0 -10
  67. data/lib/gem_release/templates/gemspec +0 -18
  68. data/lib/gem_release/templates/gitignore +0 -25
  69. data/lib/gem_release/templates/test/test_helper.rb +0 -2
  70. data/lib/gem_release/templates/version.rb +0 -12
  71. data/lib/gem_release/version.rb +0 -3
  72. data/lib/gem_release/version_file.rb +0 -115
  73. data/lib/gem_release/version_template.rb +0 -14
@@ -1,52 +0,0 @@
1
- require 'erb'
2
- require 'fileutils'
3
- require 'core_ext/string/camelize'
4
-
5
- module GemRelease
6
- class Template
7
- include GemRelease::Helpers
8
-
9
- attr_reader :template, :filename, :name, :module_names, :module_path
10
-
11
- def initialize(template, options = {})
12
- @template = template
13
-
14
- options.each do |key, value|
15
- instance_variable_set(:"@#{key}", value)
16
- meta_class.send(:attr_reader, key)
17
- end
18
-
19
- @filename ||= @template
20
- @name ||= gem_name_from_directory
21
- @module_path ||= name
22
- @module_names ||= module_names_from_path(module_path)
23
- end
24
-
25
- def write
26
- FileUtils.mkdir_p(File.dirname(filename))
27
- File.open(filename, 'w+') { |f| f.write(render) }
28
- end
29
-
30
- protected
31
-
32
- def module_names_from_path(path)
33
- names = []
34
- path.split('-').each do |segment|
35
- names << segment.camelize
36
- end
37
- names
38
- end
39
-
40
- def render
41
- ERB.new(read_template, nil, "%").result(binding)
42
- end
43
-
44
- def read_template
45
- File.new(File.expand_path("../templates/#{template}", __FILE__)).read
46
- end
47
-
48
- def meta_class
49
- class << self; self; end
50
- end
51
- end
52
- end
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
@@ -1 +0,0 @@
1
- # <%= gem_name %>
@@ -1,10 +0,0 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new do |t|
5
- t.libs << 'lib'
6
- t.pattern = 'test/**/*_test.rb'
7
- t.verbose = false
8
- end
9
-
10
- task :default => :test
@@ -1,18 +0,0 @@
1
- # encoding: utf-8
2
-
3
- $:.unshift File.expand_path('../lib', __FILE__)
4
- require '<%= module_path %>/version'
5
-
6
- Gem::Specification.new do |s|
7
- s.name = <%= name.inspect %>
8
- s.version = <%= module_names.join('::') %>::VERSION
9
- s.authors = [<%= author.inspect %>]
10
- s.email = [<%= email.inspect %>]
11
- s.homepage = <%= homepage.inspect %>
12
- s.summary = <%= summary.inspect %>
13
- s.description = <%= description.inspect %>
14
-
15
- s.files = <%= files %>
16
- s.platform = Gem::Platform::RUBY
17
- s.require_paths = ['lib']
18
- end
@@ -1,25 +0,0 @@
1
- # Because this is a gem, ignore Gemfile.lock:
2
-
3
- Gemfile.lock
4
-
5
- # And because this is Ruby, ignore the following
6
- # (source: https://github.com/github/gitignore/blob/master/Ruby.gitignore):
7
-
8
- *.gem
9
- *.rbc
10
- .bundle
11
- .config
12
- coverage
13
- InstalledFiles
14
- lib/bundler/man
15
- pkg
16
- rdoc
17
- spec/reports
18
- test/tmp
19
- test/version_tmp
20
- tmp
21
-
22
- # YARD artifacts
23
- .yardoc
24
- _yardoc
25
- doc/
@@ -1,2 +0,0 @@
1
- require 'bundler/setup'
2
-
@@ -1,12 +0,0 @@
1
- <%=
2
- i = 0
3
- opening = ""
4
- closing = ""
5
- module_names.each do |n|
6
- opening += "#{' ' * i}module #{n}\n"
7
- closing = "#{' ' * i}end\n" + closing
8
- i += 2
9
- end
10
-
11
- opening + "#{' ' * i}VERSION = #{version.inspect}\n" + closing
12
- %>
@@ -1,3 +0,0 @@
1
- module GemRelease
2
- VERSION = '1.0.0'
3
- end
@@ -1,115 +0,0 @@
1
- require 'core_ext/kernel/silence'
2
-
3
- module GemRelease
4
- class VersionFile
5
- include GemRelease::Helpers
6
-
7
- VERSION_PATTERN = /(VERSION\s*=\s*(?:"|'))((?:(?!"|').)*)("|')/
8
- NUMBER_PATTERN = /(\d+)\.(\d+)\.(\d+)(.*)/
9
- PRERELEASE_NUMBER_PATTERN = /(\d+)\.(\d+)\.(\d+)\.(\D+|.*)(\d+)/
10
-
11
- attr_reader :target
12
-
13
- def initialize(options = {})
14
- @target = options[:target]
15
- if @target == nil || @target == ''
16
- @target = is_prerelease_version_number?(old_number) ? :pre : :patch
17
- elsif @target.to_sym == :release
18
- @target = :patch unless is_prerelease_version_number?(old_number)
19
- end
20
- end
21
-
22
- def bump!
23
- File.open(filename, 'w+') { |f| f.write(bumped_content) }
24
- reload_version
25
- end
26
-
27
- def new_number
28
- @new_number ||=
29
- if is_version_number?(target)
30
- target
31
- elsif [:major, :minor, :patch].include?(target.to_sym)
32
- old_number.sub(NUMBER_PATTERN) do
33
- send(target, $1, $2, $3)
34
- end
35
- elsif is_prerelease_version_number?(old_number)
36
- old_number.sub(PRERELEASE_NUMBER_PATTERN) do
37
- (target.to_sym == :release) ? release($1, $2, $3) : prerelease($1, $2, $3, $4, $5)
38
- end
39
- else
40
- old_number.sub(NUMBER_PATTERN) do
41
- "#{patch($1, $2, $3)}.#{target}1"
42
- end
43
- end
44
- end
45
-
46
- def old_number
47
- @old_number ||= content =~ VERSION_PATTERN && $2
48
- end
49
-
50
- def filename
51
- path = gem_name
52
- path = path.gsub('-', '/') unless File.exists?(path_to_version_file(path))
53
- path = path.gsub('/', '_') unless File.exists?(path_to_version_file(path))
54
-
55
- File.expand_path(path_to_version_file(path))
56
- end
57
-
58
- protected
59
-
60
- def path_to_version_file(path)
61
- "lib/#{path}/version.rb"
62
- end
63
-
64
- def reload_version
65
- silently { load(filename) }
66
- end
67
-
68
- def major(major, minor, patch)
69
- "#{major.to_i + 1}.0.0"
70
- end
71
-
72
- def minor(major, minor, patch)
73
- "#{major}.#{minor.to_i + 1}.0"
74
- end
75
-
76
- def patch(major, minor, patch)
77
- "#{major}.#{minor}.#{patch.to_i + 1}"
78
- end
79
-
80
- def release(major, minor, patch)
81
- "#{major}.#{minor}.#{patch}"
82
- end
83
-
84
- def prerelease(major, minor, patch, prereleasePrefix, prereleaseNumber)
85
- "#{major}.#{minor}.#{patch}.#{prereleasePrefix || 'pre'}#{prereleaseNumber.to_i + 1}"
86
- end
87
-
88
- def content
89
- @content ||= File.read(filename)
90
- end
91
-
92
- def bumped_content
93
- content.sub(VERSION_PATTERN) { "#{$1}#{new_number}#{$3}" }
94
- end
95
-
96
- def silently(&block)
97
- warn_level = $VERBOSE
98
- $VERBOSE = nil
99
- begin
100
- result = block.call
101
- ensure
102
- $VERBOSE = warn_level
103
- end
104
- result
105
- end
106
-
107
- def is_version_number?(v)
108
- v.to_s.match(NUMBER_PATTERN) != nil
109
- end
110
-
111
- def is_prerelease_version_number?(v)
112
- v.to_s.match(PRERELEASE_NUMBER_PATTERN) != nil
113
- end
114
- end
115
- end
@@ -1,14 +0,0 @@
1
- module GemRelease
2
- class VersionTemplate < Template
3
- attr_reader :version
4
-
5
- def initialize(options = {})
6
- super('version.rb', options)
7
- @version ||= '0.0.1'
8
- end
9
-
10
- def filename
11
- "lib/#{module_path}/version.rb"
12
- end
13
- end
14
- end