simple_gem 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,8 @@
1
+ = Simple Gem
2
+
3
+ == Version 0.0.0
4
+ * Supports "gem skeleton" command to create a new gem
5
+ * Supports "rake build" to build a new permanent versioned gemfile
6
+ * Supports "rake build_dev" to build a temporary dev version of a gem
7
+ * Supports "rake tag" to tag the current git repo with the current version number
8
+
data/LICENSE.txt ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2012 RevPAR Collective, Inc.
2
+
3
+ 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:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ 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.
data/README.rdoc ADDED
@@ -0,0 +1,42 @@
1
+ = Simple Gem
2
+
3
+ Contains tools, libraries, and rake tasks for creating gems.
4
+
5
+ Attempts to be as lightweight and non-intrusive as possible, minimizing code-gen
6
+
7
+ == Creating a new gem
8
+
9
+ === Synopsis:
10
+
11
+ gem skeleton my_gem
12
+
13
+ Note the output of the command - it will tell you to update the gemspec among a couple other things to get you started.
14
+
15
+ The new gem may be built and tested out of the box.
16
+
17
+ == Building a gem
18
+
19
+ There are two rake tasks--build and build_dev--that let you create either a new permenant versioned build of the gem or a temporary development build.
20
+
21
+ === rake build
22
+
23
+ To build a new permanent version, first update the lib/gem_name/version.rb file appropriately (major, minor, or build version) and/or CHANGELOG if there is one, then commit it and tag it with the new version number (you can do this with "rake tag"). Build the gem using "rake build" which will create a gem file in the gems/ directory. Then simply deploy it to the desired repository (ie. "gem push gems/my_gem-version.gem", or "gem inabox gems/my_gem-version.gem") and install it locally.
24
+
25
+ Here's a quick synopsis:
26
+
27
+ vim lib/gem_name/version.rb # update version number appropriately
28
+ vim CHANGELOG # add change info
29
+ git add .
30
+ git commit
31
+ rake tag
32
+ git push origin master
33
+ git push --tags origin
34
+ rake build
35
+ gem push gems/gem_name-0.0.0.gem # alternatively, "gem inabox gems/gem_name-0.0.0.gem"
36
+ gem install gem_name
37
+
38
+ Note that once you build and deploy a gem, you shouldn't try to undo it - that should be a released version forever. If you need to fix an error, patch it, increment its build version, and deploy it using these same steps.
39
+
40
+ === rake build_dev
41
+
42
+ At any time, you can run rake build_dev, which will add a patch version to the current version number and build a gem file into the gems_dev folder. Install it with "gem install gems_dev/my_gem-version.gem," and then you can use it in other projects to try it out before permanently versioning it.
@@ -0,0 +1,90 @@
1
+ require 'date'
2
+ require 'erb'
3
+ require 'rubygems/command'
4
+ require 'active_support/inflector'
5
+
6
+ class Gem::Commands::SkeletonCommand < Gem::Command
7
+
8
+ def initialize
9
+ super 'skeleton', 'Create the skeleton for a new gem'
10
+ end
11
+
12
+ def arguments
13
+ 'GEMNAME name of gem to create a skeleton for'
14
+ end
15
+
16
+ def usage
17
+ "#{program_name} GEMNAME"
18
+ end
19
+
20
+ def execute
21
+ gem_name = get_all_gem_names[0]
22
+ camelized_gem_name = gem_name.camelize
23
+
24
+ # make directory for gem
25
+ if File.exists?(gem_name)
26
+ raise "#{gem_name} directory already exists"
27
+ else
28
+ Dir.mkdir gem_name
29
+ end
30
+
31
+ safe_create_dir(File.join(gem_name, 'lib'))
32
+ safe_create_dir(File.join(gem_name, 'lib', gem_name))
33
+ safe_create_dir(File.join(gem_name, 'spec'))
34
+
35
+ renderer = TemplateRenderer.new(gem_name)
36
+ renderer.render('gitignore', '.gitignore')
37
+ renderer.render('Gemfile', 'Gemfile')
38
+ renderer.render('README.rdoc', 'README.rdoc')
39
+ renderer.render('CHANGELOG.rdoc', 'CHANGELOG.rdoc')
40
+ renderer.render('LICENSE.txt', 'LICENSE.txt')
41
+ renderer.render('Rakefile', 'Rakefile')
42
+ renderer.render('lib_base.rb', File.join('lib', "#{gem_name}.rb"))
43
+ renderer.render('version.rb', File.join('lib', gem_name, 'version.rb'))
44
+ renderer.render('spec_helper.rb', File.join('spec', 'spec_helper.rb'))
45
+ renderer.render('gemspec', "#{gem_name}.gemspec")
46
+
47
+ puts renderer.render('POST_INSTALL_MESSAGE')
48
+
49
+ end
50
+
51
+ private
52
+
53
+ def safe_create_dir(dir_name)
54
+ if File.exists?(dir_name)
55
+ raise "#{dir_name} is not a directory" unless File.directory?(dir_name)
56
+ else
57
+ Dir.mkdir dir_name
58
+ end
59
+ end
60
+
61
+ class TemplateRenderer
62
+
63
+ attr_reader :gem_name
64
+
65
+ def initialize(gem_name)
66
+ @gem_name = gem_name
67
+ @templates_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'templates'))
68
+ end
69
+
70
+ def get_binding
71
+ binding
72
+ end
73
+
74
+ def render(template, target_file = nil)
75
+ source_text = File.read("#{File.join(@templates_dir, template)}")
76
+ source_object = ERB.new(source_text)
77
+ result = source_object.result(get_binding)
78
+
79
+ if target_file
80
+ File.open(File.join(gem_name, target_file), 'w') do |f|
81
+ f.write(result)
82
+ end
83
+ else
84
+ result
85
+ end
86
+ end
87
+
88
+ end
89
+
90
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems/command_manager'
2
+
3
+ Gem::CommandManager.instance.register_command :skeleton
@@ -0,0 +1,4 @@
1
+ module SimpleGem
2
+ VERSION = '0.0.0'
3
+ end
4
+
@@ -0,0 +1,87 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ module SimpleGem
4
+ class << self
5
+
6
+ attr_writer :current_version, :current_gemspec
7
+
8
+ def current_version
9
+ if !@current_version
10
+ raise 'must define SimpleGem.current_version'
11
+ end
12
+ @current_version
13
+ end
14
+
15
+ def current_gemspec
16
+ if !@current_gemspec
17
+ raise 'must define SimpleGem.current_gemspec'
18
+ end
19
+ @current_gemspec
20
+ end
21
+
22
+ def safe_create_dir(dir_name)
23
+ if File.exists?(dir_name)
24
+ raise "#{dir_name} is not a directory" unless File.directory?(dir_name)
25
+ else
26
+ Dir.mkdir dir_name
27
+ puts "* created directory #{dir_name}"
28
+ end
29
+ end
30
+
31
+ def build_gem(target_dir)
32
+ print "Do you want to build version #{current_version} (Y/n): "
33
+ input = STDIN.gets.strip
34
+
35
+ if input.to_s[0,1] == 'Y'
36
+ safe_create_dir(target_dir)
37
+ spec = Gem::Specification.load(current_gemspec)
38
+ spec.version = current_version
39
+ builder = Gem::Builder.new(spec)
40
+ gem_file = builder.build
41
+ target_file = "#{target_dir}/#{gem_file}"
42
+ File.rename gem_file, target_file
43
+ puts "Successfully built #{gem_file} into #{target_dir}"
44
+ [ current_version, target_file ]
45
+ else
46
+ raise %q{Aborting... update version file and run "rake build" again.}
47
+ end
48
+ end
49
+
50
+ def build_production_gem
51
+ if !`git status -s`.empty?
52
+ raise 'There are uncommitted changes in the tree - commit before building'
53
+ end
54
+
55
+ build_gem 'gems'
56
+ end
57
+
58
+ def tag(version)
59
+ version ||= current_version
60
+ `git tag #{version}`
61
+ end
62
+
63
+ end
64
+ end
65
+
66
+ task :default => [ :spec ]
67
+
68
+ RSpec::Core::RakeTask.new(:spec)
69
+
70
+ desc 'Builds a gemfile for production (into gems/)'
71
+ task :build do
72
+ SimpleGem.build_production_gem
73
+ end
74
+
75
+ desc 'Builds a gemfile for development (into gems_dev/)'
76
+ task :build_dev do
77
+ current_version = SimpleGem.current_version
78
+ SimpleGem.current_version = "#{current_version}.#{Time.now.to_i}"
79
+ SimpleGem.build_gem 'gems_dev'
80
+ SimpleGem.current_version = current_version
81
+ end
82
+
83
+ desc 'Creates a git tag with the given version'
84
+ task :tag, :version do |t, args|
85
+ SimpleGem.tag(args[:version])
86
+ end
87
+
@@ -0,0 +1,4 @@
1
+ = <%= @gem_name.titleize %>
2
+
3
+ == Version 0.0.0
4
+ * Change information here
data/templates/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'http://rubygems.org'
2
+
3
+ group :rake do
4
+ gem 'simple_gem', :require => 'tasks/simple_gem'
5
+ end
6
+
7
+ group :test do
8
+ gem 'rspec', '~> 2.8'
9
+ end
10
+
@@ -0,0 +1,7 @@
1
+ Copyright (c) <%= Date.today.year %> <%= `git config user.name` %>
2
+
3
+ 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:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ 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.
@@ -0,0 +1,15 @@
1
+ A barebones gem has been created in the <%= @gem_name %> directory.
2
+
3
+ You should now:
4
+ * Open up README.rdoc and put in a basic description of your gem
5
+ * Open up <%= @gem_name %>.gemspec and fill in the summary, description,
6
+ authors, and email fields, and add any dependencies
7
+ * Init a git repo (git init), add and commit everything
8
+ * Create a github repo for the gem and push to it
9
+
10
+ The lib/<%= @gem_name %>.rb file has a note to get you started on
11
+ implementation, and the spec/ folder is ready for tests. They can be run by
12
+ simply executing "rake".
13
+
14
+ See the README for simple_gem on github for a brief overview of how to
15
+ version, build, and deploy your gem.
@@ -0,0 +1,7 @@
1
+ = <%= @gem_name.titleize %>
2
+
3
+ Put a description of the gem here.
4
+
5
+ == Synopsis:
6
+
7
+ foo = <%= @gem_name.camelize %>.new
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler.require(:rake)
3
+
4
+ # Configure gem building
5
+ require File.expand_path(File.join(File.dirname(__FILE__), 'lib', '<%= @gem_name %>', 'version'))
6
+ SimpleGem.current_version = <%= @gem_name.camelize %>::VERSION
7
+ SimpleGem.current_gemspec = '<%= @gem_name %>.gemspec'
8
+
data/templates/gemspec ADDED
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'lib', '<%= @gem_name %>', 'version'))
2
+
3
+ Gem::Specification.new do |s|
4
+
5
+ # definition
6
+ s.name = %q{<%= @gem_name %>}
7
+ s.version = <%= @gem_name.camelize %>::VERSION
8
+
9
+ # details
10
+ s.date = %q{<%= Date.today %>}
11
+ s.summary = %q{Summary of gem here.}
12
+ s.description = %q{Description of gem here.}
13
+ s.authors = [ '<%= `git config user.name` %>' ]
14
+ s.email = %q{<%= `git config user.email` %>}
15
+ s.homepage = %q{https://github.com/<%= `git config github.user` %>/<%= @gem_name %>}
16
+ s.require_paths = [ 'lib' ]
17
+
18
+ # documentation
19
+ s.has_rdoc = true
20
+ s.extra_rdoc_files = %w( README.rdoc CHANGELOG.rdoc LICENSE.txt )
21
+ s.rdoc_options = %w( --main README.rdoc )
22
+
23
+ # files to include
24
+ s.files = Dir[ 'lib/**/*.rb', 'README.rdoc', 'CHANGELOG.rdoc', 'LICENSE.txt' ]
25
+
26
+ # dependencies
27
+ # s.add_dependency 'activemodel', '~> 3.0'
28
+
29
+ # if binaries
30
+ # s.bindir = 'bin'
31
+ # s.executables = [ 'executable' ]
32
+
33
+ end
@@ -0,0 +1,3 @@
1
+ /gems
2
+ /gems_dev
3
+ .*.swp
@@ -0,0 +1,9 @@
1
+ # This file should require or autoload the implementation of this gem
2
+ #
3
+ # Example:
4
+ #
5
+ # require 'my_gem/my_extension'
6
+ #
7
+ # module MyGem
8
+ # autoload :MyClass, 'my_gem/my_class'
9
+ # end
@@ -0,0 +1,5 @@
1
+ require 'bundler'
2
+ Bundler.require(:default, :test)
3
+
4
+ require '<%= @gem_name %>'
5
+
@@ -0,0 +1,3 @@
1
+ module <%= @gem_name.camelize %>
2
+ VERSION = '0.0.0'
3
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Dawson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-08 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: &70112078226820 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70112078226820
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70112078226320 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.8.7
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70112078226320
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70112078276800 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.8'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70112078276800
47
+ description: Contains tools that create gem skeletons, rake tasks that support building
48
+ and deploying gems, and more.
49
+ email: daws23@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files:
53
+ - README.rdoc
54
+ - CHANGELOG.rdoc
55
+ - LICENSE.txt
56
+ files:
57
+ - lib/rubygems/commands/skeleton_command.rb
58
+ - lib/rubygems_plugin.rb
59
+ - lib/simple_gem/version.rb
60
+ - lib/tasks/simple_gem.rb
61
+ - templates/CHANGELOG.rdoc
62
+ - templates/Gemfile
63
+ - templates/gemspec
64
+ - templates/gitignore
65
+ - templates/lib_base.rb
66
+ - templates/LICENSE.txt
67
+ - templates/POST_INSTALL_MESSAGE
68
+ - templates/Rakefile
69
+ - templates/README.rdoc
70
+ - templates/spec_helper.rb
71
+ - templates/version.rb
72
+ - README.rdoc
73
+ - CHANGELOG.rdoc
74
+ - LICENSE.txt
75
+ homepage: https://github.com/daws/simple_gem
76
+ licenses: []
77
+ post_install_message:
78
+ rdoc_options:
79
+ - --main
80
+ - README.rdoc
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 1.8.10
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Support tools, libraries, and rake tasks for creating gems.
101
+ test_files: []