gemsmith 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{LICENSE.rdoc → LICENSE.md} +1 -1
- data/README.md +154 -0
- data/lib/gemsmith.rb +2 -2
- data/lib/gemsmith/cli.rb +32 -131
- data/lib/gemsmith/cli_helpers.rb +90 -0
- data/lib/gemsmith/cli_options.rb +94 -0
- data/lib/gemsmith/skeletons/base_skeleton.rb +35 -0
- data/lib/gemsmith/skeletons/cli_skeleton.rb +10 -0
- data/lib/gemsmith/skeletons/default_skeleton.rb +21 -0
- data/lib/gemsmith/skeletons/documentation_skeleton.rb +12 -0
- data/lib/gemsmith/skeletons/git_skeleton.rb +13 -0
- data/lib/gemsmith/skeletons/rails_skeleton.rb +51 -0
- data/lib/gemsmith/skeletons/rspec_skeleton.rb +17 -0
- data/lib/gemsmith/skeletons/travis_skeleton.rb +9 -0
- data/lib/gemsmith/templates/{gem.gemspec.tmp → %gem_name%/%gem_name%.gemspec.tt} +4 -3
- data/lib/gemsmith/templates/{gitignore.tmp → %gem_name%/.gitignore.tt} +2 -1
- data/lib/gemsmith/templates/{rspec.tmp → %gem_name%/.rspec.tt} +0 -0
- data/lib/gemsmith/templates/%gem_name%/.ruby-version.tt +1 -0
- data/lib/gemsmith/templates/{travis.yml.tmp → %gem_name%/.travis.yml.tt} +0 -2
- data/lib/gemsmith/templates/{CHANGELOG.rdoc.tmp → %gem_name%/CHANGELOG.md.tt} +1 -1
- data/lib/gemsmith/templates/{CONTRIBUTING.md.tmp → %gem_name%/CONTRIBUTING.md.tt} +0 -0
- data/lib/gemsmith/templates/{Gemfile.tmp → %gem_name%/Gemfile.tt} +0 -0
- data/lib/gemsmith/templates/{LICENSE.rdoc.tmp → %gem_name%/LICENSE.md.tt} +1 -1
- data/lib/gemsmith/templates/%gem_name%/README.md.tt +59 -0
- data/lib/gemsmith/templates/{Rakefile.tmp → %gem_name%/Rakefile.tt} +0 -0
- data/lib/gemsmith/templates/{bin/gem.tmp → %gem_name%/bin/%gem_name%.tt} +0 -0
- data/lib/gemsmith/templates/{gemfiles/rails-3.2.x.gemfile.tmp → %gem_name%/gemfiles/rails-3.2.x.gemfile.tt} +1 -1
- data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%.rb.tt +33 -0
- data/lib/gemsmith/templates/{lib/gem/action_controller/class_methods.rb.tmp → %gem_name%/lib/%gem_name%/action_controller/class_methods.rb.tt} +2 -2
- data/lib/gemsmith/templates/{lib/gem/action_controller/instance_methods.rb.tmp → %gem_name%/lib/%gem_name%/action_controller/instance_methods.rb.tt} +0 -0
- data/lib/gemsmith/templates/{lib/gem/action_view/instance_methods.rb.tmp → %gem_name%/lib/%gem_name%/action_view/instance_methods.rb.tt} +0 -0
- data/lib/gemsmith/templates/{lib/gem/active_record/class_methods.rb.tmp → %gem_name%/lib/%gem_name%/active_record/class_methods.rb.tt} +2 -2
- data/lib/gemsmith/templates/{lib/gem/active_record/instance_methods.rb.tmp → %gem_name%/lib/%gem_name%/active_record/instance_methods.rb.tt} +0 -0
- data/lib/gemsmith/templates/{lib/gem/cli.rb.tmp → %gem_name%/lib/%gem_name%/cli.rb.tt} +1 -1
- data/lib/gemsmith/templates/{lib/gem/version.rb.tmp → %gem_name%/lib/%gem_name%/version.rb.tt} +0 -0
- data/lib/gemsmith/templates/{lib/generators/gem/install/USAGE.tmp → %gem_name%/lib/generators/%gem_name%/install/USAGE.tt} +0 -0
- data/lib/gemsmith/templates/{lib/generators/gem/install/install_generator.rb.tmp → %gem_name%/lib/generators/%gem_name%/install/install_generator.rb.tt} +0 -0
- data/lib/gemsmith/templates/{lib/generators/gem/upgrade/USAGE.tmp → %gem_name%/lib/generators/%gem_name%/upgrade/USAGE.tt} +0 -0
- data/lib/gemsmith/templates/{lib/generators/gem/upgrade/upgrade_generator.rb.tmp → %gem_name%/lib/generators/%gem_name%/upgrade/upgrade_generator.rb.tt} +0 -0
- data/lib/gemsmith/templates/{spec/gem_spec.rb.tmp → %gem_name%/spec/%gem_name%_spec.rb.tt} +0 -0
- data/lib/gemsmith/templates/{spec/spec_helper.rb.tmp → %gem_name%/spec/spec_helper.rb.tt} +2 -1
- data/lib/gemsmith/version.rb +1 -1
- metadata +61 -40
- data/CHANGELOG.rdoc +0 -134
- data/README.rdoc +0 -133
- data/lib/gemsmith/templates/README.rdoc.tmp +0 -59
- data/lib/gemsmith/templates/gemfiles/rails-3.0.x.gemfile.tmp +0 -5
- data/lib/gemsmith/templates/gemfiles/rails-3.1.x.gemfile.tmp +0 -5
- data/lib/gemsmith/templates/lib/gem.rb.tmp +0 -33
@@ -0,0 +1,94 @@
|
|
1
|
+
module Gemsmith
|
2
|
+
module CLIOptions
|
3
|
+
module_function
|
4
|
+
|
5
|
+
# Initializes template options with default and/or command line overrides.
|
6
|
+
# ==== Parameters
|
7
|
+
# * +name+ - Required. The gem name.
|
8
|
+
# * +options+ - Optional. Additional command line options. Default: {}.
|
9
|
+
def initialize_template_options name, options = {}
|
10
|
+
@settings.merge! options
|
11
|
+
@settings = enforce_symbol_keys @settings
|
12
|
+
|
13
|
+
gem_name name
|
14
|
+
gem_class name
|
15
|
+
|
16
|
+
@template_options = {
|
17
|
+
gem_name: gem_name,
|
18
|
+
gem_class: gem_class,
|
19
|
+
gem_platform: gem_platform,
|
20
|
+
gem_url: gem_url,
|
21
|
+
author_name: author_name,
|
22
|
+
author_email: author_email,
|
23
|
+
author_url: author_url,
|
24
|
+
company_name: company_name,
|
25
|
+
company_url: company_url,
|
26
|
+
github_user: github_user,
|
27
|
+
year: year,
|
28
|
+
ruby_version: ruby_version,
|
29
|
+
ruby_patch: ruby_patch,
|
30
|
+
rails_version: rails_version,
|
31
|
+
post_install_message: @settings[:post_install_message],
|
32
|
+
bin: default_boolean(:bin),
|
33
|
+
rails: default_boolean(:rails),
|
34
|
+
pry: default_boolean(:pry, true),
|
35
|
+
guard: default_boolean(:guard, true),
|
36
|
+
rspec: default_boolean(:rspec, true),
|
37
|
+
travis: default_boolean(:travis, true),
|
38
|
+
code_climate: default_boolean(:code_climate, true)
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def gem_platform
|
43
|
+
@settings[:gem_platform] || "Gem::Platform::RUBY"
|
44
|
+
end
|
45
|
+
|
46
|
+
def gem_url
|
47
|
+
@settings[:gem_url] || author_url
|
48
|
+
end
|
49
|
+
|
50
|
+
def author_name
|
51
|
+
@settings[:author_name] || Gemsmith::Kit.git_config_value("user.name") || "TODO: Add full name here."
|
52
|
+
end
|
53
|
+
|
54
|
+
def author_email
|
55
|
+
@settings[:author_email] || Gemsmith::Kit.git_config_value("user.email") || "TODO: Add email address here."
|
56
|
+
end
|
57
|
+
|
58
|
+
def author_url
|
59
|
+
@settings[:author_url] || "https://www.unknown.com"
|
60
|
+
end
|
61
|
+
|
62
|
+
def company_name
|
63
|
+
@settings[:company_name] || author_name
|
64
|
+
end
|
65
|
+
|
66
|
+
def company_url
|
67
|
+
@settings[:company_url] || author_url
|
68
|
+
end
|
69
|
+
|
70
|
+
def github_user
|
71
|
+
@settings[:github_user] || Gemsmith::Kit.git_config_value("github.user") || "unknown"
|
72
|
+
end
|
73
|
+
|
74
|
+
def year
|
75
|
+
@settings[:year] || Time.now.year
|
76
|
+
end
|
77
|
+
|
78
|
+
def ruby_version
|
79
|
+
@settings[:ruby_version] || "2.0.0"
|
80
|
+
end
|
81
|
+
|
82
|
+
def ruby_patch
|
83
|
+
@settings[:ruby_patch] || "p0"
|
84
|
+
end
|
85
|
+
|
86
|
+
def rails_version
|
87
|
+
@settings[:rails_version] || "3.0"
|
88
|
+
end
|
89
|
+
|
90
|
+
def default_boolean key, value = false
|
91
|
+
@settings.has_key?(key) ? @settings[key] : value
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Gemsmith
|
2
|
+
module Skeletons
|
3
|
+
class BaseSkeleton
|
4
|
+
def initialize cli
|
5
|
+
@cli = cli
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.run cli
|
9
|
+
self.new(cli).create
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
public_methods.each { |method| public_send(method) if method =~ /^create_.+$/ }
|
14
|
+
end
|
15
|
+
|
16
|
+
def respond_to? name, include_private = false
|
17
|
+
@cli.respond_to?(name, include_private) || super(name, include_private)
|
18
|
+
end
|
19
|
+
|
20
|
+
def method_missing name, *args, &block
|
21
|
+
if respond_to?(name)
|
22
|
+
@cli.public_send name, *args, &block
|
23
|
+
else
|
24
|
+
super name, *args, &block
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def lib_root
|
31
|
+
"%gem_name%/lib"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Gemsmith
|
2
|
+
module Skeletons
|
3
|
+
class DefaultSkeleton < BaseSkeleton
|
4
|
+
def create_default_files
|
5
|
+
template "%gem_name%/Gemfile.tt", template_options
|
6
|
+
template "%gem_name%/Rakefile.tt", template_options
|
7
|
+
template "%gem_name%/%gem_name%.gemspec.tt", template_options
|
8
|
+
template "#{lib_root}/%gem_name%.rb.tt", template_options
|
9
|
+
template "#{lib_root}/%gem_name%/version.rb.tt", template_options
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_ruby_files
|
13
|
+
template "%gem_name%/.ruby-version.tt", template_options
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_git_files
|
17
|
+
template "%gem_name%/.gitignore.tt", template_options
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Gemsmith
|
2
|
+
module Skeletons
|
3
|
+
class DocumentationSkeleton < BaseSkeleton
|
4
|
+
def create_files
|
5
|
+
template "%gem_name%/README.md.tt", template_options
|
6
|
+
template "%gem_name%/CONTRIBUTING.md.tt", template_options
|
7
|
+
template "%gem_name%/LICENSE.md.tt", template_options
|
8
|
+
template "%gem_name%/CHANGELOG.md.tt", template_options
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Gemsmith
|
2
|
+
module Skeletons
|
3
|
+
class GitSkeleton < BaseSkeleton
|
4
|
+
def create_files
|
5
|
+
Dir.chdir(File.join(destination_root, gem_name)) do
|
6
|
+
`git init`
|
7
|
+
`git add .`
|
8
|
+
`git commit -a -n -m "Gemsmith skeleton created."`
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Gemsmith
|
2
|
+
module Skeletons
|
3
|
+
class RailsSkeleton < BaseSkeleton
|
4
|
+
def create_model_files
|
5
|
+
template "#{model_root}/class_methods.rb.tt", template_options
|
6
|
+
template "#{model_root}/instance_methods.rb.tt", template_options
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_view_files
|
10
|
+
template "#{lib_gem_root}/action_view/instance_methods.rb.tt", template_options
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_controller_files
|
14
|
+
template "#{controller_root}/class_methods.rb.tt", template_options
|
15
|
+
template "#{controller_root}/instance_methods.rb.tt", template_options
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_generator_files
|
19
|
+
empty_directory "#{generator_root}/templates"
|
20
|
+
template "#{generator_root}/install/install_generator.rb.tt", template_options
|
21
|
+
template "#{generator_root}/install/USAGE.tt", template_options
|
22
|
+
template "#{generator_root}/upgrade/upgrade_generator.rb.tt", template_options
|
23
|
+
template "#{generator_root}/upgrade/USAGE.tt", template_options
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_travis_gemfiles
|
27
|
+
if template_options[:travis]
|
28
|
+
template "%gem_name%/gemfiles/rails-3.2.x.gemfile.tt", template_options
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def lib_gem_root
|
35
|
+
"#{lib_root}/%gem_name%"
|
36
|
+
end
|
37
|
+
|
38
|
+
def model_root
|
39
|
+
"#{lib_gem_root}/active_record"
|
40
|
+
end
|
41
|
+
|
42
|
+
def controller_root
|
43
|
+
"#{lib_gem_root}/action_controller"
|
44
|
+
end
|
45
|
+
|
46
|
+
def generator_root
|
47
|
+
"#{lib_root}/generators/%gem_name%"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Gemsmith
|
2
|
+
module Skeletons
|
3
|
+
class RspecSkeleton < BaseSkeleton
|
4
|
+
def create_files
|
5
|
+
template "%gem_name%/.rspec.tt", template_options
|
6
|
+
template "#{rspec_root}/spec_helper.rb.tt", template_options
|
7
|
+
template "#{rspec_root}/%gem_name%_spec.rb.tt", template_options
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def rspec_root
|
13
|
+
"%gem_name%/spec"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -29,7 +29,8 @@ Gem::Specification.new do |s|
|
|
29
29
|
<%- end -%>
|
30
30
|
<%- if config[:pry] -%>
|
31
31
|
s.add_development_dependency "pry"
|
32
|
-
s.add_development_dependency "pry-
|
32
|
+
s.add_development_dependency "pry-debugger"
|
33
|
+
s.add_development_dependency "pry-rescue"
|
33
34
|
s.add_development_dependency "pry-stack_explorer"
|
34
35
|
s.add_development_dependency "pry-vterm_aliases"
|
35
36
|
<%- end -%>
|
@@ -45,9 +46,9 @@ Gem::Specification.new do |s|
|
|
45
46
|
s.add_development_dependency "rb-inotify" # Guard file events for Linux.
|
46
47
|
s.add_development_dependency "guard-rspec"
|
47
48
|
<%- end -%>
|
48
|
-
|
49
|
+
|
49
50
|
s.files = Dir["lib/**/*", "vendor/**/*"]
|
50
|
-
s.extra_rdoc_files = Dir["README*", "
|
51
|
+
s.extra_rdoc_files = Dir["README*", "LICENSE*"]
|
51
52
|
<%- if config[:bin] -%>
|
52
53
|
s.executables << "<%= config[:gem_name] %>"
|
53
54
|
<%- end -%>
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= [config[:ruby_version], config[:ruby_patch]] * '-' %>
|
File without changes
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) <%= config[:year] %>
|
1
|
+
Copyright (c) <%= config[:year] %> [<%= config[:company_name] %>](<%= config[:company_url] %>).
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Overview
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/<%= config[:gem_name] %>)
|
4
|
+
<%- if config[:code_climate] -%>
|
5
|
+
[](https://codeclimate.com/github/<%= config[:github_user] %>/<%= config[:gem_name] %>)
|
6
|
+
<%- end -%>
|
7
|
+
<%- if config[:travis] -%>
|
8
|
+
[](http://travis-ci.org/<%= config[:github_user] %>/<%= config[:gem_name] %>)
|
9
|
+
<%- end -%>
|
10
|
+
|
11
|
+
# Features
|
12
|
+
|
13
|
+
# Requirements
|
14
|
+
|
15
|
+
<%- if config[:rails] -%>
|
16
|
+
0. [Ruby on Rails](http://rubyonrails.org).
|
17
|
+
<%- end -%>
|
18
|
+
|
19
|
+
# Setup
|
20
|
+
|
21
|
+
Type the following from the command line to install:
|
22
|
+
|
23
|
+
gem install <%= config[:gem_name] %>
|
24
|
+
|
25
|
+
<%- if config[:rails] -%>
|
26
|
+
Add the following to your Gemfile:
|
27
|
+
|
28
|
+
gem "<%= config[:gem_name] %>"
|
29
|
+
<%- end -%>
|
30
|
+
|
31
|
+
# Usage
|
32
|
+
|
33
|
+
<%- if config[:rspec] -%>
|
34
|
+
# Tests
|
35
|
+
|
36
|
+
To test, do the following:
|
37
|
+
|
38
|
+
0. cd to the gem root.
|
39
|
+
0. bundle install
|
40
|
+
0. bundle exec rspec spec
|
41
|
+
<%- end -%>
|
42
|
+
|
43
|
+
# Contributions
|
44
|
+
|
45
|
+
Read CONTRIBUTING for details.
|
46
|
+
|
47
|
+
# Credits
|
48
|
+
|
49
|
+
Developed by [<%= config[:author_name] %>](<%= config[:author_url] %>) at [<%= config[:company_name] %>](<%= config[:company_url] %>).
|
50
|
+
|
51
|
+
# License
|
52
|
+
|
53
|
+
Copyright (c) <%= config[:year] %> [<%= config[:company_name] %>](<%= config[:company_url] %>).
|
54
|
+
Read the LICENSE for details.
|
55
|
+
|
56
|
+
# History
|
57
|
+
|
58
|
+
Read the CHANGELOG for details.
|
59
|
+
Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
|
File without changes
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "<%= config[:gem_name] %>/version"
|
2
|
+
|
3
|
+
<%- if config[:rails] -%>
|
4
|
+
# Rails Enhancements
|
5
|
+
if defined? Rails
|
6
|
+
# Dependencies
|
7
|
+
require "<%= config[:gem_name] %>/active_record/class_methods"
|
8
|
+
require "<%= config[:gem_name] %>/active_record/instance_methods"
|
9
|
+
require "<%= config[:gem_name] %>/action_view/instance_methods"
|
10
|
+
require "<%= config[:gem_name] %>/action_controller/class_methods"
|
11
|
+
require "<%= config[:gem_name] %>/action_controller/instance_methods"
|
12
|
+
|
13
|
+
# Model
|
14
|
+
if defined? ActiveRecord
|
15
|
+
ActiveRecord::Base.send :include, <%= config[:gem_class] %>::ActiveRecord
|
16
|
+
end
|
17
|
+
|
18
|
+
# View
|
19
|
+
if defined? ActionView
|
20
|
+
ActionView::Base.send :include, <%= config[:gem_class] %>::ActionView
|
21
|
+
end
|
22
|
+
|
23
|
+
# Controller
|
24
|
+
if defined? ActionController
|
25
|
+
ActionController::Base.send :include, <%= config[:gem_class] %>::ActionController
|
26
|
+
end
|
27
|
+
end
|
28
|
+
<%- else -%>
|
29
|
+
# Namespace
|
30
|
+
module <%= config[:gem_class] %>
|
31
|
+
# TODO - Add code here.
|
32
|
+
end
|
33
|
+
<%- end -%>
|