kelredd-simple-gem 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,54 @@
1
+ = SimpleGem
2
+
3
+ == Description
4
+
5
+ SimpleGem is a gem to help quickly generate a ruby gem project ready to build, test, and deploy.
6
+
7
+ == Installation
8
+
9
+ sudo gem install kelredd-simple-gem --source=http://gems.github.com
10
+
11
+ == Usage
12
+
13
+ $ simple-gem my-gem
14
+
15
+ This will create a gem structure under the './my-gem'. The command is pretty forgiving with the name you supply, it will automatically transform anything that is camelcased into something more ruby-like. If you have an existing gem structure, it will just add/overwrite where necessary and not remove anything.
16
+
17
+ After generating your gem, go ahead and add information about your gem to both the <tt>Rakefile</tt> and <tt>README.rdoc</tt> files. The default version number is "0.1.0", but if you want to change that, take a look at <tt>lib/my_gem/version.rb</tt> to make the change - this will automatically be picked up when you rebuild your gem.
18
+
19
+ Your new gem provides some Rake tasks for convenience:
20
+
21
+ * <tt>rake gem</tt> - Build the gem and drop it into the <tt>pkg/</tt> directory for installation.
22
+ * <tt>rake test</tt> - The default test task, it will run the tests in <tt>test</tt>. If this is a newly-created gem, your tests will flunk.
23
+ * <tt>rake features</tt> - a rake task to run any cucumber features you have defined.
24
+ * <tt>rake gemspec</tt> - Generate <tt>my_gem.gemspec</tt> file to use if you're serving your gem (via Github or your own server).
25
+
26
+ That's it. Enjoy.
27
+
28
+ == Credit
29
+ Many thanks to Patrick Reagan (mailto:reaganpr@gmail.com) who is the original author of this gem. The source and credit is largely his. I simply forked his source on Github and extended it for my purposes. The original source can be found here: http://github.com/reagent/simple-gem/tree/master.
30
+
31
+ == License
32
+
33
+ Copyright (c) 2008-2009 Kelly Redding (mailto: kelly@kelredd.com) and Patrick Reagan (mailto:reaganpr@gmail.com)
34
+
35
+ Permission is hereby granted, free of charge, to any person
36
+ obtaining a copy of this software and associated documentation
37
+ files (the "Software"), to deal in the Software without
38
+ restriction, including without limitation the rights to use,
39
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
40
+ copies of the Software, and to permit persons to whom the
41
+ Software is furnished to do so, subject to the following
42
+ conditions:
43
+
44
+ The above copyright notice and this permission notice shall be
45
+ included in all copies or substantial portions of the Software.
46
+
47
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
48
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
49
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
50
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
51
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
52
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
53
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
54
+ OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rake/testtask'
4
+
5
+ require 'lib/simple_gem/version'
6
+
7
+ task :default => :test
8
+
9
+ spec = Gem::Specification.new do |s|
10
+ s.name = 'simple-gem'
11
+ s.version = SimpleGem::Version.to_s
12
+ s.has_rdoc = true
13
+ s.extra_rdoc_files = %w(README.rdoc)
14
+ s.rdoc_options = %w(--main README.rdoc)
15
+ s.summary = "A gem to help quickly generate a ruby gem project ready to build, test, and deploy."
16
+ s.author = 'Kelly Redding (and Patrick Reagan)'
17
+ s.email = 'kelly@kelredd.com'
18
+ s.homepage = 'http://github.com/kelredd/simple-gem'
19
+ s.executables = ['simple-gem']
20
+ s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib,templates}/**/*")
21
+ end
22
+
23
+ Rake::GemPackageTask.new(spec) do |pkg|
24
+ pkg.gem_spec = spec
25
+ end
26
+
27
+ Rake::TestTask.new do |t|
28
+ t.libs << 'test'
29
+ t.test_files = FileList["test/**/*_test.rb"]
30
+ t.verbose = true
31
+ end
32
+
33
+ desc 'Generate the gemspec to serve this Gem from Github'
34
+ task :gemspec do
35
+ file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
36
+ File.open(file, 'w') {|f| f << spec.to_ruby }
37
+ puts "Created gemspec: #{file}"
38
+ end
data/bin/simple-gem ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'simple_gem/gem'
4
+
5
+ if ARGV[0]
6
+ gem = SimpleGem::Gem.new(`pwd`.strip, ARGV[0])
7
+ gem.generate
8
+ else
9
+ puts "Please specify a name for your gem"
10
+ end
data/lib/simple_gem.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'simple_gem/version'
2
+ require 'simple_gem/gem'
@@ -0,0 +1,64 @@
1
+ require 'erb'
2
+
3
+ module SimpleGem
4
+ class Gem
5
+
6
+ attr_reader :root_path, :name
7
+
8
+ def initialize(path, name)
9
+ @root_path = path
10
+ self.name = name
11
+ end
12
+
13
+ def name=(name)
14
+ @name = name.gsub(/([A-Z])([a-z])/, '_\1\2').sub(/^_/, '').downcase
15
+ end
16
+
17
+ def module_name
18
+ transform_name {|part| part.capitalize }
19
+ end
20
+
21
+ def ruby_name
22
+ transform_name('_') {|part| part.downcase }
23
+ end
24
+
25
+ def generate
26
+ generate_root_directory
27
+ generate_subdirectories
28
+ generate_file('gitignore.erb', '.gitignore')
29
+ generate_file('lib.rb.erb', "lib/#{self.ruby_name}.rb")
30
+ generate_file('lib_version.rb.erb', "lib/#{self.ruby_name}/version.rb")
31
+ generate_file('Rakefile.erb', 'Rakefile')
32
+ generate_file('README.rdoc.erb', 'README.rdoc')
33
+ generate_file('test_helper.rb.erb', 'test/test_helper.rb')
34
+ generate_file('test.rb.erb', "test/unit/#{self.ruby_name}_test.rb")
35
+ generate_file('feature.feature.erb', "test/features/#{self.ruby_name}.feature")
36
+ generate_file('feature_steps.rb.erb', "test/features/step_definitions/#{self.ruby_name}_steps.rb")
37
+ generate_file('feature_env.rb.erb', "test/features/step_definitions/support/env.rb")
38
+ end
39
+
40
+ private
41
+ def transform_name(glue = nil, &block)
42
+ self.name.split(/[_-]/).map {|part| block.call(part) }.join(glue)
43
+ end
44
+
45
+ def generate_root_directory
46
+ FileUtils.mkdir_p("#{self.root_path}/#{self.name}")
47
+ end
48
+
49
+ def generate_subdirectories
50
+ ["lib/#{self.ruby_name}", 'test/unit', 'test/features/step_definitions/support'].each do |dir|
51
+ FileUtils.mkdir_p("#{self.root_path}/#{self.name}/#{dir}")
52
+ end
53
+ end
54
+
55
+ def generate_file(source, output)
56
+ source_file = File.dirname(__FILE__) + "/../../templates/#{source}"
57
+ output_file = "#{self.root_path}/#{self.name}/#{output}"
58
+
59
+ erb = ERB.new(File.read(source_file))
60
+ File.open(output_file, 'w') {|f| f << erb.result(binding) }
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,13 @@
1
+ module SimpleGem
2
+ module Version
3
+
4
+ MAJOR = 0
5
+ MINOR = 5
6
+ TINY = 0
7
+
8
+ def self.to_s
9
+ [MAJOR, MINOR, TINY].join('.')
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,38 @@
1
+ = <%= self.module_name %>
2
+
3
+ == Description
4
+
5
+ Describe your gem here ...
6
+
7
+ == Installation
8
+
9
+ sudo gem install <%= self.name %>
10
+
11
+ == Usage
12
+
13
+ require '<%= self.ruby_name %>'
14
+
15
+ == License
16
+
17
+ Copyright (c) <year> <copyright holders>
18
+
19
+ Permission is hereby granted, free of charge, to any person
20
+ obtaining a copy of this software and associated documentation
21
+ files (the "Software"), to deal in the Software without
22
+ restriction, including without limitation the rights to use,
23
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
24
+ copies of the Software, and to permit persons to whom the
25
+ Software is furnished to do so, subject to the following
26
+ conditions:
27
+
28
+ The above copyright notice and this permission notice shall be
29
+ included in all copies or substantial portions of the Software.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
33
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
35
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
36
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
37
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
38
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,63 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rake/testtask'
4
+
5
+ require 'lib/<%= self.ruby_name %>/version'
6
+
7
+ spec = Gem::Specification.new do |s|
8
+ s.name = '<%= self.name %>'
9
+ s.version = <%= self.module_name %>::Version.to_s
10
+ s.has_rdoc = true
11
+ s.extra_rdoc_files = %w(README.rdoc)
12
+ s.rdoc_options = %w(--main README.rdoc)
13
+ s.summary = "This gem does ... "
14
+ s.author = 'First Last'
15
+ s.email = 'user@example.com'
16
+ s.homepage = 'http://my-site.net'
17
+ s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib}/**/*")
18
+ # s.executables = ['<%= self.name %>']
19
+
20
+ # s.add_dependency('gem_name', '~> 0.0.1')
21
+ end
22
+
23
+ Rake::GemPackageTask.new(spec) do |pkg|
24
+ pkg.gem_spec = spec
25
+ end
26
+
27
+ Rake::TestTask.new do |t|
28
+ t.libs << 'test'
29
+ t.test_files = FileList["test/**/*_test.rb"]
30
+ t.verbose = true
31
+ end
32
+
33
+ begin
34
+ require 'rcov/rcovtask'
35
+
36
+ Rcov::RcovTask.new(:coverage) do |t|
37
+ t.libs = ['test']
38
+ t.test_files = FileList["test/**/*_test.rb"]
39
+ t.verbose = true
40
+ t.rcov_opts = ['--text-report', "-x #{Gem.path}", '-x /Library/Ruby', '-x /usr/lib/ruby']
41
+ end
42
+
43
+ task :default => :coverage
44
+
45
+ rescue LoadError
46
+ warn "\n**** Install rcov (sudo gem install relevance-rcov) to get coverage stats ****\n"
47
+ task :default => :test
48
+ end
49
+
50
+
51
+ desc 'Generate the gemspec to serve this Gem from Github'
52
+ task :gemspec do
53
+ file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
54
+ File.open(file, 'w') {|f| f << spec.to_ruby }
55
+ puts "Created gemspec: #{file}"
56
+ end
57
+
58
+ require 'cucumber'
59
+ require 'cucumber/rake/task'
60
+
61
+ Cucumber::Rake::Task.new(:features) do |t|
62
+ t.cucumber_opts = "test/features --format pretty"
63
+ end
@@ -0,0 +1,4 @@
1
+ Feature: <%= self.module_name %>
2
+ In order to test this gem
3
+ As a requirer of this gem
4
+ I want to ensure this gem behaves as expected
@@ -0,0 +1,6 @@
1
+ require 'test/unit/assertions'
2
+ World(Test::Unit::Assertions)
3
+
4
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', '<%= self.ruby_name %>.rb'))
5
+
6
+ # TODO: setup your feature environment here
@@ -0,0 +1 @@
1
+ # TODO: define any pending feature steps here
@@ -0,0 +1,4 @@
1
+ /pkg/
2
+ /doc/
3
+ /coverage/
4
+ *.log
@@ -0,0 +1,3 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ # require '<%= self.ruby_name %>/...'
@@ -0,0 +1,13 @@
1
+ module <%= self.module_name %>
2
+ module Version
3
+
4
+ MAJOR = 0
5
+ MINOR = 1
6
+ TINY = 0
7
+
8
+ def self.to_s # :nodoc:
9
+ [MAJOR, MINOR, TINY].join('.')
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class <%= self.module_name %>Test < Test::Unit::TestCase
4
+
5
+ describe "An instance of the <%= self.module_name %> class" do
6
+
7
+ it "should flunk" do
8
+ flunk "Please provide some tests"
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,6 @@
1
+ # http://sneaq.net/textmate-wtf
2
+ $:.reject! { |e| e.include? 'TextMate' }
3
+
4
+ require 'rubygems'
5
+
6
+ require File.dirname(__FILE__) + '/../lib/<%= self.ruby_name %>'
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kelredd-simple-gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Kelly Redding (and Patrick Reagan)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-28 00:00:00 -07:00
13
+ default_executable: simple-gem
14
+ dependencies: []
15
+
16
+ description:
17
+ email: kelly@kelredd.com
18
+ executables:
19
+ - simple-gem
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - README.rdoc
26
+ - Rakefile
27
+ - lib/simple_gem
28
+ - lib/simple_gem/gem.rb
29
+ - lib/simple_gem/version.rb
30
+ - lib/simple_gem.rb
31
+ - templates/feature.feature.erb
32
+ - templates/feature_env.rb.erb
33
+ - templates/feature_steps.rb.erb
34
+ - templates/gitignore.erb
35
+ - templates/lib.rb.erb
36
+ - templates/lib_version.rb.erb
37
+ - templates/Rakefile.erb
38
+ - templates/README.rdoc.erb
39
+ - templates/test.rb.erb
40
+ - templates/test_helper.rb.erb
41
+ - bin/simple-gem
42
+ has_rdoc: true
43
+ homepage: http://github.com/kelredd/simple-gem
44
+ licenses:
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --main
48
+ - README.rdoc
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.5
67
+ signing_key:
68
+ specification_version: 2
69
+ summary: A gem to help quickly generate a ruby gem project ready to build, test, and deploy.
70
+ test_files: []
71
+