gemsmith 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,18 @@
1
+ = v1.3.0
2
+
3
+ * Specified Thor+ 0.2.x version dependency.
4
+ * Added Travis CI support.
5
+ * Added Travis CI template support (can be disable via your settings.yml or during new gem creation).
6
+ * Added the spec/tmp directory to the gitignore template.
7
+ * Added Gemsmith::Kit class with a supplementary utility method for obtaining .gitconfig values.
8
+ * Added github user support - Defaults to github config file or settings.yml.
9
+ * Updated RSpec format to better represent class and instance methods.
10
+ * Removed the -w option from gem binary and the binary template.
11
+ * No longer shell out to Git when referencing the gem/template files in gemspecs - This increases Rails boot performance.
12
+ * Switched Gemfile and Gemfile.tmp reference from "http://rubygems.org" to :rubygems.
13
+ * Moved documentation files to the extra_rdoc_files option for gem specifications
14
+ * Removed the packaging of test files.
15
+
1
16
  = v1.2.0
2
17
 
3
18
  * Updated README and README template with new layout for test instructions.
@@ -1,5 +1,7 @@
1
1
  = Overview
2
2
 
3
+ {<img src="https://secure.travis-ci.org/bkuhlmann/gemsmith.png" />}[http://travis-ci.org/bkuhlmann/gemsmith]
4
+
3
5
  Gemsmith allows you to easily craft new gems via the command line with custom settings (if desired). If you are
4
6
  a fan of Bundler[https://github.com/carlhuda/bundler], then you'll appreciate the additional capabilities of this
5
7
  gem. Gemsmith is essentially an enhanced version of Bundler's gem building capabilities.
@@ -7,10 +9,11 @@ gem. Gemsmith is essentially an enhanced version of Bundler's gem building capab
7
9
  = Features
8
10
 
9
11
  * Builds a gem skeleton with Bundler functionality in mind.
10
- * Allows for common settings that can be applied to new gem creations.
12
+ * Supports common settings that can be applied to new gem creations.
11
13
  * Supports binary skeletons with Thor[https://github.com/wycats/thor] command line functionality.
12
14
  * Supports {Ruby on Rails}[http://rubyonrails.org] skeletons.
13
- * Supports RSpec[http://rspec.info] test skeletons.
15
+ * Supports RSpec[http://rspec.info] skeletons.
16
+ * Supports {Travis CI}[http://travis-ci.org] skeletons.
14
17
  * Adds commonly needed README, CHANGELOG, LICENSE, etc. template files.
15
18
  * Provides the ability to open any installed gem within your favorite editor.
16
19
 
@@ -48,10 +51,10 @@ If no options are configured, then the defaults are as follows:
48
51
  gem_url: <author URL>
49
52
  company_name: <author name>
50
53
  company_url: <author URL>
54
+ github_user: <github user>
51
55
  year: <current year>
52
56
  ruby_version: 1.9.0
53
57
  rails_version: 3.1.0
54
- post_install_message: nil
55
58
 
56
59
  = Usage
57
60
 
@@ -65,10 +68,12 @@ From the command line, type: gemsmith help
65
68
 
66
69
  For more gem creation options, type: gemsmith help create
67
70
 
68
- -b, [--bin] # Add binary support.
69
- -r, [--rails] # Add Rails support.
70
- -s, [--rspec] # Add RSpec support.
71
- # Default: true
71
+ -b, [--bin] # Add binary support.
72
+ -r, [--rails] # Add Rails support.
73
+ -s, [--rspec] # Add RSpec support.
74
+ # Default: true
75
+ -t, [--travis] # Add Travis CI support.
76
+ # Default: true
72
77
 
73
78
  Also, don't forget that once you have created your gem skeleton, the following rake tasks are also
74
79
  available to you via Bundler (i.e. rake -T):
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby -w
1
+ #!/usr/bin/ruby
2
2
  # encoding: UTF-8
3
3
 
4
4
  require "gemsmith"
@@ -1 +1,2 @@
1
1
  require File.join File.dirname(__FILE__), "gemsmith", "version.rb"
2
+ require File.join File.dirname(__FILE__), "gemsmith", "kit.rb"
@@ -25,12 +25,13 @@ module Gemsmith
25
25
  method_option :bin, aliases: "-b", desc: "Add binary support.", type: :boolean, default: false
26
26
  method_option :rails, aliases: "-r", desc: "Add Rails support.", type: :boolean, default: false
27
27
  method_option :rspec, aliases: "-s", desc: "Add RSpec support.", type: :boolean, default: true
28
+ method_option :travis, aliases: "-t", desc: "Add Travis CI support.", type: :boolean, default: true
28
29
  def create name
29
30
  say
30
31
  info "Creating gem..."
31
-
32
+
32
33
  # Initialize options.
33
- template_options = build_template_options name, options
34
+ template_options = build_template_options name, @settings, options
34
35
  gem_name = template_options[:gem_name]
35
36
 
36
37
  # Configure templates.
@@ -77,6 +78,11 @@ module Gemsmith
77
78
  template File.join("spec", "spec_helper.rb.tmp"), File.join(target_path, "spec", "spec_helper.rb"), template_options
78
79
  template File.join("spec", "gem_spec.rb.tmp"), File.join(target_path, "spec", "#{gem_name}_spec.rb"), template_options
79
80
  end
81
+
82
+ # Travis CI (optional).
83
+ if template_options[:travis]
84
+ template "travis.yml.tmp", File.join(target_path, ".travis.yml"), template_options
85
+ end
80
86
 
81
87
  # Git
82
88
  Dir.chdir(target_path) do
@@ -137,31 +143,34 @@ module Gemsmith
137
143
  # Builds template options with default and/or custom settings (where the custom
138
144
  # settings trump default settings).
139
145
  # ==== Parameters
140
- # * +name+ - Required. The gem name.
141
- # * +options+ - Optional. Additional command line options. Default: {}
142
- def build_template_options name, options = {}
143
- gem_name = Thor::Util.snake_case name
144
- gem_class = Thor::Util.camel_case name
145
- author_name = @settings[:author_name] || `git config user.name`.chomp || "TODO: Add full name here."
146
- author_email = @settings[:author_email] || `git config user.email`.chomp || "TODO: Add email address here."
147
- author_url = @settings[:author_url] || "https://www.unknown.com"
146
+ # * +gem_name+ - Required. The gem name.
147
+ # * +settings+ - Optional. The custom settings. Default: {}.
148
+ # * +options+ - Optional. Additional command line options. Default: {}.
149
+ def build_template_options gem_name, settings = {}, options = {}
150
+ gem_name = Thor::Util.snake_case gem_name
151
+ gem_class = Thor::Util.camel_case gem_name
152
+ author_name = settings[:author_name] || Gemsmith::Kit.git_config_value("user.name") || "TODO: Add full name here."
153
+ author_email = settings[:author_email] || Gemsmith::Kit.git_config_value("user.email") || "TODO: Add email address here."
154
+ author_url = settings[:author_url] || "https://www.unknown.com"
148
155
  {
149
156
  gem_name: gem_name,
150
157
  gem_class: gem_class,
151
- gem_platform: (@settings[:gem_platform] || "Gem::Platform::RUBY"),
158
+ gem_platform: (settings[:gem_platform] || "Gem::Platform::RUBY"),
152
159
  author_name: author_name,
153
160
  author_email: author_email,
154
161
  author_url: (author_url || "http://www.unknown.com"),
155
- gem_url: (@settings[:gem_url] || author_url),
156
- company_name: (@settings[:company_name] || author_name),
157
- company_url: (@settings[:company_url] || author_url),
158
- year: (@settings[:year] || Time.now.year),
159
- ruby_version: (@settings[:ruby_version] || "1.9.0"),
160
- rails_version: (@settings[:rails_version] || "3.1.0"),
161
- post_install_message: @settings[:post_install_message],
162
+ gem_url: (settings[:gem_url] || author_url),
163
+ company_name: (settings[:company_name] || author_name),
164
+ company_url: (settings[:company_url] || author_url),
165
+ github_user: (settings[:github_user] || Gemsmith::Kit.git_config_value("github.user") || "unknown"),
166
+ year: (settings[:year] || Time.now.year),
167
+ ruby_version: (settings[:ruby_version] || "1.9.0"),
168
+ rails_version: (settings[:rails_version] || "3.1.0"),
169
+ post_install_message: settings[:post_install_message],
162
170
  bin: (options[:bin] || false),
163
171
  rails: (options[:rails] || false),
164
- rspec: (options[:rspec].nil? ? true : options[:rspec]),
172
+ rspec: (options[:rspec] || true),
173
+ travis: (options[:travis] || true)
165
174
  }
166
175
  end
167
176
  end
@@ -0,0 +1,12 @@
1
+ module Gemsmith
2
+ # Provides supplementary utility methods.
3
+ class Kit
4
+ # Answers the git config (i.e. ~/.gitconfig) value for a given key, otherwise nil.
5
+ # ==== Parameters
6
+ # # * +key+ - Required. The git config key to search for.
7
+ def self.git_config_value key
8
+ value = `git config #{key}`.chomp
9
+ value.nil? || value.empty? ? nil : value
10
+ end
11
+ end
12
+ end
@@ -1,2 +1,2 @@
1
- source "http://rubygems.org"
1
+ source :rubygems
2
2
  gemspec
@@ -1,5 +1,9 @@
1
1
  = Overview
2
2
 
3
+ <%- if config[:travis] -%>
4
+ {<img src="https://secure.travis-ci.org/<%= config[:github_user] %>/<%= config[:gem_name] %>.png" />}[http://travis-ci.org/<%= config[:github_user] %>/<%= config[:gem_name] %>]
5
+ <%- end -%>
6
+
3
7
  = Features
4
8
 
5
9
  = Requirements
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby -w
1
+ #!/usr/bin/ruby
2
2
  # encoding: UTF-8
3
3
 
4
4
  require "<%= config[:gem_name] %>"
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.post_install_message = "<%= config[:post_install_message] %>"
17
17
  <%- end -%>
18
18
 
19
- s.rdoc_options << "CHANGELOG.rdoc"
20
19
  s.required_ruby_version = "~> <%= config[:ruby_version] %>"
21
20
  <%- if config[:bin] -%>
22
21
  s.add_dependency "thor"
@@ -25,18 +24,20 @@ Gem::Specification.new do |s|
25
24
  <%- if config[:rails] -%>
26
25
  s.add_dependency "rails", "~> <%= config[:rails_version] %>"
27
26
  <%- end -%>
27
+ <%- if config[:travis] -%>
28
+ s.add_development_dependency "rake"
29
+ <%- end -%>
28
30
  <%- if config[:rspec] -%>
29
31
  s.add_development_dependency "rspec"
30
32
  <%- end -%>
31
33
  <%- if config[:bin] -%>
32
34
  s.add_development_dependency "aruba"
33
35
  <%- end -%>
36
+
37
+ s.files = Dir["lib/**/*"]
38
+ s.extra_rdoc_files = Dir["README*", "CHANGELOG*", "LICENSE*"]
34
39
  <%- if config[:bin] -%>
35
- s.executables << "<%= config[:gem_name] %>"
40
+ s.executables << "<%= config[:gem_name] %>"
36
41
  <%- end -%>
37
-
38
- s.files = `git ls-files`.split("\n")
39
- s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
40
- s.executables = `git ls-files -- bin/*`.split("\n").map {|f| File.basename f}
41
- s.require_paths = ["lib"]
42
+ s.require_paths = ["lib"]
42
43
  end
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ spec/tmp
@@ -1,2 +1,2 @@
1
1
  --color
2
- --format documentation
2
+ --format documentation
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ script: bundle exec rspec spec
@@ -1,3 +1,3 @@
1
1
  module Gemsmith
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemsmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-02 00:00:00.000000000Z
12
+ date: 2012-01-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70133761355280 !ruby/object:Gem::Requirement
16
+ requirement: &70314477299460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,32 @@ dependencies:
21
21
  version: 0.14.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70133761355280
24
+ version_requirements: *70314477299460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor_plus
27
- requirement: &70133761354820 !ruby/object:Gem::Requirement
27
+ requirement: &70314477299000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.1.0
32
+ version: 0.2.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70133761354820
35
+ version_requirements: *70314477299000
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70314477298620 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70314477298620
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: rspec
38
- requirement: &70133761354440 !ruby/object:Gem::Requirement
49
+ requirement: &70314477298160 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '0'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *70133761354440
57
+ version_requirements: *70314477298160
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: aruba
49
- requirement: &70133761384180 !ruby/object:Gem::Requirement
60
+ requirement: &70314477297740 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,26 +65,20 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *70133761384180
68
+ version_requirements: *70314477297740
58
69
  description: ! 'Ruby gem skeleton generation for the professional gemsmith. Includes
59
70
  custom settings, binary, Ruby on Rails, and RSpec support. '
60
71
  email: brooke@redalchemist.com
61
72
  executables:
62
73
  - gemsmith
63
74
  extensions: []
64
- extra_rdoc_files: []
65
- files:
66
- - .gitignore
67
- - .rspec
75
+ extra_rdoc_files:
76
+ - README.rdoc
68
77
  - CHANGELOG.rdoc
69
- - Gemfile
70
78
  - LICENSE.rdoc
71
- - README.rdoc
72
- - Rakefile
73
- - bin/gemsmith
74
- - gemsmith.gemspec
75
- - lib/gemsmith.rb
79
+ files:
76
80
  - lib/gemsmith/cli.rb
81
+ - lib/gemsmith/kit.rb
77
82
  - lib/gemsmith/templates/CHANGELOG.rdoc.tmp
78
83
  - lib/gemsmith/templates/Gemfile.tmp
79
84
  - lib/gemsmith/templates/LICENSE.rdoc.tmp
@@ -82,7 +87,6 @@ files:
82
87
  - lib/gemsmith/templates/bin/gem.tmp
83
88
  - lib/gemsmith/templates/gem.gemspec.tmp
84
89
  - lib/gemsmith/templates/gitignore.tmp
85
- - lib/gemsmith/templates/lib/gem.rb.tmp
86
90
  - lib/gemsmith/templates/lib/gem/action_controller/class_methods.rb.tmp
87
91
  - lib/gemsmith/templates/lib/gem/action_controller/instance_methods.rb.tmp
88
92
  - lib/gemsmith/templates/lib/gem/action_view/instance_methods.rb.tmp
@@ -90,6 +94,7 @@ files:
90
94
  - lib/gemsmith/templates/lib/gem/active_record/instance_methods.rb.tmp
91
95
  - lib/gemsmith/templates/lib/gem/cli.rb.tmp
92
96
  - lib/gemsmith/templates/lib/gem/version.rb.tmp
97
+ - lib/gemsmith/templates/lib/gem.rb.tmp
93
98
  - lib/gemsmith/templates/lib/generators/gem/install/USAGE.tmp
94
99
  - lib/gemsmith/templates/lib/generators/gem/install/install_generator.rb.tmp
95
100
  - lib/gemsmith/templates/lib/generators/gem/upgrade/USAGE.tmp
@@ -97,16 +102,18 @@ files:
97
102
  - lib/gemsmith/templates/rspec.tmp
98
103
  - lib/gemsmith/templates/spec/gem_spec.rb.tmp
99
104
  - lib/gemsmith/templates/spec/spec_helper.rb.tmp
105
+ - lib/gemsmith/templates/travis.yml.tmp
100
106
  - lib/gemsmith/version.rb
101
- - spec/settings_spec.rb
102
- - spec/spec_helper.rb
103
- - spec/support/settings.yml
107
+ - lib/gemsmith.rb
108
+ - README.rdoc
109
+ - CHANGELOG.rdoc
110
+ - LICENSE.rdoc
111
+ - bin/gemsmith
104
112
  homepage: http://www.redalchemist.com
105
113
  licenses:
106
114
  - MIT
107
115
  post_install_message: ! '(W): www.redalchemist.com. (T): @ralchemist.'
108
- rdoc_options:
109
- - CHANGELOG.rdoc
116
+ rdoc_options: []
110
117
  require_paths:
111
118
  - lib
112
119
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -127,7 +134,4 @@ rubygems_version: 1.8.13
127
134
  signing_key:
128
135
  specification_version: 3
129
136
  summary: Ruby gem skeleton generation for the professional gemsmith.
130
- test_files:
131
- - spec/settings_spec.rb
132
- - spec/spec_helper.rb
133
- - spec/support/settings.yml
137
+ test_files: []
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format documentation
data/Gemfile DELETED
@@ -1,2 +0,0 @@
1
- source "http://rubygems.org"
2
- gemspec
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require 'bundler/gem_tasks'
@@ -1,30 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "gemsmith/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "gemsmith"
7
- s.version = Gemsmith::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.author = "Brooke Kuhlmann"
10
- s.email = "brooke@redalchemist.com"
11
- s.homepage = "http://www.redalchemist.com"
12
- s.summary = "Ruby gem skeleton generation for the professional gemsmith."
13
- s.description = "Ruby gem skeleton generation for the professional gemsmith. Includes custom settings, binary, Ruby on Rails, and RSpec support. "
14
- s.license = "MIT"
15
- s.post_install_message = "(W): www.redalchemist.com. (T): @ralchemist."
16
-
17
- s.rdoc_options << "CHANGELOG.rdoc"
18
- s.required_ruby_version = "~> 1.9.0"
19
- s.add_dependency "thor", "~> 0.14.0"
20
- s.add_dependency "thor_plus", ">= 0.1.0"
21
- s.add_development_dependency "rspec"
22
- s.add_development_dependency "aruba"
23
- s.executables << "gemsmith"
24
-
25
- s.files = `git ls-files`.split("\n")
26
- s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
27
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
28
- s.require_paths = ["lib"]
29
- end
30
-
@@ -1,69 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Settings" do
4
- before :each do
5
- # Default settings.
6
- class Gemsmith::CLI
7
- def initialize
8
- super
9
- @settings_file = File.join File.dirname(__FILE__), "support", "settings.yml"
10
- @settings = {}
11
- end
12
- end
13
- @cli_default = Gemsmith::CLI.new
14
-
15
- # Custom settings.
16
- class Gemsmith::CLI
17
- def initialize
18
- super
19
- @settings_file = File.join File.dirname(__FILE__), "support", "settings.yml"
20
- @settings = load_yaml @settings_file
21
- end
22
- end
23
- @cli_custom = Gemsmith::CLI.new
24
- end
25
-
26
- context "Load" do
27
- it "should build defaults" do
28
- author_name = `git config user.name`.chomp || "TODO: Add full name here."
29
- author_url = "https://www.unknown.com"
30
- options = @cli_default.send :build_template_options, "test"
31
- options[:gem_name].should be == "test"
32
- options[:gem_class].should be == "Test"
33
- options[:gem_platform].should be == "Gem::Platform::RUBY"
34
- options[:author_name].should be == author_name
35
- options[:author_email].should be == (`git config user.email`.chomp || "TODO: Add email address here.")
36
- options[:author_url].should be == author_url
37
- options[:gem_url].should be == "https://www.unknown.com"
38
- options[:company_name].should be == author_name
39
- options[:company_url].should be == author_url
40
- options[:year].should be == Time.now.year
41
- options[:ruby_version].should be == "1.9.0"
42
- options[:rails_version].should be == "3.1.0"
43
- options[:post_install_message].should be == nil
44
- options[:bin].should be_false
45
- options[:rails].should be_false
46
- options[:rspec].should be_true
47
- end
48
-
49
- it "should be custom" do
50
- options = @cli_custom.send :build_template_options, "test"
51
- options[:gem_name].should be == "test"
52
- options[:gem_class].should be == "Test"
53
- options[:gem_platform].should be == "Gem::Platform::CURRENT"
54
- options[:author_name].should be == "Testy Tester"
55
- options[:author_email].should be == "test@test.com"
56
- options[:author_url].should be == "https://www.test.com"
57
- options[:gem_url].should be == "https://www.gem.com"
58
- options[:company_name].should be == "ACME"
59
- options[:company_url].should be == "https://www.acme.com"
60
- options[:year].should be == 1920
61
- options[:ruby_version].should be == "1.8.0"
62
- options[:rails_version].should be == "2.3.0"
63
- options[:post_install_message].should be == "Follow @tester on Twitter for more info."
64
- options[:bin].should be_false
65
- options[:rails].should be_false
66
- options[:rspec].should be_true
67
- end
68
- end
69
- end
@@ -1,3 +0,0 @@
1
- require "bundler/setup"
2
- require "gemsmith"
3
- require File.join "gemsmith", "cli"
@@ -1,12 +0,0 @@
1
- ---
2
- :gem_platform: Gem::Platform::CURRENT
3
- :author_name: "Testy Tester"
4
- :author_email: "test@test.com"
5
- :author_url: "https://www.test.com"
6
- :gem_url: "https://www.gem.com"
7
- :company_name: "ACME"
8
- :company_url: "https://www.acme.com"
9
- :year: 1920
10
- :ruby_version: 1.8.0
11
- :rails_version: 2.3.0
12
- :post_install_message: "Follow @tester on Twitter for more info."