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
@@ -0,0 +1 @@
1
+ <%= define :module %>
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --order rand
@@ -0,0 +1,4 @@
1
+ require 'lib/<%= gem_path %>'
2
+
3
+ RSpec.configure do |c|
4
+ end
@@ -0,0 +1 @@
1
+ language: ruby
@@ -0,0 +1 @@
1
+ <%= define(:module) { "VERSION = '0.0.1'" } %>
@@ -0,0 +1,5 @@
1
+ module Gem
2
+ module Release
3
+ VERSION = '2.0.0.dev.1'
4
+ end
5
+ end
@@ -0,0 +1,102 @@
1
+ module Gem
2
+ module Release
3
+ module Version
4
+ class Number < Struct.new(:number, :target)
5
+ NUMBER = /^(\d+)\.(\d+).(\d+).?(\w+)?.?(\d+)?$/
6
+
7
+ STAGES = %i(alpha beta pre rc)
8
+
9
+ def bump
10
+ return target if specific?
11
+ validate_stage
12
+ [major, minor, patch, stage, num].compact.join('.')
13
+ end
14
+
15
+ private
16
+
17
+ def specific?
18
+ target =~ NUMBER
19
+ end
20
+
21
+ def major
22
+ part = parts[0]
23
+ part += 1 if to?(:major)
24
+ part
25
+ end
26
+
27
+ def minor
28
+ part = parts[1]
29
+ part = 0 if to?(:major)
30
+ part += 1 if to?(:minor) || fresh_pre_release?
31
+ part
32
+ end
33
+
34
+ def patch
35
+ part = parts[2]
36
+ part = 0 if to?(:major, :minor) || fresh_pre_release?
37
+ part += 1 if to?(:patch) && from_release?
38
+ part
39
+ end
40
+
41
+ def stage
42
+ target unless to_release?
43
+ end
44
+
45
+ def num
46
+ return if to_release?
47
+ part = parts[4].to_i
48
+ part += 1 if from_release? || same_stage?
49
+ part
50
+ end
51
+
52
+ def to?(*targets)
53
+ targets.include?(target)
54
+ end
55
+
56
+ def to_release?
57
+ to?(:major, :minor, :patch)
58
+ end
59
+
60
+ def fresh_pre_release?
61
+ from_release? && to?(:pre, :rc)
62
+ end
63
+
64
+ def from_release?
65
+ !from_pre_release?
66
+ end
67
+
68
+ def from_pre_release?
69
+ !!from_stage
70
+ end
71
+
72
+ def same_stage?
73
+ from_stage == target
74
+ end
75
+
76
+ def from_stage
77
+ parts[3]
78
+ end
79
+
80
+ def target
81
+ super || (from_pre_release? ? from_stage : :patch)
82
+ end
83
+
84
+ def validate_stage
85
+ from, to = STAGES.index(from_stage), STAGES.index(target)
86
+ return unless from && to && from > to
87
+ raise Abort, "Cannot go from an #{from_stage} version to a #{target} version"
88
+ end
89
+
90
+ def parts
91
+ @parts ||= matches.compact.map(&:to_i).tap do |parts|
92
+ parts[3] = matches[3] && matches[3].to_sym
93
+ end
94
+ end
95
+
96
+ def matches
97
+ @matches ||= number.match(NUMBER).to_a[1..-1]
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -1,96 +1,7 @@
1
- require 'rubygems/commands/gemspec_command'
2
- require 'core_ext/kernel/silence'
1
+ require 'gem/release/support/gem_command'
2
+ require 'gem/release/cmds/bootstrap'
3
3
 
4
4
  class Gem::Commands::BootstrapCommand < Gem::Command
5
- include GemRelease, Gem::Commands
6
- include Helpers, CommandOptions
7
-
8
- DEFAULTS = {
9
- :gemspec => true,
10
- :strategy => 'git',
11
- :scaffold => true,
12
- :github => false,
13
- :quiet => false
14
- }
15
-
16
- attr_reader :arguments, :usage, :name
17
-
18
- def initialize(options = {})
19
- @name = 'bootstrap'
20
- super @name, 'Bootstrap a new gem source repository', default_options_with(options)
21
-
22
- option :gemspec, '-g', 'Generate a .gemspec'
23
- option :scaffold, '-s', 'Scaffold lib/[gem_name]/version.rb README test/'
24
- option :strategy, '-f', 'Strategy for collecting files [glob|git] in .gemspec'
25
- option :github, '-h', 'Bootstrap a git repo, create on github and push'
26
- option :quiet, '-q', 'Do not output status messages'
27
-
28
- @arguments = "gemname - option name of the gem, will use the current directory if not specified"
29
- @usage = "#{program_name} [gemname]"
30
- end
31
-
32
- def execute
33
- in_bootstrapped_dir do
34
- write_scaffold if options[:scaffold]
35
- write_gemspec if options[:gemspec]
36
- init_git if options[:github] || options[:args] # safe to 'git init' in new dir
37
- create_repo if options[:github]
38
- end
39
-
40
- success
41
- end
42
-
43
- def write_gemspec
44
- GemspecCommand.new(:quiet => quiet?, :strategy => options[:strategy], :quiet_success => true).execute
45
- end
46
-
47
- def write_scaffold
48
- say 'scaffolding ...' unless quiet?
49
-
50
- create_file Template.new('gitignore', :filename => '.gitignore')
51
- create_file Template.new('README.md')
52
- create_file Template.new('LICENSE', :year => Time.now.year, :author => user_name, :email => user_email)
53
- create_file Template.new('Gemfile')
54
- create_file Template.new('Rakefile')
55
- create_file Template.new('test/test_helper.rb')
56
- create_file VersionTemplate.new(options)
57
- end
58
-
59
- def create_lib
60
- `mkdir -p lib test`
61
- end
62
-
63
- def create_file(template)
64
- if File.exists?(template.filename)
65
- say "Skipping #{template.filename}: already exists" unless quiet?
66
- else
67
- say "Creating #{template.filename}" unless quiet?
68
- template.write
69
- end
70
- end
71
-
72
- def init_git
73
- say 'Initializing git repository'
74
- `git init`
75
- end
76
-
77
- def create_repo
78
- options = { :login => github_user, :token => github_token, :name => gem_name }
79
- options = options.map { |name, value| "-F '#{name}=#{value}'" }.join(' ')
80
-
81
- say 'Staging files'
82
- `git add .`
83
-
84
- say 'Creating initial commit'
85
- `git commit -m "initial commit"`
86
-
87
- say "Adding remote origin git@github.com:#{github_user}/#{gem_name}.git"
88
- `git remote add origin git@github.com:#{github_user}/#{gem_name}.git`
89
-
90
- say 'Creating repository on Github'
91
- silence { `curl #{options} http://github.com/api/v2/yaml/repos/create` }
92
-
93
- say 'Pushing to Github'
94
- `git push origin master`
95
- end
5
+ include Gem::Release::GemCommand
6
+ self.cmd = :bootstrap
96
7
  end
@@ -1,113 +1,7 @@
1
- require 'gem_release'
2
- require 'rubygems/commands/tag_command'
3
- require 'rubygems/commands/release_command'
4
- require 'shellwords'
1
+ require 'gem/release/support/gem_command'
2
+ require 'gem/release/cmds/bump'
5
3
 
6
4
  class Gem::Commands::BumpCommand < Gem::Command
7
- include GemRelease, Gem::Commands
8
- include Helpers, CommandOptions
9
-
10
- attr_reader :arguments, :usage, :name
11
-
12
- DEFAULTS = {
13
- :version => '',
14
- :commit => true,
15
- :push => false,
16
- :tag => false,
17
- :release => false,
18
- :key => '',
19
- :host => '',
20
- :quiet => false,
21
- :destination => "origin",
22
- }
23
-
24
- def initialize(options = {})
25
- @name = 'bump'
26
- super @name, 'Bump the gem version', default_options_with(options)
27
-
28
- option :version, '-v', 'Target version: next [major|minor|patch|pre|release] or a given version number [x.x.x]'
29
- option :commit, '-c', 'Perform a commit after incrementing gem version'
30
- option :push, '-p', 'Push to the git destination'
31
- option :destination, '-d', 'destination git repository'
32
- option :tag, '-t', 'Create a git tag and push it to the git destination'
33
- option :release, '-r', 'Build gem from a gemspec and push to rubygems.org'
34
- option :key, '-k', 'When releasing: use the given API key from ~/.gem/credentials'
35
- option :host, '-h', 'When releasing: push to a gemcutter-compatible host other than rubygems.org'
36
- option :quiet, '-q', 'Do not output status messages'
37
- end
38
-
39
- def execute
40
- @new_version_number = nil
41
-
42
- tasks = [:commit, :push, :release, :tag]
43
-
44
- # enforce option dependencies
45
- options[:push] = true if options[:tag]
46
- options[:commit] = options[:commit] || options[:push] || options[:tag] || options[:release]
47
-
48
- in_gemspec_dirs do
49
- run_cmd(:bump)
50
- end
51
-
52
- if @new_version_number == nil
53
- say "No version files could be found, so no actions were performed." unless quiet?
54
- else
55
- tasks.each do |task|
56
- run_cmd(task) if options[task]
57
- end
58
-
59
- success
60
- end
61
- end
62
-
63
- protected
64
-
65
- def bump
66
- version = VersionFile.new(:target => (@new_version_number || options[:version]))
67
- if File.exist?(version.filename)
68
- @new_version_number ||= version.new_number
69
- say "Bumping #{gem_name} from #{version.old_number} to version #{version.new_number}" unless quiet?
70
- version.bump!
71
- return system("git add #{escape(version.filename)}") if options[:commit]
72
- else
73
- say "Ignoring #{gem_name}. Version file #{version.filename} not found" unless quiet?
74
- end
75
- true
76
- end
77
-
78
- def escape(string)
79
- Shellwords.escape(string)
80
- end
81
-
82
- def commit
83
- say "Creating commit" unless quiet?
84
- system("git commit -m \"Bump to #{@new_version_number}\"")
85
- end
86
-
87
- def push
88
- destination = options[:destination]
89
- say "Pushing to the #{destination} git repository" unless quiet?
90
- system("git push #{destination}")
91
- end
92
-
93
- def release
94
- cmd = ReleaseCommand.new
95
- [:key, :host].each do |option|
96
- cmd.options[option] = options[option]
97
- end
98
- cmd.options[:quiet] = options[:quiet]
99
- cmd.options[:quiet_success] = true
100
- cmd.execute
101
- true
102
- end
103
-
104
- def tag
105
- cmd = TagCommand.new
106
- cmd.options[:quiet] = options[:quiet]
107
- cmd.options[:quiet_success] = true
108
- cmd.options[:push_tags_only] = true
109
- cmd.options[:destination] = options[:destination]
110
- cmd.execute
111
- true
112
- end
5
+ include Gem::Release::GemCommand
6
+ self.cmd = :bump
113
7
  end
@@ -1,31 +1,7 @@
1
- class Gem::Commands::GemspecCommand < Gem::Command
2
- include GemRelease
3
- include Helpers, CommandOptions
4
-
5
- DEFAULTS = {
6
- :strategy => 'git',
7
- :quiet => false
8
- }
9
-
10
- attr_reader :arguments, :usage, :name
11
-
12
- def initialize(options = {})
13
- @name = 'bootstrap'
14
- super @name, 'Bootstrap a new gem source repository', default_options_with(options)
1
+ require 'gem/release/support/gem_command'
2
+ require 'gem/release/cmds/gemspec'
15
3
 
16
- option :strategy, '-f', 'Strategy for collecting files [glob|git] in .gemspec'
17
- option :quiet, '-q', 'Do not output status messages'
18
- end
19
-
20
- def execute
21
- gemspec = GemspecTemplate.new(options)
22
- if gemspec.exists?
23
- say "Skipping #{gemspec.filename}: already exists" unless quiet?
24
- else
25
- say "Creating #{gemspec.filename}" unless quiet?
26
- gemspec.write
27
-
28
- success
29
- end
30
- end
4
+ class Gem::Commands::GemspecCommand < Gem::Command
5
+ include Gem::Release::GemCommand
6
+ self.cmd = :gemspec
31
7
  end
@@ -1,73 +1,7 @@
1
- require 'rubygems/commands/build_command'
2
- require 'rubygems/commands/push_command'
3
- require 'rubygems/commands/tag_command'
1
+ require 'gem/release/support/gem_command'
2
+ require 'gem/release/cmds/release'
4
3
 
5
4
  class Gem::Commands::ReleaseCommand < Gem::Command
6
- include GemRelease, Gem::Commands
7
- include Helpers, CommandOptions
8
-
9
- DEFAULTS = {
10
- :tag => false,
11
- :quiet => false,
12
- :key => '',
13
- :host => '',
14
- :destination => "origin",
15
- }
16
-
17
- attr_reader :arguments, :usage, :name
18
-
19
- def initialize(options = {})
20
- @name = 'release'
21
- super @name, 'Build gem from a gemspec and push to rubygems.org', default_options_with(options)
22
-
23
- option :tag, '-t', 'Create a git tag and push it to the destination'
24
- option :destination, '-d', 'Destination git repository'
25
- option :quiet, '-q', 'Do not output status messages'
26
- option :key, '-k', 'Use the given API key from ~/.gem/credentials'
27
- option :host, '-h', 'Push to a gemcutter-compatible host other than rubygems.org'
28
-
29
- @arguments = "gemspec - optional gemspec file name, will use the first *.gemspec if not specified"
30
- @usage = "#{program_name} [gemspec]"
31
- end
32
-
33
- def execute
34
- tasks = [:build, :push, :cleanup]
35
- tasks.push(:tag) if options[:tag]
36
-
37
- in_gemspec_dirs do
38
- tasks.each do |task|
39
- run_cmd(task)
40
- end
41
- end
42
-
43
- success
44
- end
45
-
46
- protected
47
-
48
- def build
49
- BuildCommand.new.invoke(gemspec_filename)
50
- true
51
- end
52
-
53
- def push
54
- args = []
55
- [:key, :host].each do |option|
56
- args += ["--#{option}", options[option]] unless options[option] == ''
57
- end
58
- args += "--quiet" if quiet?
59
-
60
- PushCommand.new.invoke(gem_filename, *args)
61
- true
62
- end
63
-
64
- def cleanup
65
- say "Deleting left over gem file #{gem_filename}" unless quiet?
66
- system("rm #{gem_filename}")
67
- end
68
-
69
- def tag
70
- TagCommand.new(:quiet => quiet?, :quiet_success => true).invoke
71
- true
72
- end
5
+ include Gem::Release::GemCommand
6
+ self.cmd = :release
73
7
  end