gemgen 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gemgen.gemspec
4
+ gemspec
5
+
6
+ # This part is taken from the thor gem Gemfile file
7
+ platforms :mri_18 do
8
+ gem 'ruby-debug', '>= 0.10.3'
9
+ end
10
+
11
+ platforms :mri_19 do
12
+ gem 'ruby-debug19'
13
+ end
14
+
15
+ group :development do
16
+ gem 'pry'
17
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Martin Chabot
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,29 @@
1
+ # Gemgen
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'gemgen'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install gemgen
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
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler'
3
+ Bundler.require(:default, :development)
4
+ require 'bundler/gem_tasks'
5
+
6
+ require 'rake/testtask'
7
+
8
+ Rake::TestTask.new do |t|
9
+ t.pattern = "test/*_test.rb"
10
+
11
+ # To avoid requirement of File.expand_path(File.dirname(__FILE__) + 'test_helper') from test files
12
+ t.libs << 'test'
13
+ end
14
+
15
+ task :default => [:test]
16
+
data/bin/gemgen ADDED
@@ -0,0 +1,4 @@
1
+ require 'gemgen'
2
+ require 'gemgen/generator'
3
+
4
+ Gemgen::Generator.start
data/gemgen.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.unshift File.expand_path('../lib', __FILE__)
3
+ require 'gemgen/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.authors = ["Martin Chabot"]
7
+ gem.email = ["chabotm@gmail.com"]
8
+ gem.description = %q{Gem generator that uses bundler gem generator}
9
+ gem.summary = %q{Mostly for personal use}
10
+ gem.homepage = ""
11
+
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "gemgen"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = Gemgen::VERSION
18
+
19
+ gem.add_dependency "thor"
20
+ gem.add_development_dependency 'rake'
21
+ gem.add_development_dependency "bundler", "~> 1.0"
22
+ gem.add_development_dependency 'minitest'
23
+ end
@@ -0,0 +1,101 @@
1
+ require 'thor/group'
2
+
3
+ module Gemgen
4
+ class Generator < Thor::Group
5
+ include Thor::Actions
6
+
7
+ # Define arguments and options
8
+ argument :gem_name
9
+ class_option :test_framework, :default => :mini_test
10
+ class_option :test_type, :default => :unit
11
+
12
+ def self.source_root
13
+ File.expand_path(File.dirname(__FILE__) +'/templates')
14
+ end
15
+
16
+ def run_bundle_gem
17
+ run "bundle gem #{gem_name}", :verbose => true
18
+ commit "$> bundle gem #{gem_name}"
19
+ end
20
+
21
+ def fix_already_initialized_constant_version_warning
22
+ inside gem_name do
23
+ sub_str = "$:.unshift File.expand_path('../lib', __FILE__)\nrequire '#{gem_name}/version'"
24
+ gsub_file "#{gem_name}.gemspec", /^.*version', __FILE__.*$/, sub_str
25
+ end
26
+ commit "Fix already initialized constant VERSION warning"
27
+ end
28
+
29
+ def add_test_dependencies
30
+ inside gem_name do
31
+ insert_into_file "#{gem_name}.gemspec", :after => /gem.version.*\n/ do
32
+ str = <<EOF
33
+ # gem.add_dependency "put dependency here"
34
+ gem.add_development_dependency 'rake'
35
+ gem.add_development_dependency "bundler", "~> 1.0"
36
+ gem.add_development_dependency 'minitest'
37
+ EOF
38
+ end
39
+ end
40
+ bundle
41
+ commit('Add testing gem dependencies')
42
+ end
43
+
44
+ def adding_test_tasks
45
+ remove_file("#{gem_name}/Rakefile")
46
+ template('Rakefile.tt', "#{gem_name}/Rakefile")
47
+ commit "Add test tasks"
48
+ end
49
+
50
+ def create_test_file
51
+ test = options[:test_framework] == "rspec" ? :spec : :test
52
+ test_path = "#{gem_name}/#{test}/"
53
+ helper_file = "#{test}_helper.rb"
54
+ create_file test_path + helper_file do
55
+ str = <<EOF
56
+ $:.unshift File.expand_path('..', __FILE__)
57
+ $:.unshift File.expand_path('../../lib', __FILE__)
58
+ require 'minitest/unit'
59
+ require 'minitest/autorun'
60
+ EOF
61
+ end
62
+ create_file test_path + "#{gem_name}_#{test}.rb" do
63
+ str = <<EOF
64
+ require '#{File.basename(helper_file, ".rb")}'
65
+ class #{module_name}Test < MiniTest::Unit::TestCase
66
+ def test_truth
67
+ assert true
68
+ end
69
+ end
70
+ EOF
71
+ end
72
+ commit("Create test scaffold file")
73
+ end
74
+
75
+ def debug_gem_to_Gemfile
76
+ remove_file("#{gem_name}/Gemfile")
77
+ template('Gemfile.tt', "#{gem_name}/Gemfile")
78
+ bundle
79
+ commit "Add debug gem to Gemfile"
80
+ end
81
+
82
+ private
83
+
84
+ def commit(msg)
85
+ inside gem_name do
86
+ run "git add ."
87
+ run "git commit -m '#{msg}'"
88
+ end
89
+ end
90
+
91
+ def bundle
92
+ inside gem_name do
93
+ run "bundle install"
94
+ end
95
+ end
96
+
97
+ def module_name
98
+ Thor::Util.camel_case(gem_name)
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in <%= gem_name %>.gemspec
4
+ gemspec
5
+
6
+ # This part is taken from the thor gem Gemfile file
7
+ platforms :mri_18 do
8
+ gem 'ruby-debug', '>= 0.10.3'
9
+ end
10
+
11
+ platforms :mri_19 do
12
+ gem 'ruby-debug19'
13
+ end
14
+
15
+ group :development do
16
+ gem 'pry'
17
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler'
3
+ Bundler.require(:default, :development)
4
+ require 'bundler/gem_tasks'
5
+
6
+ require 'rake/testtask'
7
+
8
+ Rake::TestTask.new do |t|
9
+ t.pattern = "test/*_test.rb"
10
+ # To avoid requirement of File.expand_path(File.dirname(__FILE__) + 'test_helper') from test files
11
+ t.libs << 'test'
12
+ end
13
+
14
+ task :default => [:test]
15
+
@@ -0,0 +1,3 @@
1
+ module Gemgen
2
+ VERSION = "0.0.1"
3
+ end
data/lib/gemgen.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "gemgen/version"
2
+
3
+ module Gemgen
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,6 @@
1
+ require 'test_helper'
2
+ class GemgenTest < MiniTest::Unit::TestCase
3
+ def test_truth
4
+ assert true
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'minitest/unit'
4
+ require 'minitest/autorun'
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gemgen
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Martin Chabot
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-08-27 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ requirement: *id001
32
+ name: thor
33
+ type: :runtime
34
+ - !ruby/object:Gem::Dependency
35
+ prerelease: false
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ requirement: *id002
46
+ name: rake
47
+ type: :development
48
+ - !ruby/object:Gem::Dependency
49
+ prerelease: false
50
+ version_requirements: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ hash: 15
56
+ segments:
57
+ - 1
58
+ - 0
59
+ version: "1.0"
60
+ requirement: *id003
61
+ name: bundler
62
+ type: :development
63
+ - !ruby/object:Gem::Dependency
64
+ prerelease: false
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ requirement: *id004
75
+ name: minitest
76
+ type: :development
77
+ description: Gem generator that uses bundler gem generator
78
+ email:
79
+ - chabotm@gmail.com
80
+ executables:
81
+ - gemgen
82
+ extensions: []
83
+
84
+ extra_rdoc_files: []
85
+
86
+ files:
87
+ - .gitignore
88
+ - Gemfile
89
+ - LICENSE
90
+ - README.md
91
+ - Rakefile
92
+ - bin/gemgen
93
+ - gemgen.gemspec
94
+ - lib/gemgen.rb
95
+ - lib/gemgen/generator.rb
96
+ - lib/gemgen/templates/Gemfile.tt
97
+ - lib/gemgen/templates/Rakefile.tt
98
+ - lib/gemgen/version.rb
99
+ - test/gemgen_test.rb
100
+ - test/test_helper.rb
101
+ homepage: ""
102
+ licenses: []
103
+
104
+ post_install_message:
105
+ rdoc_options: []
106
+
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ hash: 3
124
+ segments:
125
+ - 0
126
+ version: "0"
127
+ requirements: []
128
+
129
+ rubyforge_project:
130
+ rubygems_version: 1.8.11
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: Mostly for personal use
134
+ test_files:
135
+ - test/gemgen_test.rb
136
+ - test/test_helper.rb