gemsmith 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = v0.1.0
2
+
3
+ * Initial version.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/LICENSE.rdoc ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 {Red Alchemist}[http://www.redalchemist.com].
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,70 @@
1
+ = Overview
2
+
3
+ Gemsmith allows you to easily craft new gems via the command line with custom settings (if desired). If you are a fan
4
+ of Bundler[https://github.com/carlhuda/bundler] and appreciate the quick and easy setup you get via the +bundle gem+
5
+ command then you'll enjoy this gem since it is essentially an enhanced version of Bundler.
6
+
7
+ = Features
8
+
9
+ * Common custom settings that you can configure once and use for every new gem that you build.
10
+ * Additional skeleton files such as a README, CHANGELOG, and LICENCE (which you pretty much always need).
11
+
12
+ = Requirements
13
+
14
+ * A desire to develop professional gems.
15
+
16
+ = Setup
17
+
18
+ Type the following from the command line to install:
19
+
20
+ gem install gemsmith
21
+
22
+ You can also configure common custom settings that you would like to apply to all new gems that you build. To do this,
23
+ simply create the following file:
24
+
25
+ ~/.gemsmith/settings.yml
26
+
27
+ ...with the following settings (for example):
28
+
29
+ ---
30
+ :gem_platform: Gem::Platform::RUBY
31
+ :author_name: Brooke Kuhlmann
32
+ :author_email: brooke@redalchemist.com
33
+ :author_url: http://www.redalchemist.com
34
+ :company_name: Red Alchmist
35
+ :company_url: http://www.redalchemist.com
36
+
37
+ NOTE: All of the options above are optional. You don't have to create the setting.yml at all or you can pick and
38
+ choose what you want to define. Up to you. If you don't specify any settings then everything defaults as follows:
39
+
40
+ gem_platform: Gem::Platform::RUBY
41
+ author_name: <git user name>
42
+ author_email: <git email>
43
+ author_url: nil
44
+ company_name: <author name>
45
+ company_url: <author URL>
46
+
47
+ = Usage
48
+
49
+ From the command line, type: tweeter help
50
+
51
+ gemsmith -c, [create=GEM_NAME] # Create new gem.
52
+ gemsmith -h, [help] # Show this message.
53
+ gemsmith -v, [version] # Show version.
54
+
55
+ For more gem creation options, type: tweeter help create
56
+
57
+ -b, [--bin] # Add binary to gem build.
58
+
59
+ = Author
60
+
61
+ {Red Alchemist}[http://www.redalchemist.com]
62
+
63
+ = License
64
+
65
+ Copyright (c) 2011 {Red Alchemist}[http://www.redalchemist.com].
66
+ Read the LICENSE for details.
67
+
68
+ = History
69
+
70
+ Read the CHANGELOG for details.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/gemsmith ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ require "gemsmith"
4
+ require "gemsmith/cli"
5
+ Gemsmith::CLI.start
data/gemsmith.gemspec ADDED
@@ -0,0 +1,26 @@
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.authors = ["Brooke Kuhlmann"]
10
+ s.email = ["brooke@redalchemist.com"]
11
+ s.homepage = "http://www.redalchemist.com"
12
+ s.summary = "Craft new gems with custom settings."
13
+ s.description = "Craft new gems with custom settings and reduce setup redundancy."
14
+
15
+ s.rdoc_options << "CHANGELOG.rdoc"
16
+ s.add_dependency "thor", "~> 0.14.0"
17
+ s.add_development_dependency "rspec"
18
+ s.add_development_dependency "aruba"
19
+ s.executables << "gemsmith"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
26
+
data/lib/gemsmith.rb ADDED
@@ -0,0 +1,5 @@
1
+ require File.join File.dirname(__FILE__), "gemsmith", "version.rb"
2
+
3
+ module Gemsmith
4
+ # Placeholder.
5
+ end
@@ -0,0 +1,98 @@
1
+ require "yaml"
2
+ require "thor"
3
+ require "thor/actions"
4
+
5
+ module Gemsmith
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+
9
+ # Overwritten Thor template source root.
10
+ def self.source_root
11
+ File.expand_path File.join(File.dirname(__FILE__), "templates")
12
+ end
13
+
14
+ # Initialize.
15
+ def initialize args = [], options = {}, config = {}
16
+ super
17
+
18
+ # Defaults.
19
+ @shell = shell
20
+ @settings_file = File.join ENV["HOME"], ".gemsmith", "settings.yml"
21
+
22
+ # Load and apply custom settings (if any).
23
+ load_settings
24
+ end
25
+
26
+ desc "-c, [create=GEM_NAME]", "Create new gem."
27
+ map "-c" => :create
28
+ method_option :bin, :aliases => "-b", :desc => "Add binary to gem build.", :type => :boolean, :default => false
29
+ def create name
30
+ shell.say "\nCreating gem..."
31
+
32
+ # Initialize options.
33
+ gem_name = name.downcase
34
+ gem_class = gem_name.capitalize
35
+ author_name = @settings[:author_name] || `git config user.name`.chomp || "TODO: Write full name here."
36
+ author_url = @settings[:author_url] || "TODO: Write home page URL here."
37
+ template_options = {
38
+ :gem_name => gem_name,
39
+ :gem_class => gem_class,
40
+ :gem_platform => (@settings[:gem_platform] || "Gem::Platform::RUBY"),
41
+ :author_name => author_name,
42
+ :author_email => (@settings[:author_email] || `git config user.email`.chomp || "TODO: Write email address here."),
43
+ :author_url => author_url,
44
+ :company_name => (@settings[:company_name] || author_name),
45
+ :company_url => (@settings[:company_url] || author_url),
46
+ :year => Time.now.year
47
+ }
48
+
49
+ # Apply templates.
50
+ target_path = File.join Dir.pwd, gem_name
51
+ empty_directory File.join(target_path, "lib", gem_name)
52
+ template "README.rdoc.tmp", File.join(target_path, "README.rdoc"), template_options
53
+ template "CHANGELOG.rdoc.tmp", File.join(target_path, "CHANGELOG.rdoc"), template_options
54
+ template "LICENSE.rdoc.tmp", File.join(target_path, "LICENSE.rdoc"), template_options
55
+ template "Gemfile.tmp", File.join(target_path, "Gemfile"), template_options
56
+ template "Rakefile.tmp", File.join(target_path, "Rakefile"), template_options
57
+ template "gitignore.tmp", File.join(target_path, ".gitignore"), template_options
58
+ template "gem.gemspec.tmp", File.join(target_path, "#{gem_name}.gemspec"), template_options
59
+ template File.join("lib", "gem.rb.tmp"), File.join(target_path, "lib", "#{gem_name}.rb"), template_options
60
+ template File.join("lib", "gem", "version.rb.tmp"), File.join(target_path, "lib", gem_name, "version.rb"), template_options
61
+ if options[:bin]
62
+ template File.join("bin", "gem.tmp"), File.join(target_path, "bin", gem_name), template_options
63
+ end
64
+
65
+ shell.say "Gem created: #{gem_name}\n\n"
66
+ end
67
+
68
+ desc "-v, [version]", "Show version."
69
+ map "-v" => :version
70
+ def version
71
+ print_version
72
+ end
73
+
74
+ desc "-h, [help]", "Show this message."
75
+ def help task = nil
76
+ shell.say and super
77
+ end
78
+
79
+ private
80
+
81
+ # Load settings.
82
+ def load_settings
83
+ if File.exists? @settings_file
84
+ begin
85
+ settings = YAML::load_file @settings_file
86
+ @settings = settings.reject {|key, value| value.nil?}
87
+ rescue
88
+ shell.say "ERROR: Invalid settings: #{@settings_file}."
89
+ end
90
+ end
91
+ end
92
+
93
+ # Print version information.
94
+ def print_version
95
+ shell.say "Gemsmith " + VERSION
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,3 @@
1
+ = v0.1.0
2
+
3
+ * Initial version.
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) <%= config[:year] %> {<%= config[:company_name] %>}[<%= config[:company_url] %>].
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ = Overview
2
+
3
+ = Features
4
+
5
+ = Requirements
6
+
7
+ = Setup
8
+
9
+ = Usage
10
+
11
+ = Author
12
+
13
+ {<%= config[:company_name] %>}[<%= config[:company_url] %>]
14
+
15
+ = License
16
+
17
+ Copyright (c) <%= config[:year] %> {<%= config[:company_name] %>}[<%= config[:company_url] %>].
18
+ Read the LICENSE for details.
19
+
20
+ = History
21
+
22
+ Read the CHANGELOG for details.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ require "<%= config[:gem_name] %>"
4
+ require "<%= config[:gem_name] %>/cli"
5
+ <%= config[:gem_class] %>::CLI.start
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "<%=config[:gem_name]%>/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "<%= config[:gem_name] %>"
7
+ s.version = <%= config[:gem_class] %>::VERSION
8
+ s.platform = <%= config[:gem_platform] %>
9
+ s.authors = ["<%= config[:author_name] %>"]
10
+ s.email = ["<%= config[:author_email] %>"]
11
+ s.homepage = "<%= config[:author_url] %>"
12
+ s.summary = "TODO: Write gem summary."
13
+ s.description = "TODO: Write gem description."
14
+
15
+ s.rdoc_options << "CHANGELOG.rdoc"
16
+ # s.add_dependency "thor", "~> 1.0.0"
17
+ # s.add_development_dependency "some_gem"
18
+ # s.executables << "gemsmith"
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map {|f| File.basename f}
23
+ s.require_paths = ["lib"]
24
+ end
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
@@ -0,0 +1,5 @@
1
+ require File.join File.dirname(__FILE__), "<%= config[:gem_name] %>", "version.rb"
2
+
3
+ module <%= config[:gem_class] %>
4
+ # Placeholder.
5
+ end
@@ -0,0 +1,3 @@
1
+ module <%= config[:gem_class] %>
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,3 @@
1
+ module Gemsmith
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gemsmith
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Brooke Kuhlmann
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-06-05 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: thor
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 39
29
+ segments:
30
+ - 0
31
+ - 14
32
+ - 0
33
+ version: 0.14.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: aruba
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :development
63
+ version_requirements: *id003
64
+ description: Craft new gems with custom settings and reduce setup redundancy.
65
+ email:
66
+ - brooke@redalchemist.com
67
+ executables:
68
+ - gemsmith
69
+ extensions: []
70
+
71
+ extra_rdoc_files: []
72
+
73
+ files:
74
+ - .gitignore
75
+ - CHANGELOG.rdoc
76
+ - Gemfile
77
+ - LICENSE.rdoc
78
+ - README.rdoc
79
+ - Rakefile
80
+ - bin/gemsmith
81
+ - gemsmith.gemspec
82
+ - lib/gemsmith.rb
83
+ - lib/gemsmith/cli.rb
84
+ - lib/gemsmith/templates/CHANGELOG.rdoc.tmp
85
+ - lib/gemsmith/templates/Gemfile.tmp
86
+ - lib/gemsmith/templates/LICENSE.rdoc.tmp
87
+ - lib/gemsmith/templates/README.rdoc.tmp
88
+ - lib/gemsmith/templates/Rakefile.tmp
89
+ - lib/gemsmith/templates/bin/gem.tmp
90
+ - lib/gemsmith/templates/gem.gemspec.tmp
91
+ - lib/gemsmith/templates/gitignore.tmp
92
+ - lib/gemsmith/templates/lib/gem.rb.tmp
93
+ - lib/gemsmith/templates/lib/gem/version.rb.tmp
94
+ - lib/gemsmith/version.rb
95
+ homepage: http://www.redalchemist.com
96
+ licenses: []
97
+
98
+ post_install_message:
99
+ rdoc_options:
100
+ - CHANGELOG.rdoc
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ requirements: []
122
+
123
+ rubyforge_project:
124
+ rubygems_version: 1.8.4
125
+ signing_key:
126
+ specification_version: 3
127
+ summary: Craft new gems with custom settings.
128
+ test_files: []
129
+