revans-sleeve 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2008 Code Wranglers, Inc. & Robert R Evans
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ task :default => :install
2
+
3
+ desc "install the gem locally"
4
+ task :install do
5
+ sh %{ruby "#{File.dirname(__FILE__)}/bin/sleeve" :install}
6
+ end
data/bin/sleeve ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'sleeve'
5
+
6
+ options = Sleeve::Options.parse(ARGV)
7
+ Sleeve::Generate.new(options)
data/changelog.rdoc ADDED
@@ -0,0 +1,7 @@
1
+
2
+ Mon Nov 17, 2008
3
+ * Initial creation of Sleeve
4
+ * A Generator for a Gem Sleeve
5
+ * An Option Parser
6
+ * Creates a GemSpec file
7
+ * Specs are none existent :(
@@ -0,0 +1,184 @@
1
+ module Sleeve
2
+ class Generate
3
+
4
+ # User should pass the name of the gem and the path, if they want the gem
5
+ # to live somewhere other than pwd.
6
+ #
7
+ def initialize(options)
8
+ raise GemNameRequired, "You need to require a gem name, like this: sleeve --name gem_name" if options.name.nil?
9
+ @options = options
10
+ @options.path = Dir.pwd if @options.path.nil?
11
+ @options.name.downcase!
12
+ @options.gem_path = File.join(@options.path, @options.name)
13
+ @options.gem_bin = File.join(@options.gem_path, 'bin')
14
+ @options.gem_lib = File.join(@options.gem_path, 'lib')
15
+ @options.gem_spec = File.join(@options.gem_path, 'spec')
16
+ @options.gem_lib_folder = File.join(@options.gem_lib, @options.name)
17
+ files
18
+ end
19
+
20
+
21
+ def files
22
+ generate_folders
23
+ gen_base_files
24
+ generate_bin_file
25
+ generate_spec_files
26
+ generate_lib_file
27
+ exit_message
28
+ end
29
+
30
+ # Generate our Folders
31
+ def generate_folders
32
+ FileUtils.mkdir_p(@options.gem_path)
33
+ FileUtils.mkdir_p(@options.gem_bin)
34
+ FileUtils.mkdir_p(@options.gem_lib)
35
+ FileUtils.mkdir_p(@options.gem_spec)
36
+ FileUtils.mkdir_p(@options.gem_lib_folder)
37
+ end
38
+
39
+
40
+ # Generate a basic lib file
41
+ def generate_lib_file
42
+ File.open(File.join(@options.gem_lib, "#{@options.name}.rb"), "w+") do |f|
43
+ f.puts <<-EX
44
+ module #{camel_case(@options.name)}
45
+ module Version #:nodoc:
46
+ Major = '0'
47
+ Minor = '1'
48
+ Tweak = '0'
49
+ String = [Major, Minor, Tweak].join('.')
50
+ end
51
+ end
52
+
53
+ # Required Gems
54
+
55
+ # Gem specific Requires
56
+ # require "#{@options.name}/"
57
+ EX
58
+ end
59
+ end
60
+
61
+
62
+ # Generate Default Spec Files
63
+ def generate_spec_files
64
+ File.open(File.join(@options.gem_spec, "spec.opts"), "w+") do |f|
65
+ f.puts "--color"
66
+ end
67
+
68
+ File.open(File.join(@options.gem_spec, "spec_helper.rb"), "w+") do |f|
69
+ f.puts <<-EX
70
+ $TESTING=true
71
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
72
+
73
+ Spec::Runner.configure do |config|
74
+
75
+ end
76
+ EX
77
+ end
78
+ end
79
+
80
+
81
+ # Generate our bin file
82
+ def generate_bin_file
83
+ File.open(File.join(@options.gem_bin, @options.name), "w+") do |f|
84
+ f.puts <<-EX
85
+ #!/usr/bin/env ruby
86
+
87
+ require 'rubygems'
88
+ require '#{@options.name}'
89
+ EX
90
+ end
91
+ end
92
+
93
+
94
+ # Generate our Base Files
95
+ def gen_base_files
96
+ File.new(File.join(@options.gem_path, "README.markdown"), "w+")
97
+ File.new(File.join(@options.gem_path, "ChangeLog.rdoc"), "w+")
98
+ File.new(File.join(@options.gem_path, "Rakefile"), "w+")
99
+ generate_license
100
+ generate_gemspec
101
+ end
102
+
103
+
104
+ # Generate the License
105
+ def generate_license
106
+ File.open(File.join(@options.gem_path, "LICENSE"), "w+") do |f|
107
+ f.puts <<-EX
108
+ Copyright (c) 2008 Your Name Here
109
+
110
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
111
+ this software and associated documentation files (the "Software"), to deal in
112
+ the Software without restriction, including without limitation the rights to
113
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
114
+ the Software, and to permit persons to whom the Software is furnished to do so,
115
+ subject to the following conditions:
116
+
117
+ The above copyright notice and this permission notice shall be included in all
118
+ copies or substantial portions of the Software.
119
+
120
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
121
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
122
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
123
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
124
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
125
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
126
+ EX
127
+ end
128
+ end
129
+
130
+
131
+ # Generate the GemSpec File
132
+ def generate_gemspec
133
+ File.open(File.join(@options.gem_path, "#{@options.name}.gemspec"), "w+") do |f|
134
+ f.puts <<-EX
135
+ Gem::Specification.new do |s|
136
+ s.name = %q{#{@options.name}}
137
+ s.version = "0.1.0"
138
+
139
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
140
+ s.authors = ["Your Name"]
141
+ s.date = %q{#{Time.now.strftime("%Y-%m-%d")}}
142
+ s.description = %q{A description here}
143
+ s.email = %q{Your Email Address}
144
+ s.executables = ["#{@options.name}"]
145
+ s.extra_rdoc_files = ["README.markdown", "ChangeLog.rdoc", "LICENSE"]
146
+ s.files = ["README.markdown", "LICENSE", "ChangeLog.rdoc", "Rakefile", "bin/#{@options.name}", "lib/#{@options.name}.rb", "lib/#{@options.name}/"]
147
+ s.has_rdoc = true
148
+ s.homepage = %q{http://yourdomain.com}
149
+ s.require_paths = ["lib"]
150
+ s.rubyforge_project = %q{#{@options.name}}
151
+ s.rubygems_version = %q{1.2.0}
152
+ s.summary = %q{A Summary here}
153
+
154
+ if s.respond_to? :specification_version then
155
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
156
+ s.specification_version = 2
157
+
158
+ if current_version >= 3 then
159
+ else
160
+ end
161
+ else
162
+ end
163
+ end
164
+ EX
165
+ end
166
+ end
167
+
168
+
169
+ def exit_message
170
+ puts "\nYour new Gem, #{@options.name}, has been created.\n"
171
+ end
172
+
173
+ private
174
+
175
+ # Camel Case
176
+ def camel_case(word)
177
+ word = word.gsub(/[^a-zA-Z_\- ]/," ")
178
+ word = word.gsub(/_/, " ")
179
+ word = " " + word.split.join(" ")
180
+ word.gsub(/ (.)/) { $1.upcase }
181
+ end
182
+
183
+ end
184
+ end
@@ -0,0 +1,40 @@
1
+ module Sleeve
2
+ class Options
3
+
4
+ # Parse Arguments being passed
5
+ def self.parse(args)
6
+ options = OpenStruct.new
7
+
8
+ opts = OptionParser.new do |opts|
9
+ opts.banner = "Usage: Creates a Sleeve for your Gem, so you can spend your time writing your Gem code instead of the sleeve that creates your Gem."
10
+ opts.separator ""
11
+ opts.separator "Specific Options:"
12
+
13
+ # Required Arguments
14
+ opts.on("-n", "--name NAME", "The Name of the Gem") do |ext|
15
+ options.name = ext
16
+ options.name.sub!(/(\s+)/, "-")
17
+ end
18
+
19
+ # Optional Arguments
20
+ opts.on("-p", "--path PATH", "The path of where you want your Gem to live. If not supplied, it will create the gem in the current Directory.") do |ext|
21
+ options.path = ext || Dir.pwd
22
+ end
23
+
24
+ opts.on_tail("-h", "--help", "Show help") do
25
+ puts opts
26
+ exit(0)
27
+ end
28
+
29
+ opts.on_tail("-v", "--version", "Show Version") do
30
+ puts "Sleeve is currently at Version #{Sleeve::Version}"
31
+ exit(0)
32
+ end
33
+
34
+ end
35
+ opts.parse!(args)
36
+ options
37
+ end # parse
38
+
39
+ end # Options
40
+ end # Sleeve
data/lib/sleeve.rb ADDED
@@ -0,0 +1,11 @@
1
+ module Sleeve
2
+ Version = "0.1.1"
3
+ class GemNameRequired < StandardError; end
4
+ end
5
+
6
+ # Required Gems
7
+ %w[optparse ostruct fileutils].each { |library| require library }
8
+
9
+ # Gem specific Requires
10
+ require File.dirname(__FILE__) + "/sleeve/parser"
11
+ require File.dirname(__FILE__) + "/sleeve/generate"
data/readme.markdown ADDED
@@ -0,0 +1,3 @@
1
+ # Sleeve
2
+
3
+ Sleeve is a very simple Gem Generator that creates a gemspec that can be used by RubyGems and Github to build your Gems. Sleeve does not require additional gems like newgem does and is much lighter.
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: revans-sleeve
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Robert Evans
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-17 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Creates the basic gem structure you need for creating a gem.
17
+ email: robertrevans@gmail.com
18
+ executables:
19
+ - sleeve
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - readme.markdown
24
+ - changelog.rdoc
25
+ - LICENSE
26
+ files:
27
+ - readme.markdown
28
+ - LICENSE
29
+ - changelog.rdoc
30
+ - Rakefile
31
+ - bin/sleeve
32
+ - lib/sleeve.rb
33
+ - lib/sleeve/generate.rb
34
+ - lib/sleeve/parser.rb
35
+ has_rdoc: true
36
+ homepage: http://robertrevans.com
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project: sleeve
57
+ rubygems_version: 1.2.0
58
+ signing_key:
59
+ specification_version: 2
60
+ summary: A basic gem sleeve
61
+ test_files: []
62
+