shoe 0.1.8

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.
Files changed (6) hide show
  1. data/README.rdoc +39 -0
  2. data/Rakefile +9 -0
  3. data/bin/shoe +43 -0
  4. data/lib/shoe.rb +149 -0
  5. data/shoe.gemspec +36 -0
  6. metadata +82 -0
@@ -0,0 +1,39 @@
1
+ = Shoe
2
+
3
+ You probably don't want to use Shoe -- especially if you're like me!
4
+
5
+ I like tinkering with my build scripts. That's why I don't use hoe[http://seattlerb.rubyforge.org/hoe] and jeweler[http://github.com/technicalpickles/jeweler] and those guys, even though they're awesome. I like to put my own thing together, so I made Shoe.
6
+
7
+ == Behold
8
+
9
+ Here's how your Rakefile looks:
10
+
11
+ require 'shoe'
12
+
13
+ Shoe.tie('myproject', '0.1.0', "This is my project, and it's awesome!") do |spec|
14
+ spec.add_development_dependency 'thoughtbot-shoulda'
15
+ end
16
+
17
+ And here's what you get, at most:
18
+
19
+ rake clean # Remove ignored files
20
+ rake default # Run tests / Run features
21
+ rake features # Run features
22
+ rake rdoc # Generate documentation
23
+ rake release # Release myproject-0.1.0
24
+ rake shell # Run an irb console
25
+ rake test # Run tests
26
+
27
+ Most of the time, though, you won't see all of these: when possible, tasks are conditionally defined.
28
+
29
+ See what I mean by reading Shoe#define_tasks.
30
+
31
+ == Install
32
+
33
+ gem install matthewtodd-shoe --source http://gems.github.com
34
+
35
+ == Getting Started
36
+
37
+ Shoe can create a Rakefile for you:
38
+
39
+ cd myproject && shoe
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
2
+ require 'shoe'
3
+
4
+ Shoe.tie('shoe', '0.1.8', "You probably don't want to use Shoe.") do |spec|
5
+ spec.remove_development_dependency_on_shoe
6
+ spec.requirements = ['git']
7
+ spec.add_runtime_dependency 'cucumber'
8
+ spec.add_runtime_dependency 'rake'
9
+ end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if File.exists?('Rakefile')
4
+ abort 'Rakefile exists. Not clobbering.'
5
+ end
6
+
7
+ project_name = File.basename(File.expand_path(Dir.pwd))
8
+
9
+ File.open('Rakefile', 'w') do |file|
10
+ file.write <<-END_RAKEFILE.gsub('NAME', project_name)
11
+ this_rakefile_uses_shoe = <<END
12
+ ----------------------------------------
13
+ Please install Shoe:
14
+ gem sources --add http://gems.github.com
15
+ gem install matthewtodd-shoe
16
+ ----------------------------------------
17
+ END
18
+
19
+ begin
20
+ gem 'matthewtodd-shoe'
21
+ rescue Gem::LoadError
22
+ abort this_rakefile_uses_shoe
23
+ else
24
+ require 'shoe'
25
+ end
26
+
27
+ Shoe.tie('NAME', '0.1.0', 'TODO write a summary of NAME here.') do |spec|
28
+ # spec.add_development_dependency 'thoughtbot-shoulda'
29
+ end
30
+ END_RAKEFILE
31
+ end
32
+
33
+ if File.exists?('README.rdoc')
34
+ abort 'README.rdoc exists. Not clobbering.'
35
+ end
36
+
37
+ File.open('README.rdoc', 'w') do |file|
38
+ file.write <<-END_README.gsub('NAME', project_name.capitalize)
39
+ = NAME
40
+
41
+ NAME is one of my favorite things! Let me tell you about it:
42
+ END_README
43
+ end
@@ -0,0 +1,149 @@
1
+ require 'rubygems/doc_manager'
2
+
3
+ # Shoe defines some handy Rake tasks for your project, all built around your Gem::Specification.
4
+ #
5
+ # Here's how you use it in your Rakefile:
6
+ #
7
+ # require 'shoe'
8
+ # Shoe.tie('myproject', '0.1.0', "This is my project, and it's awesome!") do |spec|
9
+ # spec.add_development_dependency 'thoughtbot-shoulda'
10
+ # end
11
+ #
12
+ # Shoe comes with an executable named "shoe" that will generate a Rakefile like this (but slightly fancier) for you.
13
+ class Shoe
14
+ # Here's where you start. In your Rakefile, you'll probably just call
15
+ # Shoe.tie, then add any dependencies in the block.
16
+ def self.tie(name, version, summary)
17
+ shoe = new(name, version, summary)
18
+ yield shoe.spec if block_given?
19
+ shoe.define_tasks
20
+ end
21
+
22
+ # The Gem::Specification for your project.
23
+ attr_reader :spec
24
+
25
+ # Initializes a Gem::Specification with some nice conventions.
26
+ def initialize(name, version, summary)
27
+ @spec = Gem::Specification.new do |spec|
28
+ spec.name = name
29
+ spec.version = version
30
+ spec.summary = summary
31
+ spec.files = FileList['Rakefile', '*.gemspec', '**/*.rdoc', 'bin/**/*', 'examples/**/*', 'features/**/*', 'lib/**/*', 'resources/**/*', 'shoulda_macros/**/*', 'test/**/*'].to_a
32
+ spec.executables = everything_in_the_bin_directory
33
+ spec.rdoc_options = %W(--main README.rdoc --title #{name}-#{version} --inline-source) # MAYBE include --all, so that we document private methods?
34
+ spec.extra_rdoc_files = FileList['*.rdoc', 'shoulda_macros/**/*'].to_a
35
+ spec.has_rdoc = true
36
+ spec.author = `git config --get user.name`.chomp
37
+ spec.email = `git config --get user.email`.chomp
38
+ spec.add_development_dependency 'matthewtodd-shoe'
39
+ end
40
+
41
+ def @spec.remove_development_dependency_on_shoe
42
+ dependencies.delete_if { |d| d.name == 'matthewtodd-shoe' }
43
+ end
44
+ end
45
+
46
+ # This is where the magic happens.
47
+ def define_tasks
48
+ if File.directory?('.git')
49
+ desc 'Remove ignored files'
50
+ task :clean do
51
+ sh 'git clean -fdX'
52
+ end
53
+ end
54
+
55
+ if File.directory?('lib')
56
+ desc 'Generate documentation'
57
+ task :rdoc do
58
+ LocalDocManager.new(spec).generate_rdoc
59
+
60
+ case RUBY_PLATFORM
61
+ when /darwin/
62
+ sh 'open rdoc/index.html'
63
+ when /mswin|mingw/
64
+ sh 'start rdoc\index.html'
65
+ else
66
+ sh 'firefox rdoc/index.html'
67
+ end
68
+ end
69
+ end
70
+
71
+ if File.file?("lib/#{spec.name}.rb")
72
+ desc 'Run an irb console'
73
+ task :shell do
74
+ # MAYBE include -Iext. I think I'd like to wait until I handle C extensions in general.
75
+ exec 'irb', '-Ilib', "-r#{spec.name}"
76
+ end
77
+ end
78
+
79
+ if File.directory?('test')
80
+ require 'rake/testtask'
81
+ # MAYBE be a little more forgiving in test selection, using test/**/*_test.rb. Or create suites based on subdirectory?
82
+ Rake::TestTask.new { |task| task.pattern = 'test/*_test.rb' }
83
+ default_depends_on(:test)
84
+ end
85
+
86
+ if File.directory?('features')
87
+ require 'cucumber/rake/task'
88
+ Cucumber::Rake::Task.new('features', 'Run features')
89
+ default_depends_on(:features)
90
+ end
91
+
92
+ desc 'Show latest gemspec contents'
93
+ task :gemspec do
94
+ puts spec.to_ruby
95
+ end
96
+
97
+ if there_is_no_tag_for_the_current_version && we_are_on_the_master_branch && we_have_already_pushed_the_master_branch_to_a_remote_called_origin
98
+ desc "Release #{spec.name}-#{spec.version}"
99
+ task :release do
100
+ File.open("#{spec.name}.gemspec", 'w') { |f| f.write spec.to_ruby }
101
+ sh "git add #{spec.name}.gemspec"
102
+ sh "git commit -a -m 'Release #{spec.version}'"
103
+ sh "git tag #{spec.version}"
104
+ sh 'git push'
105
+ sh 'git push --tags'
106
+ end
107
+ end
108
+ end
109
+
110
+ private
111
+
112
+ def default_depends_on(task_name)
113
+ desc Rake.application.lookup(task_name).comment
114
+ task :default => task_name
115
+ end
116
+
117
+ def everything_in_the_bin_directory
118
+ File.directory?('bin') ? Dir.entries('bin') - ['.', '..'] : []
119
+ end
120
+
121
+ def there_is_no_tag_for_the_current_version
122
+ !File.file?(".git/refs/tags/#{spec.version}")
123
+ end
124
+
125
+ def we_are_on_the_master_branch
126
+ File.file?('.git/HEAD') && File.read('.git/HEAD').strip == 'ref: refs/heads/master'
127
+ end
128
+
129
+ def we_have_already_pushed_the_master_branch_to_a_remote_called_origin
130
+ File.file?('.git/refs/remotes/origin/master')
131
+ end
132
+
133
+ # Using Gem::DocManager instead of Rake::RDocTask means you get to see your
134
+ # rdoc *exactly* as users who install your gem will.
135
+ class LocalDocManager < Gem::DocManager #:nodoc:
136
+ def initialize(spec)
137
+ @spec = spec
138
+ @doc_dir = Dir.pwd
139
+ @rdoc_args = []
140
+ adjust_spec_so_that_we_can_generate_rdoc_locally
141
+ end
142
+
143
+ def adjust_spec_so_that_we_can_generate_rdoc_locally
144
+ def @spec.full_gem_path
145
+ Dir.pwd
146
+ end
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,36 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{shoe}
5
+ s.version = "0.1.8"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Matthew Todd"]
9
+ s.date = %q{2009-09-02}
10
+ s.default_executable = %q{shoe}
11
+ s.email = %q{matthew.todd@gmail.com}
12
+ s.executables = ["shoe"]
13
+ s.extra_rdoc_files = ["README.rdoc"]
14
+ s.files = ["Rakefile", "shoe.gemspec", "README.rdoc", "bin/shoe", "lib/shoe.rb"]
15
+ s.rdoc_options = ["--main", "README.rdoc", "--title", "shoe-0.1.8", "--inline-source"]
16
+ s.require_paths = ["lib"]
17
+ s.requirements = ["git"]
18
+ s.rubygems_version = %q{1.3.5}
19
+ s.summary = %q{You probably don't want to use Shoe.}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<cucumber>, [">= 0"])
27
+ s.add_runtime_dependency(%q<rake>, [">= 0"])
28
+ else
29
+ s.add_dependency(%q<cucumber>, [">= 0"])
30
+ s.add_dependency(%q<rake>, [">= 0"])
31
+ end
32
+ else
33
+ s.add_dependency(%q<cucumber>, [">= 0"])
34
+ s.add_dependency(%q<rake>, [">= 0"])
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shoe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.8
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Todd
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-02 00:00:00 +03:00
13
+ default_executable: shoe
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: cucumber
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description:
36
+ email: matthew.todd@gmail.com
37
+ executables:
38
+ - shoe
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README.rdoc
43
+ files:
44
+ - Rakefile
45
+ - shoe.gemspec
46
+ - README.rdoc
47
+ - bin/shoe
48
+ - lib/shoe.rb
49
+ has_rdoc: true
50
+ homepage:
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --main
56
+ - README.rdoc
57
+ - --title
58
+ - shoe-0.1.8
59
+ - --inline-source
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ requirements:
75
+ - git
76
+ rubyforge_project:
77
+ rubygems_version: 1.3.5
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: You probably don't want to use Shoe.
81
+ test_files: []
82
+