technicalpickles-jeweler 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +11 -5
- data/VERSION.yml +1 -1
- data/lib/jeweler/gemspec.rb +1 -0
- data/lib/jeweler/generator.rb +79 -0
- data/lib/jeweler/templates/LICENSE +20 -0
- data/lib/jeweler/templates/README +9 -0
- data/lib/jeweler/templates/Rakefile +41 -0
- data/lib/jeweler.rb +2 -2
- metadata +7 -3
- data/lib/jeweler/active_support.rb +0 -38
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rake/rdoctask'
|
4
|
+
require 'rcov/rcovtask'
|
4
5
|
|
5
6
|
$:.unshift('lib')
|
6
7
|
|
@@ -19,20 +20,25 @@ rescue LoadError
|
|
19
20
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
20
21
|
end
|
21
22
|
|
23
|
+
|
22
24
|
Rake::TestTask.new do |t|
|
23
25
|
t.libs << 'lib'
|
24
26
|
t.pattern = 'test/**/*_test.rb'
|
25
27
|
t.verbose = false
|
26
28
|
end
|
27
29
|
|
28
|
-
|
29
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
30
|
+
Rake::RDocTask.new do |rdoc|
|
30
31
|
rdoc.rdoc_dir = 'rdoc'
|
31
32
|
rdoc.title = 'Jeweler'
|
32
33
|
rdoc.options << '--line-numbers' << '--inline-source'
|
33
34
|
rdoc.rdoc_files.include('README.markdown')
|
34
35
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
35
36
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
|
38
|
+
Rcov::RcovTask.new do |t|
|
39
|
+
t.libs << "test"
|
40
|
+
t.test_files = FileList['test/*_test.rb']
|
41
|
+
t.verbose = true
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => :rcov
|
data/VERSION.yml
CHANGED
data/lib/jeweler/gemspec.rb
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
class Jeweler
|
5
|
+
class Generator
|
6
|
+
attr_accessor :target_dir, :user_name, :user_email, :github_repo_name, :github_remote, :github_url, :github_username, :lib_dir
|
7
|
+
|
8
|
+
def initialize(github_remote, dir = nil)
|
9
|
+
|
10
|
+
self.github_remote = github_remote
|
11
|
+
check_user_git_config()
|
12
|
+
determine_github_stuff()
|
13
|
+
|
14
|
+
self.target_dir = dir || self.github_repo_name
|
15
|
+
self.lib_dir = File.join(target_dir, 'lib')
|
16
|
+
end
|
17
|
+
|
18
|
+
def check_user_git_config
|
19
|
+
lib = Git::Lib.new(nil, nil)
|
20
|
+
config = lib.parse_config '~/.gitconfig'
|
21
|
+
unless config.has_key? 'user.name'
|
22
|
+
puts %Q{No user.name set in ~/.gitconfig. Set it with: git config --global user.name 'Your Name Here'}
|
23
|
+
exit 1
|
24
|
+
end
|
25
|
+
unless config.has_key? 'user.email'
|
26
|
+
puts %Q{No user.name set in ~/.gitconfig. Set it with: git config --global user.name 'Your Name Here'}
|
27
|
+
exit 1
|
28
|
+
end
|
29
|
+
@user_name = config['user.name'].gsub('"', '')
|
30
|
+
@user_email = config['user.email'].gsub('"', '')
|
31
|
+
end
|
32
|
+
|
33
|
+
def determine_github_stuff
|
34
|
+
self.github_url = self.github_remote.gsub(/^git@github\.com:/, 'http://github.com/').gsub(/\.git$/, '/tree')
|
35
|
+
self.github_repo_name = self.github_remote.match(/\/(.*)\.git$/)[1]
|
36
|
+
end
|
37
|
+
|
38
|
+
def run
|
39
|
+
begin
|
40
|
+
FileUtils.mkdir target_dir
|
41
|
+
rescue Errno::EEXIST => e
|
42
|
+
puts "The directory #{target_dir} already exists, aborting. Maybe move it out of the way before continuing?"
|
43
|
+
exit 1
|
44
|
+
end
|
45
|
+
|
46
|
+
FileUtils.mkdir lib_dir
|
47
|
+
|
48
|
+
rakefile = template('Rakefile')
|
49
|
+
File.open(File.join(target_dir, 'Rakefile'), 'w') {|file| file.write(rakefile.result(binding))}
|
50
|
+
|
51
|
+
license = template('LICENSE')
|
52
|
+
File.open(File.join(target_dir, 'LICENSE'), 'w') {|file| file.write(license.result(binding))}
|
53
|
+
|
54
|
+
FileUtils.touch File.join(lib_dir, "#{github_repo_name}.rb")
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def template(file)
|
59
|
+
ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', file)))
|
60
|
+
end
|
61
|
+
|
62
|
+
def gitify
|
63
|
+
saved_pwd = Dir.pwd
|
64
|
+
Dir.chdir(target_dir)
|
65
|
+
begin
|
66
|
+
repo = Git.init()
|
67
|
+
repo.add('.')
|
68
|
+
repo.commit 'First commit courtesy of jeweler.'
|
69
|
+
repo.add_remote('origin', github_remote)
|
70
|
+
repo.push('origin', 'master')
|
71
|
+
rescue Git::GitExecuteError => e
|
72
|
+
puts "Encountered an error during gitification. Maybe the repo already exists, or has already been pushed to?"
|
73
|
+
puts
|
74
|
+
raise
|
75
|
+
end
|
76
|
+
Dir.chdir(saved_pwd)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 <%= user_name %>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rcov/rcovtask'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler.gemspec = Gem::Specification.new do |s|
|
9
|
+
s.name = "<%= github_repo_name %>"
|
10
|
+
s.summary = "TODO"
|
11
|
+
s.email = "<%= user_email %>"
|
12
|
+
s.homepage = "<%= github_url %>"
|
13
|
+
s.description = "TODO"
|
14
|
+
s.authors = ["<%= user_name %>"]
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
Rake::TestTask.new do |t|
|
22
|
+
t.libs << 'lib'
|
23
|
+
t.pattern = 'test/**/*_test.rb'
|
24
|
+
t.verbose = false
|
25
|
+
end
|
26
|
+
|
27
|
+
Rake::RDocTask.new do |rdoc|
|
28
|
+
rdoc.rdoc_dir = 'rdoc'
|
29
|
+
rdoc.title = 'Jeweler'
|
30
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
31
|
+
rdoc.rdoc_files.include('README*')
|
32
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
33
|
+
end
|
34
|
+
|
35
|
+
Rcov::RcovTask.new do |t|
|
36
|
+
t.libs << "test"
|
37
|
+
t.test_files = FileList['test/*_test.rb']
|
38
|
+
t.verbose = true
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :rcov
|
data/lib/jeweler.rb
CHANGED
@@ -5,9 +5,9 @@ require 'jeweler/versioning'
|
|
5
5
|
require 'jeweler/singleton'
|
6
6
|
require 'jeweler/gemspec'
|
7
7
|
require 'jeweler/errors'
|
8
|
+
require 'jeweler/generator'
|
8
9
|
|
9
10
|
require 'jeweler/tasks' if defined?(Rake)
|
10
|
-
require 'jeweler/active_support' # Adds the stolen camelize and constantize
|
11
11
|
|
12
12
|
# A Jeweler helps you craft the perfect Rubygem. Give him a gemspec, and he takes care of the rest.
|
13
13
|
class Jeweler
|
@@ -24,7 +24,7 @@ class Jeweler
|
|
24
24
|
@gemspec = gemspec
|
25
25
|
@base_dir = base_dir
|
26
26
|
|
27
|
-
@gemspec.files ||= FileList["[A-Z]*.*", "{generators,lib,test,spec}/**/*"]
|
27
|
+
@gemspec.files ||= FileList["[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"]
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: technicalpickles-jeweler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nichols
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-10-
|
13
|
+
date: 2008-10-24 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -28,12 +28,16 @@ files:
|
|
28
28
|
- TODO
|
29
29
|
- VERSION.yml
|
30
30
|
- lib/jeweler
|
31
|
-
- lib/jeweler/active_support.rb
|
32
31
|
- lib/jeweler/bumping.rb
|
33
32
|
- lib/jeweler/errors.rb
|
34
33
|
- lib/jeweler/gemspec.rb
|
34
|
+
- lib/jeweler/generator.rb
|
35
35
|
- lib/jeweler/singleton.rb
|
36
36
|
- lib/jeweler/tasks.rb
|
37
|
+
- lib/jeweler/templates
|
38
|
+
- lib/jeweler/templates/LICENSE
|
39
|
+
- lib/jeweler/templates/Rakefile
|
40
|
+
- lib/jeweler/templates/README
|
37
41
|
- lib/jeweler/versioning.rb
|
38
42
|
- lib/jeweler.rb
|
39
43
|
- test/fixtures
|
@@ -1,38 +0,0 @@
|
|
1
|
-
class Jeweler
|
2
|
-
# This stuff is blatently ripped out of active_support's inflector
|
3
|
-
module ActiveSupport
|
4
|
-
if Module.method(:const_get).arity == 1
|
5
|
-
def constantize(camel_cased_word)
|
6
|
-
names = camel_cased_word.split('::')
|
7
|
-
names.shift if names.empty? || names.first.empty?
|
8
|
-
|
9
|
-
constant = Object
|
10
|
-
names.each do |name|
|
11
|
-
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
12
|
-
end
|
13
|
-
constant
|
14
|
-
end
|
15
|
-
else
|
16
|
-
def constantize(camel_cased_word) #:nodoc:
|
17
|
-
names = camel_cased_word.split('::')
|
18
|
-
names.shift if names.empty? || names.first.empty?
|
19
|
-
|
20
|
-
constant = Object
|
21
|
-
names.each do |name|
|
22
|
-
constant = constant.const_get(name, false) || constant.const_missing(name)
|
23
|
-
end
|
24
|
-
constant
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
|
29
|
-
if first_letter_in_uppercase
|
30
|
-
lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
31
|
-
else
|
32
|
-
lower_case_and_underscored_word.first.downcase + camelize(lower_case_and_underscored_word)[1..-1]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
include ActiveSupport
|
38
|
-
end
|