gemit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +10 -0
- data/bin/gemit +13 -0
- data/gemit.gemspec +24 -0
- data/lib/gemit.rb +117 -0
- data/lib/gemit/string_ext.rb +5 -0
- data/lib/gemit/version.rb +3 -0
- metadata +79 -0
data/.gitignore
ADDED
data/README.md
ADDED
data/bin/gemit
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
require 'gemit'
|
5
|
+
|
6
|
+
if ARGV.length != 1
|
7
|
+
puts "Usage: #{File.basename(__FILE__)} [gem name] (verbose)"
|
8
|
+
Process.exit
|
9
|
+
end
|
10
|
+
|
11
|
+
gemit = Gemit.new(ARGV[0])
|
12
|
+
gemit.generate
|
13
|
+
|
data/gemit.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
|
4
|
+
require "gemit/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "gemit"
|
8
|
+
s.version = Gemit::VERSION
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = `git config --get user.name`
|
11
|
+
s.email = `git config --get user.email`
|
12
|
+
s.homepage = %q{http://github.com/kitofr/gemit}
|
13
|
+
|
14
|
+
s.summary = %q{A simple gem scaffolder}
|
15
|
+
s.description = %q{Scaffolds some things I most of the time want when creating a gem}
|
16
|
+
|
17
|
+
s.rubyforge_project = "gemit"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
s.required_ruby_version = '>= 1.8.7'
|
24
|
+
end
|
data/lib/gemit.rb
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'gemit/string_ext'
|
3
|
+
|
4
|
+
class Gemit
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
@verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate
|
13
|
+
raise "Name cannot contain white spaces!" if @name =~ /\s/
|
14
|
+
raise "Folder already exists #{@name}" if File.exists? @name
|
15
|
+
|
16
|
+
FileUtils.mkdir_p(File.join(@name, "bin"), :verbose => @verbose)
|
17
|
+
FileUtils.mkdir_p(File.join(@name, "lib"), :verbose => @verbose)
|
18
|
+
FileUtils.mkdir_p(File.join(@name, "lib", @name), :verbose => @verbose)
|
19
|
+
|
20
|
+
create_file(gemspec_file, gemspec)
|
21
|
+
create_file(readme_file, readme)
|
22
|
+
create_file(version_file, version)
|
23
|
+
create_file(lib_file, lib)
|
24
|
+
create_file(executable_file, executable)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def create_file(name, content)
|
30
|
+
file_name = File.join(@name, name)
|
31
|
+
File.open(file_name, 'w') {|f| f.write(content) }
|
32
|
+
puts "created #{file_name}" if @verbose
|
33
|
+
end
|
34
|
+
|
35
|
+
def gemspec_file
|
36
|
+
"#{@name}.gemspec"
|
37
|
+
end
|
38
|
+
|
39
|
+
def readme_file
|
40
|
+
"README.md"
|
41
|
+
end
|
42
|
+
|
43
|
+
def version_file
|
44
|
+
File.join("lib", @name, "version.rb").to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def lib_file
|
48
|
+
File.join("lib", "#{@name}.rb")
|
49
|
+
end
|
50
|
+
|
51
|
+
def executable_file
|
52
|
+
File.join("bin", "#{@name}")
|
53
|
+
end
|
54
|
+
|
55
|
+
def gemspec
|
56
|
+
<<GEMSPEC
|
57
|
+
# encoding: utf-8
|
58
|
+
|
59
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
|
60
|
+
require "#{@name}/version"
|
61
|
+
|
62
|
+
Gem::Specification.new do |s|
|
63
|
+
s.name = "#{@name}"
|
64
|
+
s.version = #{@name.classify}::VERSION
|
65
|
+
s.platform = Gem::Platform::RUBY
|
66
|
+
s.authors = `git config --get user.name`
|
67
|
+
s.email = `git config --get user.email`
|
68
|
+
s.homepage = %q{}
|
69
|
+
|
70
|
+
s.summary = %q{}
|
71
|
+
s.description = %q{}
|
72
|
+
|
73
|
+
s.rubyforge_project = "#{@name}"
|
74
|
+
|
75
|
+
s.files = `git ls-files`.split("\\n")
|
76
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\\n")
|
77
|
+
s.executables = `git ls-files -- bin/*`.split("\\n").map{ |f| File.basename(f) }
|
78
|
+
s.require_paths = ["lib"]
|
79
|
+
s.required_ruby_version = '>= 1.8.7'
|
80
|
+
end
|
81
|
+
GEMSPEC
|
82
|
+
end
|
83
|
+
|
84
|
+
def readme
|
85
|
+
<<README
|
86
|
+
#{@name.classify}
|
87
|
+
#{@name.classify.length.times.collect{'='}}
|
88
|
+
|
89
|
+
Intallation
|
90
|
+
-----------
|
91
|
+
* gem install #{@name}
|
92
|
+
README
|
93
|
+
end
|
94
|
+
def version
|
95
|
+
<<VERSION
|
96
|
+
class #{@name.classify}
|
97
|
+
VERSION = "0.0.1"
|
98
|
+
end
|
99
|
+
VERSION
|
100
|
+
end
|
101
|
+
def lib
|
102
|
+
<<LIB
|
103
|
+
class #{@name.classify}
|
104
|
+
#Fill in the gaps :P
|
105
|
+
end
|
106
|
+
LIB
|
107
|
+
end
|
108
|
+
def executable
|
109
|
+
<<EXECUTABLE
|
110
|
+
#!/usr/bin/env ruby
|
111
|
+
|
112
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
113
|
+
require '#{@name}'
|
114
|
+
|
115
|
+
EXECUTABLE
|
116
|
+
end
|
117
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gemit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- |
|
14
|
+
kitofr
|
15
|
+
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2011-06-29 00:00:00 +02:00
|
21
|
+
default_executable:
|
22
|
+
dependencies: []
|
23
|
+
|
24
|
+
description: Scaffolds some things I most of the time want when creating a gem
|
25
|
+
email: |
|
26
|
+
kitofr@gmail.com
|
27
|
+
|
28
|
+
executables:
|
29
|
+
- gemit
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files: []
|
33
|
+
|
34
|
+
files:
|
35
|
+
- .gitignore
|
36
|
+
- README.md
|
37
|
+
- bin/gemit
|
38
|
+
- gemit.gemspec
|
39
|
+
- lib/gemit.rb
|
40
|
+
- lib/gemit/string_ext.rb
|
41
|
+
- lib/gemit/version.rb
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://github.com/kitofr/gemit
|
44
|
+
licenses: []
|
45
|
+
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 57
|
57
|
+
segments:
|
58
|
+
- 1
|
59
|
+
- 8
|
60
|
+
- 7
|
61
|
+
version: 1.8.7
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: 3
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project: gemit
|
74
|
+
rubygems_version: 1.3.7
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: A simple gem scaffolder
|
78
|
+
test_files: []
|
79
|
+
|