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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENSE.rdoc → LICENSE.md} +1 -1
  3. data/README.md +154 -0
  4. data/lib/gemsmith.rb +2 -2
  5. data/lib/gemsmith/cli.rb +32 -131
  6. data/lib/gemsmith/cli_helpers.rb +90 -0
  7. data/lib/gemsmith/cli_options.rb +94 -0
  8. data/lib/gemsmith/skeletons/base_skeleton.rb +35 -0
  9. data/lib/gemsmith/skeletons/cli_skeleton.rb +10 -0
  10. data/lib/gemsmith/skeletons/default_skeleton.rb +21 -0
  11. data/lib/gemsmith/skeletons/documentation_skeleton.rb +12 -0
  12. data/lib/gemsmith/skeletons/git_skeleton.rb +13 -0
  13. data/lib/gemsmith/skeletons/rails_skeleton.rb +51 -0
  14. data/lib/gemsmith/skeletons/rspec_skeleton.rb +17 -0
  15. data/lib/gemsmith/skeletons/travis_skeleton.rb +9 -0
  16. data/lib/gemsmith/templates/{gem.gemspec.tmp → %gem_name%/%gem_name%.gemspec.tt} +4 -3
  17. data/lib/gemsmith/templates/{gitignore.tmp → %gem_name%/.gitignore.tt} +2 -1
  18. data/lib/gemsmith/templates/{rspec.tmp → %gem_name%/.rspec.tt} +0 -0
  19. data/lib/gemsmith/templates/%gem_name%/.ruby-version.tt +1 -0
  20. data/lib/gemsmith/templates/{travis.yml.tmp → %gem_name%/.travis.yml.tt} +0 -2
  21. data/lib/gemsmith/templates/{CHANGELOG.rdoc.tmp → %gem_name%/CHANGELOG.md.tt} +1 -1
  22. data/lib/gemsmith/templates/{CONTRIBUTING.md.tmp → %gem_name%/CONTRIBUTING.md.tt} +0 -0
  23. data/lib/gemsmith/templates/{Gemfile.tmp → %gem_name%/Gemfile.tt} +0 -0
  24. data/lib/gemsmith/templates/{LICENSE.rdoc.tmp → %gem_name%/LICENSE.md.tt} +1 -1
  25. data/lib/gemsmith/templates/%gem_name%/README.md.tt +59 -0
  26. data/lib/gemsmith/templates/{Rakefile.tmp → %gem_name%/Rakefile.tt} +0 -0
  27. data/lib/gemsmith/templates/{bin/gem.tmp → %gem_name%/bin/%gem_name%.tt} +0 -0
  28. data/lib/gemsmith/templates/{gemfiles/rails-3.2.x.gemfile.tmp → %gem_name%/gemfiles/rails-3.2.x.gemfile.tt} +1 -1
  29. data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%.rb.tt +33 -0
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. data/lib/gemsmith/templates/{lib/gem/cli.rb.tmp → %gem_name%/lib/%gem_name%/cli.rb.tt} +1 -1
  36. data/lib/gemsmith/templates/{lib/gem/version.rb.tmp → %gem_name%/lib/%gem_name%/version.rb.tt} +0 -0
  37. data/lib/gemsmith/templates/{lib/generators/gem/install/USAGE.tmp → %gem_name%/lib/generators/%gem_name%/install/USAGE.tt} +0 -0
  38. 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
  39. data/lib/gemsmith/templates/{lib/generators/gem/upgrade/USAGE.tmp → %gem_name%/lib/generators/%gem_name%/upgrade/USAGE.tt} +0 -0
  40. 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
  41. data/lib/gemsmith/templates/{spec/gem_spec.rb.tmp → %gem_name%/spec/%gem_name%_spec.rb.tt} +0 -0
  42. data/lib/gemsmith/templates/{spec/spec_helper.rb.tmp → %gem_name%/spec/spec_helper.rb.tt} +2 -1
  43. data/lib/gemsmith/version.rb +1 -1
  44. metadata +61 -40
  45. data/CHANGELOG.rdoc +0 -134
  46. data/README.rdoc +0 -133
  47. data/lib/gemsmith/templates/README.rdoc.tmp +0 -59
  48. data/lib/gemsmith/templates/gemfiles/rails-3.0.x.gemfile.tmp +0 -5
  49. data/lib/gemsmith/templates/gemfiles/rails-3.1.x.gemfile.tmp +0 -5
  50. 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,10 @@
1
+ module Gemsmith
2
+ module Skeletons
3
+ class CLISkeleton < BaseSkeleton
4
+ def create_files
5
+ template "%gem_name%/bin/%gem_name%.tt", template_options
6
+ template "%gem_name%/lib/%gem_name%/cli.rb.tt", template_options
7
+ end
8
+ end
9
+ end
10
+ 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
@@ -0,0 +1,9 @@
1
+ module Gemsmith
2
+ module Skeletons
3
+ class TravisSkeleton < BaseSkeleton
4
+ def create_files
5
+ template "%gem_name%/.travis.yml.tt", template_options
6
+ end
7
+ end
8
+ end
9
+ 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-nav"
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*", "CHANGELOG*", "LICENSE*"]
51
+ s.extra_rdoc_files = Dir["README*", "LICENSE*"]
51
52
  <%- if config[:bin] -%>
52
53
  s.executables << "<%= config[:gem_name] %>"
53
54
  <%- end -%>
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  .bundle
3
+ .ruby-version
3
4
  Gemfile.lock
4
5
  pkg/*
5
- spec/tmp
6
+ spec/tmp
@@ -0,0 +1 @@
1
+ <%= [config[:ruby_version], config[:ruby_patch]] * '-' %>
@@ -3,8 +3,6 @@ rvm:
3
3
  - 2.0.0
4
4
  <%- if config[:rails] -%>
5
5
  gemfile:
6
- - gemfiles/rails-3.0.x.gemfile
7
- - gemfiles/rails-3.1.x.gemfile
8
6
  - gemfiles/rails-3.2.x.gemfile
9
7
  <%- end -%>
10
8
  script: bundle exec rspec spec
@@ -1,3 +1,3 @@
1
- = v0.1.0
1
+ # v0.1.0
2
2
 
3
3
  * Initial version.
@@ -1,4 +1,4 @@
1
- Copyright (c) <%= config[:year] %> {<%= config[:company_name] %>}[<%= config[:company_url] %>].
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
+ [![Gem Version](https://badge.fury.io/rb/<%= config[:gem_name] %>.png)](http://badge.fury.io/rb/<%= config[:gem_name] %>)
4
+ <%- if config[:code_climate] -%>
5
+ [![Code Climate GPA](https://codeclimate.com/github/<%= config[:github_user] %>/<%= config[:gem_name] %>.png)](https://codeclimate.com/github/<%= config[:github_user] %>/<%= config[:gem_name] %>)
6
+ <%- end -%>
7
+ <%- if config[:travis] -%>
8
+ [![Travis CI Status](https://secure.travis-ci.org/<%= config[:github_user] %>/<%= config[:gem_name] %>.png)](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).
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
 
3
3
  gem "rails", "~> 3.2.0"
4
4
 
@@ -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 -%>