Permalink
Browse files

Initial commits

  • Loading branch information...
0 parents commit dff7991245fd43106fd48b8ecd5da102dede4217 @ywen2 ywen2 committed Apr 11, 2012
18 .gitignore
@@ -0,0 +1,18 @@
+*.gem
+*.rbc
+.bundle
+.config
+.yardoc
+Gemfile.lock
+InstalledFiles
+_yardoc
+coverage
+doc/
+lib/bundler/man
+pkg
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
+.rvmrc
1 .rvmrc.template
@@ -0,0 +1 @@
+rvm 1.9.3@gem_skeleton
4 Gemfile
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+# Specify your gem's dependencies in gem_skeleton.gemspec
+gemspec
22 LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Yi Wen
+
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 README.md
@@ -0,0 +1,29 @@
+# GemSkeleton
+
+TODO: Write a gem description
+
+## Installation
+
+Add this line to your application's Gemfile:
+
+ gem 'gem_skeleton'
+
+And then execute:
+
+ $ bundle
+
+Or install it yourself as:
+
+ $ gem install gem_skeleton
+
+## Usage
+
+TODO: Write usage instructions here
+
+## Contributing
+
+1. Fork it
+2. Create your feature branch (`git checkout -b my-new-feature`)
+3. Commit your changes (`git commit -am 'Added some feature'`)
+4. Push to the branch (`git push origin my-new-feature`)
+5. Create new Pull Request
2 Rakefile
@@ -0,0 +1,2 @@
+#!/usr/bin/env rake
+require "bundler/gem_tasks"
4 bin/gem_skeleton
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+require_relative '../lib/gem_skeleton'
+require_relative '../lib/gem_skeleton/cli'
+GemSkeleton::CLI.start
19 gem_skeleton.gemspec
@@ -0,0 +1,19 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/gem_skeleton/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.authors = ["Yi Wen"]
+ gem.email = ["hayafirst@gmail.com"]
+ gem.description = %q{TODO: Write a gem description}
+ gem.summary = %q{TODO: Write a gem summary}
+ gem.homepage = ""
+
+ gem.files = `git ls-files`.split($\)
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
+ gem.name = "gem_skeleton"
+ gem.require_paths = ["lib"]
+ gem.version = GemSkeleton::VERSION
+ gem.add_runtime_dependency(%q<thor>)
+ gem.add_runtime_dependency(%q<bundler>)
+end
1 lib/gem_skeleton.rb
@@ -0,0 +1 @@
+# require "gem_skeleton/version"
49 lib/gem_skeleton/cli.rb
@@ -0,0 +1,49 @@
+require 'bundler/vendored_thor'
+require 'rubygems/user_interaction'
+require 'rubygems/config_file'
+
+module GemSkeleton
+ class CLI < Thor
+ include Thor::Actions
+ check_unknown_options!
+
+ default_task :make
+
+ desc "make GEM", "Creates a skeleton for creating a rubygem"
+ long_desc <<-D
+ Make a gem skeleton, with rspec goodies, tasks for settingup ci,
+ a Guardfile, a .rvmrc.template, etc.
+ D
+ method_option :bin, :type => :boolean, :default => false, :aliases => '-b', :banner => "Generate a binary for your library."
+ def make(name)
+ name = name.chomp("/") # remove trailing slash if present
+ target = File.join(Dir.pwd, name)
+ constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
+ constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
+ constant_array = constant_name.split('::')
+ FileUtils.mkdir_p(File.join(target, 'lib', name))
+ git_user_name = `git config user.name`.chomp
+ git_user_email = `git config user.email`.chomp
+ opts = {
+ :name => name,
+ :constant_name => constant_name,
+ :constant_array => constant_array,
+ :author => git_user_name.empty? ? "TODO: Write your name" : git_user_name,
+ :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email
+ }
+ template(File.join("newgem/Gemfile.tt"), File.join(target, "Gemfile"), opts)
+ template(File.join("newgem/Rakefile.tt"), File.join(target, "Rakefile"), opts)
+ template(File.join("newgem/LICENSE.tt"), File.join(target, "LICENSE"), opts)
+ template(File.join("newgem/README.md.tt"), File.join(target, "README.md"), opts)
+ template(File.join("newgem/gitignore.tt"), File.join(target, ".gitignore"), opts)
+ template(File.join("newgem/newgem.gemspec.tt"), File.join(target, "#{name}.gemspec"), opts)
+ template(File.join("newgem/lib/newgem.rb.tt"), File.join(target, "lib/#{name}.rb"), opts)
+ template(File.join("newgem/lib/newgem/version.rb.tt"), File.join(target, "lib/#{name}/version.rb"), opts)
+ if options[:bin]
+ template(File.join("newgem/bin/newgem.tt"), File.join(target, 'bin', name), opts)
+ end
+ Bundler.ui.info "Initializating git repo in #{target}"
+ Dir.chdir(target) { `git init`; `git add .` }
+ end
+ end
+end
16 lib/gem_skeleton/templates/newgem/Executable
@@ -0,0 +1,16 @@
+#!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG['ruby_install_name'] %>
+#
+# This file was generated by Bundler.
+#
+# The application '<%= executable %>' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../<%= relative_gemfile_path %>",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('<%= spec.name %>', '<%= executable %>')
12 lib/gem_skeleton/templates/newgem/Executable.standalone
@@ -0,0 +1,12 @@
+#!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG['ruby_install_name'] %>
+#
+# This file was generated by Bundler.
+#
+# The application '<%= executable %>' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+$:.unshift File.expand_path '../<%= standalone_path %>', __FILE__
+
+require 'bundler/setup'
+load File.expand_path '../<%= executable_path %>', __FILE__
4 lib/gem_skeleton/templates/newgem/Gemfile
@@ -0,0 +1,4 @@
+# A sample Gemfile
+source "https://rubygems.org"
+
+# gem "rails"
4 lib/gem_skeleton/templates/newgem/newgem/Gemfile.tt
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+# Specify your gem's dependencies in <%=config[:name]%>.gemspec
+gemspec
22 lib/gem_skeleton/templates/newgem/newgem/LICENSE.tt
@@ -0,0 +1,22 @@
+Copyright (c) <%=Time.now.year%> <%=config[:author]%>
+
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 lib/gem_skeleton/templates/newgem/newgem/README.md.tt
@@ -0,0 +1,29 @@
+# <%=config[:constant_name]%>
+
+TODO: Write a gem description
+
+## Installation
+
+Add this line to your application's Gemfile:
+
+ gem '<%=config[:name]%>'
+
+And then execute:
+
+ $ bundle
+
+Or install it yourself as:
+
+ $ gem install <%=config[:name]%>
+
+## Usage
+
+TODO: Write usage instructions here
+
+## Contributing
+
+1. Fork it
+2. Create your feature branch (`git checkout -b my-new-feature`)
+3. Commit your changes (`git commit -am 'Added some feature'`)
+4. Push to the branch (`git push origin my-new-feature`)
+5. Create new Pull Request
2 lib/gem_skeleton/templates/newgem/newgem/Rakefile.tt
@@ -0,0 +1,2 @@
+#!/usr/bin/env rake
+require "bundler/gem_tasks"
3 lib/gem_skeleton/templates/newgem/newgem/bin/newgem.tt
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+
+require '<%= config[:name] %>'
17 lib/gem_skeleton/templates/newgem/newgem/gitignore.tt
@@ -0,0 +1,17 @@
+*.gem
+*.rbc
+.bundle
+.config
+.yardoc
+Gemfile.lock
+InstalledFiles
+_yardoc
+coverage
+doc/
+lib/bundler/man
+pkg
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
9 lib/gem_skeleton/templates/newgem/newgem/lib/newgem.rb.tt
@@ -0,0 +1,9 @@
+require "<%=config[:name]%>/version"
+
+<%- config[:constant_array].each_with_index do |c,i| -%>
+<%= ' '*i %>module <%= c %>
+<%- end -%>
+<%= ' '*config[:constant_array].size %># Your code goes here...
+<%- (config[:constant_array].size-1).downto(0) do |i| -%>
+<%= ' '*i %>end
+<%- end -%>
7 lib/gem_skeleton/templates/newgem/newgem/lib/newgem/version.rb.tt
@@ -0,0 +1,7 @@
+<%- config[:constant_array].each_with_index do |c,i| -%>
+<%= ' '*i %>module <%= c %>
+<%- end -%>
+<%= ' '*config[:constant_array].size %>VERSION = "0.0.1"
+<%- (config[:constant_array].size-1).downto(0) do |i| -%>
+<%= ' '*i %>end
+<%- end -%>
17 lib/gem_skeleton/templates/newgem/newgem/newgem.gemspec.tt
@@ -0,0 +1,17 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/<%=config[:name]%>/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.authors = [<%=config[:author].inspect%>]
+ gem.email = [<%=config[:email].inspect%>]
+ gem.description = %q{TODO: Write a gem description}
+ gem.summary = %q{TODO: Write a gem summary}
+ gem.homepage = ""
+
+ gem.files = `git ls-files`.split($\)
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
+ gem.name = <%=config[:name].inspect%>
+ gem.require_paths = ["lib"]
+ gem.version = <%=config[:constant_name]%>::VERSION
+end
3 lib/gem_skeleton/version.rb
@@ -0,0 +1,3 @@
+module GemSkeleton
+ VERSION = "0.0.1"
+end

0 comments on commit dff7991

Please sign in to comment.