technicalpickles-jeweler 0.0.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/README.markdown ADDED
@@ -0,0 +1,95 @@
1
+ # Create a directory and git repo
2
+
3
+ $ mkdir jeweler
4
+ $ git init
5
+
6
+ # Create a Rakefile:
7
+
8
+ require 'rake'
9
+ require 'jeweler'
10
+
11
+ Jeweler.gemspec = Gem::Specification.new do |s|
12
+ s.name = "jeweler"
13
+ s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
14
+ s.email = "josh@technicalpickles.com"
15
+ s.homepage = "http://github.com/technicalpickles/jeweler"
16
+ s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
17
+ s.authors = ["Josh Nichols"]
18
+ s.files = FileList["[A-Z]*"]
19
+ end
20
+
21
+ Note, we don't include 'date', or 'version'. Jeweler takes care of that.
22
+
23
+ Jeweler assumes you'll have either a class or module similar to your spec's name. This value gets camelized, so...
24
+
25
+ Good:
26
+
27
+ * safety\_valve -> SafetyValve
28
+ * clearance -> Clearance
29
+
30
+ Bad:
31
+
32
+ * shoulda-generator -> Shoulda-generator (not valid!)
33
+ * ruby-debug -> Ruby-debug (not valid!)
34
+
35
+ We're opinionated and lazy.
36
+
37
+ # Create a version file
38
+
39
+ Stick it in `lib/(spec_name_here)/version.rb`, and start it out at some version, like 0.0.0:
40
+
41
+ class Jeweler
42
+ module Version
43
+ MAJOR = 0
44
+ MINOR = 0
45
+ PATCH = 0
46
+ end
47
+ end
48
+
49
+ OR
50
+
51
+ module Jeweler
52
+ module Version
53
+ MAJOR = 0
54
+ MINOR = 0
55
+ PATCH = 0
56
+ end
57
+ end
58
+
59
+ Which you use depends on how you want to organize your gem. If you have a top-level class, like Jeweler, use the first. If you have a top level module, like Clearance, use the latter.
60
+
61
+ # Generate the first gemspec
62
+
63
+ $ rake gemspec
64
+
65
+ # Commit it
66
+
67
+ $ git add .
68
+ $ git commit -a -m "First commit yo"
69
+
70
+ # Make a github repository
71
+
72
+ Wander to http://github.com/repositories/new and follow the instructions to get it pushed
73
+
74
+ # Enable Rubygem building on the repository
75
+
76
+ Go to your project's edit page and check the 'RubyGem' box.
77
+
78
+ # Go do something awesome
79
+
80
+ I'll let you figure that out
81
+
82
+ # Bump the version
83
+
84
+ You have a few rake tasks for automating the version bumping:
85
+
86
+ $ rake version:bump:patch
87
+ $ rake version:bump:minor
88
+ $ rake version:bump:major
89
+
90
+ This will automatically regenerate your gemspec.
91
+
92
+ Just commit and push it afterwards:
93
+
94
+ $ git commit -a -m "Version bump yo"
95
+ $ git push origin master
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ $:.unshift('lib')
5
+ require 'jeweler'
6
+
7
+ Jeweler.gemspec = Gem::Specification.new do |s|
8
+ s.name = "jeweler"
9
+ s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
10
+ s.email = "josh@technicalpickles.com"
11
+ s.homepage = "http://github.com/technicalpickles/jeweler"
12
+ s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
13
+ s.authors = ["Josh Nichols"]
14
+ s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
15
+ end
@@ -0,0 +1,34 @@
1
+ desc "Generate a gemspec file for GitHub"
2
+ task :gemspec do
3
+ Jeweler.write_gemspec
4
+ end
5
+
6
+ desc "Displays the current version"
7
+ task :version do
8
+ puts Jeweler.version
9
+ end
10
+
11
+ namespace :version do
12
+ namespace :bump do
13
+ desc "Bump the gemspec a major version."
14
+ task :major do
15
+ major = Jeweler.major_version + 1
16
+ Jeweler.bump_version(major, 0, 0)
17
+ Jeweler.write_gemspec
18
+ end
19
+
20
+ desc "Bump the gemspec a minor version."
21
+ task :minor do
22
+ minor = Jeweler.minor_version + 1
23
+ Jeweler.bump_version(Jeweler.major_version, minor, 0)
24
+ Jeweler.write_gemspec
25
+ end
26
+
27
+ desc "Bump the gemspec a patch version."
28
+ task :patch do
29
+ patch = Jeweler.patch_version + 1
30
+ Jeweler.bump_version(Jeweler.major_version, Jeweler.minor_version, patch)
31
+ Jeweler.write_gemspec
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ class Jeweler
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 0
6
+ end
7
+ end
data/lib/jeweler.rb ADDED
@@ -0,0 +1,114 @@
1
+ require 'date'
2
+
3
+ class Jeweler
4
+ def self.gemspec=(gemspec)
5
+ @@gemspec = gemspec
6
+ require version_module_path
7
+ @@gemspec.version = version
8
+ end
9
+
10
+ def self.major_version
11
+ version_module.const_get(:MAJOR)
12
+ end
13
+
14
+ def self.minor_version
15
+ version_module.const_get(:MINOR)
16
+ end
17
+
18
+ def self.patch_version
19
+ version_module.const_get(:PATCH)
20
+ end
21
+
22
+ def self.version
23
+ "#{major_version}.#{minor_version}.#{patch_version}"
24
+ end
25
+
26
+ def self.date
27
+ date = DateTime.now
28
+ "#{date.year}-#{date.month}-#{date.day}"
29
+ end
30
+
31
+ def self.bump_version(major, minor, patch)
32
+ main_module_or_class = constantize(main_module_name)
33
+ keyword = case main_module_or_class.class
34
+ when Class
35
+ 'class'
36
+ when Module
37
+ 'module'
38
+ else
39
+ raise "Uh, main_module_name should be a class or module, but was a #{main_module_or_class.class}"
40
+ end
41
+
42
+ File.open(version_module_path, 'w') do |file|
43
+ file.write <<-END
44
+ #{keyword} #{main_module_name}
45
+ module Version
46
+ MAJOR = #{major}
47
+ MINOR = #{minor}
48
+ PATCH = #{patch}
49
+ end
50
+ end
51
+ END
52
+ end
53
+ @@gemspec.version = "#{major}.#{minor}.#{patch}"
54
+ end
55
+
56
+ def self.write_gemspec
57
+ @@gemspec.date = self.date
58
+ File.open(gemspec_path, 'w') do |f|
59
+ f.write @@gemspec.to_ruby
60
+ end
61
+ end
62
+
63
+ private
64
+
65
+ def self.gemspec_path
66
+ "#{@@gemspec.name}.gemspec"
67
+ end
68
+
69
+ def self.version_module_path
70
+ "lib/#{@@gemspec.name}/version.rb"
71
+ end
72
+
73
+ def self.version_module
74
+ constantize("#{main_module_name}::Version")
75
+ end
76
+
77
+ def self.main_module_name
78
+ camelize(@@gemspec.name)
79
+ end
80
+
81
+ if Module.method(:const_get).arity == 1
82
+ def self.constantize(camel_cased_word)
83
+ names = camel_cased_word.split('::')
84
+ names.shift if names.empty? || names.first.empty?
85
+
86
+ constant = Object
87
+ names.each do |name|
88
+ constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
89
+ end
90
+ constant
91
+ end
92
+ else
93
+ def self.constantize(camel_cased_word) #:nodoc:
94
+ names = camel_cased_word.split('::')
95
+ names.shift if names.empty? || names.first.empty?
96
+
97
+ constant = Object
98
+ names.each do |name|
99
+ constant = constant.const_get(name, false) || constant.const_missing(name)
100
+ end
101
+ constant
102
+ end
103
+ end
104
+
105
+ def self.camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
106
+ if first_letter_in_uppercase
107
+ lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
108
+ else
109
+ lower_case_and_underscored_word.first.downcase + camelize(lower_case_and_underscored_word)[1..-1]
110
+ end
111
+ end
112
+ end
113
+
114
+ require 'jeweler/tasks'
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: technicalpickles-jeweler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh Nichols
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-10-11 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Simple and opinionated helper for creating Rubygem projects on GitHub
17
+ email: josh@technicalpickles.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - Rakefile
26
+ - README.markdown
27
+ - lib/jeweler
28
+ - lib/jeweler/tasks.rb
29
+ - lib/jeweler/version.rb
30
+ - lib/jeweler.rb
31
+ has_rdoc: false
32
+ homepage: http://github.com/technicalpickles/jeweler
33
+ post_install_message:
34
+ rdoc_options: []
35
+
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: "0"
43
+ version:
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ requirements: []
51
+
52
+ rubyforge_project:
53
+ rubygems_version: 1.2.0
54
+ signing_key:
55
+ specification_version: 2
56
+ summary: Simple and opinionated helper for creating Rubygem projects on GitHub
57
+ test_files: []
58
+