gem_skeleton 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rvmrc
data/.rvmrc.template ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.3@gem_skeleton
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gem_skeleton.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Yi Wen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # GemSkeleton
2
+
3
+ This gem provide a command for making a rubygem skeleton.
4
+
5
+ It basically copied from ```bundle gem``` code and add some more templates and here is extra file list:
6
+
7
+ * .rvmrc (which is ignored in .gitignore)
8
+ * .rvmrc.template
9
+ * .gemspec file: This is not new, But I add rspec related gems and code quality control gems:
10
+ * rspec
11
+ * guard-spork
12
+ * guard-rspec
13
+ * cane
14
+ * simplecov
15
+ * growl-rspec
16
+ * Guardfile, containing the rspec and spork configurations
17
+ * spec/spec_helper.rb
18
+ * tasks/rspec.rb - the rspec task file
19
+ * tasks/ci.rb - the tasks for running ci on jenkins
20
+ * .rspec - rspec confiuration file
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ gem 'gem_skeleton'
27
+
28
+ And then execute:
29
+
30
+ $ bundle
31
+
32
+ Or install it yourself as:
33
+
34
+ $ gem install gem_skeleton
35
+
36
+ ## Usage
37
+
38
+ ```bash
39
+ $ gem_skeleton make your-gem-name
40
+ ```
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/gem_skeleton ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/gem_skeleton'
3
+ require_relative '../lib/gem_skeleton/cli'
4
+ GemSkeleton::CLI.start
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/gem_skeleton/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Yi Wen"]
6
+ gem.email = ["hayafirst@gmail.com"]
7
+ gem.description = %q{A command that make a gem skeleton with rspec in place}
8
+ gem.summary = %q{The command copies part of bundle gem code and add rspec and rvmrc support into the gem skeleton}
9
+ gem.homepage = "https://github.com/ywen/gem_skeleton"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "gem_skeleton"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = GemSkeleton::VERSION
17
+ gem.add_runtime_dependency(%q<thor>)
18
+ end
@@ -0,0 +1,63 @@
1
+ require 'bundler/vendored_thor'
2
+ require 'rubygems/user_interaction'
3
+ require 'rubygems/config_file'
4
+
5
+ module GemSkeleton
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+ check_unknown_options!
9
+
10
+ default_task :make
11
+
12
+ class << self
13
+ def source_root
14
+ File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
15
+ end
16
+
17
+ end
18
+
19
+ desc "make GEM", "Creates a skeleton for creating a rubygem"
20
+ long_desc <<-D
21
+ Make a gem skeleton, with rspec goodies, tasks for settingup ci,
22
+ a Guardfile, a .rvmrc.template, etc.
23
+ D
24
+ method_option :bin, :type => :boolean, :default => false, :aliases => '-b', :banner => "Generate a binary for your library."
25
+ def make(name)
26
+ name = name.chomp("/") # remove trailing slash if present
27
+ target = File.join(Dir.pwd, name)
28
+ constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
29
+ constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
30
+ constant_array = constant_name.split('::')
31
+ FileUtils.mkdir_p(File.join(target, 'lib', name))
32
+ git_user_name = `git config user.name`.chomp
33
+ git_user_email = `git config user.email`.chomp
34
+ opts = {
35
+ :name => name,
36
+ :constant_name => constant_name,
37
+ :constant_array => constant_array,
38
+ :author => git_user_name.empty? ? "TODO: Write your name" : git_user_name,
39
+ :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email
40
+ }
41
+ template(File.join("newgem/Gemfile.tt"), File.join(target, "Gemfile"), opts)
42
+ template(File.join("newgem/Rakefile.tt"), File.join(target, "Rakefile"), opts)
43
+ template(File.join("newgem/LICENSE.tt"), File.join(target, "LICENSE"), opts)
44
+ template(File.join("newgem/README.md.tt"), File.join(target, "README.md"), opts)
45
+ template(File.join("newgem/gitignore.tt"), File.join(target, ".gitignore"), opts)
46
+ template(File.join("newgem/Guardfile.tt"), File.join(target, "Guardfile"), opts)
47
+ template(File.join("newgem/rvmrc.tt"), File.join(target, ".rvmrc"), opts)
48
+ template(File.join("newgem/rvmrc.tt"), File.join(target, ".rvmrc.template"), opts)
49
+ template(File.join("newgem/rspec.tt"), File.join(target, ".rspec"), opts)
50
+ template(File.join("newgem/newgem.gemspec.tt"), File.join(target, "#{name}.gemspec"), opts)
51
+ template(File.join("newgem/lib/newgem.rb.tt"), File.join(target, "lib/#{name}.rb"), opts)
52
+ template(File.join("newgem/lib/newgem/version.rb.tt"), File.join(target, "lib/#{name}/version.rb"), opts)
53
+ template(File.join("newgem/spec/spec_helper.rb.tt"), File.join(target, "spec/spec_helper.rb"), opts)
54
+ template(File.join("newgem/tasks/rspec.rb.tt"), File.join(target, "tasks/rspec.rb"), opts)
55
+ template(File.join("newgem/tasks/ci.rb.tt"), File.join(target, "tasks/ci.rb"), opts)
56
+ if options[:bin]
57
+ template(File.join("newgem/bin/newgem.tt"), File.join(target, 'bin', name), opts)
58
+ end
59
+ puts "Initializating git repo in #{target}"
60
+ Dir.chdir(target) { `git init`; `git add .` }
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in <%=config[:name]%>.gemspec
4
+ gemspec
@@ -0,0 +1,15 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'spork' do
5
+ watch('Gemfile')
6
+ watch('Gemfile.lock')
7
+ watch('spec/spec_helper.rb') { :rspec }
8
+ end
9
+
10
+ guard 'rspec', :cli => "--color --format nested --fail-fast --drb" do
11
+ watch(%r{^spec/.+_spec\.rb$})
12
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
13
+ watch(%r{^lib/galaxy-presenters/(.+)\.rb$}) { |m| [ "lib/galaxy-presenters/#{m[1]}.rb", "spec/lib/galaxy-presenters/#{m[1]}_spec.rb" ] }
14
+ watch('spec/spec_helper.rb') { "spec" }
15
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) <%=Time.now.year%> <%=config[:author]%>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # <%=config[:constant_name]%>
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem '<%=config[:name]%>'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install <%=config[:name]%>
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ Dir["#{File.dirname(__FILE__)}/tasks/**/*.rb"].each {|f| require f}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require '<%= config[:name] %>'
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rvmrc
19
+ test_reports
@@ -0,0 +1,7 @@
1
+ <%- config[:constant_array].each_with_index do |c,i| -%>
2
+ <%= ' '*i %>module <%= c %>
3
+ <%- end -%>
4
+ <%= ' '*config[:constant_array].size %>VERSION = "0.0.1"
5
+ <%- (config[:constant_array].size-1).downto(0) do |i| -%>
6
+ <%= ' '*i %>end
7
+ <%- end -%>
@@ -0,0 +1,9 @@
1
+ require "<%=config[:name]%>/version"
2
+
3
+ <%- config[:constant_array].each_with_index do |c,i| -%>
4
+ <%= ' '*i %>module <%= c %>
5
+ <%- end -%>
6
+ <%= ' '*config[:constant_array].size %># Your code goes here...
7
+ <%- (config[:constant_array].size-1).downto(0) do |i| -%>
8
+ <%= ' '*i %>end
9
+ <%- end -%>
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/<%=config[:name]%>/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = [<%=config[:author].inspect%>]
6
+ gem.email = [<%=config[:email].inspect%>]
7
+ gem.description = %q{TODO: Write a gem description}
8
+ gem.summary = %q{TODO: Write a gem summary}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = <%=config[:name].inspect%>
15
+ gem.require_paths = ["lib"]
16
+ gem.version = <%=config[:constant_name]%>::VERSION
17
+ gem.add_development_dependency(%q<rspec>)
18
+ gem.add_development_dependency(%q<guard-spork>)
19
+ gem.add_development_dependency(%q<guard-rspec>)
20
+ gem.add_development_dependency(%q<cane>)
21
+ gem.add_development_dependency(%q<simplecov>)
22
+ gem.add_development_dependency(%q<growl-rspec>)
23
+ end
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format documentation
@@ -0,0 +1 @@
1
+ rvm 1.9.3@<%=config[:name]%>
@@ -0,0 +1,27 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ SimpleCov.at_exit do
4
+ threshold = 100
5
+ SimpleCov.result.format!
6
+ if SimpleCov.result.covered_percent != threshold
7
+ actual_coverage = SimpleCov.result.covered_percent
8
+ puts "The coverage is #{actual_coverage}%. It has to be 100%"
9
+ exit 1
10
+ end
11
+ end
12
+ end
13
+ require 'spork'
14
+
15
+ Spork.prefork do
16
+ require 'rspec/core'
17
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
18
+ require "#{File.dirname(__FILE__)}/../lib/<%=config[:name]%>"
19
+
20
+ RSpec.configure do |config|
21
+ config.mock_with :rspec
22
+ end
23
+ end
24
+
25
+ Spork.each_run do
26
+ end
27
+
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'rspec/core'
3
+ require 'rspec/core/rake_task'
4
+
5
+ require 'cane/rake_task'
6
+ task :ci => [
7
+ 'cruise_spec',
8
+ 'quality'
9
+ ]
10
+
11
+ desc "Run cane to check quality metrics"
12
+ Cane::RakeTask.new(:quality) do |cane|
13
+ cane.abc_max = 10
14
+ cane.no_doc = true
15
+ end
16
+ desc "Run all specs in spec directory (excluding plugin specs)"
17
+ RSpec::Core::RakeTask.new(:cruise_spec) do |t|
18
+ out = File.join(File.expand_path(File.dirname(__FILE__)), "..","test_reports/Rspec.html")
19
+ t.rspec_opts = ["--format", "html", "-o", out, "--format", "progress"]
20
+ excluded_paths = ['bundle', 'spec', 'config/boot.rb', '/var/', '/usr']
21
+ t.pattern = "spec/**/*_spec.rb"
22
+ end
23
+ rescue LoadError => e
24
+ end
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'rspec/core'
3
+ require 'rspec/core/rake_task'
4
+
5
+ spec_prereq = :noop
6
+ task :noop do
7
+ end
8
+
9
+ desc "Run all specs in spec directory (excluding plugin specs)"
10
+ RSpec::Core::RakeTask.new(:spec => spec_prereq) do |t|
11
+ t.rspec_opts = ["--format", "documentation"]
12
+ t.pattern = "spec/**/*_spec.rb"
13
+ end
14
+
15
+ rescue LoadError => e
16
+ p e
17
+ end
@@ -0,0 +1,3 @@
1
+ module GemSkeleton
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ # require "gem_skeleton/version"
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem_skeleton
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yi Wen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: A command that make a gem skeleton with rspec in place
31
+ email:
32
+ - hayafirst@gmail.com
33
+ executables:
34
+ - gem_skeleton
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - .rvmrc.template
40
+ - Gemfile
41
+ - LICENSE
42
+ - README.md
43
+ - Rakefile
44
+ - bin/gem_skeleton
45
+ - gem_skeleton.gemspec
46
+ - lib/gem_skeleton.rb
47
+ - lib/gem_skeleton/cli.rb
48
+ - lib/gem_skeleton/templates/newgem/Gemfile.tt
49
+ - lib/gem_skeleton/templates/newgem/Guardfile.tt
50
+ - lib/gem_skeleton/templates/newgem/LICENSE.tt
51
+ - lib/gem_skeleton/templates/newgem/README.md.tt
52
+ - lib/gem_skeleton/templates/newgem/Rakefile.tt
53
+ - lib/gem_skeleton/templates/newgem/bin/newgem.tt
54
+ - lib/gem_skeleton/templates/newgem/gitignore.tt
55
+ - lib/gem_skeleton/templates/newgem/lib/newgem.rb.tt
56
+ - lib/gem_skeleton/templates/newgem/lib/newgem/version.rb.tt
57
+ - lib/gem_skeleton/templates/newgem/newgem.gemspec.tt
58
+ - lib/gem_skeleton/templates/newgem/rspec.tt
59
+ - lib/gem_skeleton/templates/newgem/rvmrc.tt
60
+ - lib/gem_skeleton/templates/newgem/spec/spec_helper.rb.tt
61
+ - lib/gem_skeleton/templates/newgem/tasks/ci.rb.tt
62
+ - lib/gem_skeleton/templates/newgem/tasks/rspec.rb.tt
63
+ - lib/gem_skeleton/version.rb
64
+ homepage: https://github.com/ywen/gem_skeleton
65
+ licenses: []
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.21
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: The command copies part of bundle gem code and add rspec and rvmrc support
88
+ into the gem skeleton
89
+ test_files: []