gem-release 0.0.24 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,8 +9,8 @@ module GemRelease
9
9
  @email ||= user_email
10
10
  @homepage ||= "https://github.com/#{github_user}/#{name}" || "[your github name]"
11
11
 
12
- @summary ||= '[summary]'
13
- @description ||= '[description]'
12
+ @summary ||= '[TODO: summary]'
13
+ @description ||= '[TODO: description]'
14
14
 
15
15
  @strategy = options[:strategy]
16
16
  end
@@ -30,14 +30,6 @@ module GemRelease
30
30
  File.basename(Dir.pwd)
31
31
  end
32
32
 
33
- def gem_module_path
34
- gem_name.gsub('-', '_')
35
- end
36
-
37
- def gem_module_name
38
- gem_module_path.camelize
39
- end
40
-
41
33
  def gem_filename
42
34
  gemspec.file_name
43
35
  end
@@ -6,7 +6,7 @@ module GemRelease
6
6
  class Template
7
7
  include GemRelease::Helpers
8
8
 
9
- attr_reader :template, :name, :module_name, :module_path
9
+ attr_reader :template, :name, :module_names, :module_path
10
10
 
11
11
  def initialize(template, options = {})
12
12
  @template = template
@@ -16,9 +16,9 @@ module GemRelease
16
16
  meta_class.send(:attr_reader, key)
17
17
  end
18
18
 
19
- @name ||= gem_name_from_directory
20
- @module_path ||= name.gsub('-', '_')
21
- @module_name ||= module_path.camelize
19
+ @name ||= gem_name_from_directory
20
+ @module_path ||= name
21
+ @module_names ||= module_names_from_path(module_path)
22
22
  end
23
23
 
24
24
  def write
@@ -32,6 +32,14 @@ module GemRelease
32
32
 
33
33
  protected
34
34
 
35
+ def module_names_from_path(path)
36
+ names = []
37
+ path.split('-').each do |segment|
38
+ names << segment.camelize
39
+ end
40
+ names
41
+ end
42
+
35
43
  def render
36
44
  ERB.new(read_template, nil, "%").result(binding)
37
45
  end
@@ -5,7 +5,7 @@ require '<%= module_path %>/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = <%= name.inspect %>
8
- s.version = <%= module_name %>::VERSION
8
+ s.version = <%= module_names.join('::') %>::VERSION
9
9
  s.authors = [<%= author.inspect %>]
10
10
  s.email = <%= email.inspect %>
11
11
  s.homepage = <%= homepage.inspect %>
@@ -1,3 +1,12 @@
1
- module <%= module_name %>
2
- VERSION = <%= version.inspect %>
3
- end
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,5 +1,5 @@
1
1
  module GemRelease
2
- VERSION = '0.0.24'
2
+ VERSION = '0.1.0'
3
3
 
4
4
  class Version < Template
5
5
  attr_reader :version
@@ -29,11 +29,19 @@ module GemRelease
29
29
  end
30
30
 
31
31
  def filename
32
- File.expand_path("lib/#{gem_module_path}/version.rb")
32
+ path = gem_name
33
+ path = path.gsub('-', '/') unless File.exists?(path_to_version_file(path))
34
+ path = path.gsub('/', '_') unless File.exists?(path_to_version_file(path))
35
+
36
+ File.expand_path(path_to_version_file(path))
33
37
  end
34
38
 
35
39
  protected
36
40
 
41
+ def path_to_version_file(path)
42
+ "lib/#{path}/version.rb"
43
+ end
44
+
37
45
  def require_version
38
46
  silence { require(filename) }
39
47
  end
@@ -8,7 +8,7 @@ class Gem::Commands::BootstrapCommand < Gem::Command
8
8
  DEFAULTS = {
9
9
  :gemspec => true,
10
10
  :strategy => 'git',
11
- :scaffold => false,
11
+ :scaffold => true,
12
12
  :github => false,
13
13
  :quiet => false
14
14
  }
@@ -19,8 +19,8 @@ class Gem::Commands::BootstrapCommand < Gem::Command
19
19
  super 'bootstrap', 'Bootstrap a new gem source repository', DEFAULTS.merge(options)
20
20
 
21
21
  option :gemspec, '-g', 'Generate a .gemspec'
22
- option :strategy, '-f', 'Strategy for collecting files [glob|git] in .gemspec'
23
22
  option :scaffold, '-s', 'Scaffold lib/[gem_name]/version.rb README test/'
23
+ option :strategy, '-f', 'Strategy for collecting files [glob|git] in .gemspec'
24
24
  option :github, '-h', 'Bootstrap a git repo, create on github and push'
25
25
  option :quiet, '-q', 'Do not output status messages'
26
26
 
@@ -32,6 +32,7 @@ class Gem::Commands::BootstrapCommand < Gem::Command
32
32
  in_bootstrapped_dir do
33
33
  write_scaffold if options[:scaffold]
34
34
  write_gemspec if options[:gemspec]
35
+ init_git if options[:github] || options[:args] # safe to 'git init' in new dir
35
36
  create_repo if options[:github]
36
37
  end
37
38
  end
@@ -64,13 +65,15 @@ class Gem::Commands::BootstrapCommand < Gem::Command
64
65
  end
65
66
  end
66
67
 
68
+ def init_git
69
+ say 'Initializing git repository'
70
+ `git init`
71
+ end
72
+
67
73
  def create_repo
68
74
  options = { :login => github_user, :token => github_token, :name => gem_name }
69
75
  options = options.map { |name, value| "-F '#{name}=#{value}'" }.join(' ')
70
76
 
71
- say 'Bootstrapializing git repository'
72
- `git init`
73
-
74
77
  say 'Staging files'
75
78
  `git add .`
76
79
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-release
3
3
  version: !ruby/object:Gem::Version
4
- hash: 47
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 24
10
- version: 0.0.24
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sven Fuchs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-02 00:00:00 -04:00
18
+ date: 2012-01-29 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency