matthewtodd-shoe 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +28 -13
  2. data/Rakefile +2 -1
  3. data/lib/shoe.rb +60 -22
  4. metadata +5 -5
data/README.rdoc CHANGED
@@ -2,23 +2,38 @@
2
2
 
3
3
  You probably don't want to use Shoe -- especially if you're like me!
4
4
 
5
- I like tinkering with my build scripts. That's why I don't use hoe and jeweler and those guys, even though they're awesome. I like to put my own thing together, so I made Shoe.
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
6
 
7
- == Install
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
8
16
 
9
- gem sources --add http://gems.github.com
10
- gem install matthewtodd-shoe
17
+ And here's what you get, at most:
11
18
 
12
- == Use
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
13
32
 
14
- cd myproject
15
- shoe # create a Rakefile
16
- rake -T # see what you get
33
+ gem install matthewtodd-shoe --source http://gems.github.com
17
34
 
18
- mkdir test
19
- rake -T
35
+ == Getting Started
20
36
 
21
- mkdir features
22
- rake -T
37
+ Shoe can create a Rakefile for you:
23
38
 
24
- And that's about it. There's also a :release task that will pop up when you have a git remote called "origin", you're on the master branch, and you don't have a tag with the current version number.
39
+ cd myproject && shoe
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
2
2
  require 'shoe'
3
3
 
4
- Shoe.tie('shoe', '0.1.4', "You probably don't want to use Shoe.") do |spec|
4
+ Shoe.tie('shoe', '0.1.5', "You probably don't want to use Shoe.") do |spec|
5
5
  spec.remove_development_dependency_on_shoe
6
+ spec.requirements = ['git']
6
7
  spec.add_runtime_dependency 'cucumber'
7
8
  spec.add_runtime_dependency 'rake'
8
9
  end
data/lib/shoe.rb CHANGED
@@ -1,26 +1,36 @@
1
- require 'pathname'
2
1
  require 'rubygems/doc_manager'
3
2
 
4
- require 'cucumber/rake/task'
5
- require 'rake/testtask'
6
-
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.
7
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.
8
16
  def self.tie(name, version, summary)
9
17
  shoe = new(name, version, summary)
10
18
  yield shoe.spec if block_given?
11
19
  shoe.define_tasks
12
20
  end
13
21
 
22
+ # The Gem::Specification for your project.
14
23
  attr_reader :spec
15
24
 
25
+ # Initializes a Gem::Specification with some nice conventions.
16
26
  def initialize(name, version, summary)
17
27
  @spec = Gem::Specification.new do |spec|
18
28
  spec.name = name
19
29
  spec.version = version
20
30
  spec.summary = summary
21
- spec.files = FileList['Rakefile', '*.rdoc', 'bin/**/*', 'features/**/*', 'lib/**/*', 'resources**/*', 'test/**/*'].to_a
22
- spec.executables = executables
23
- spec.rdoc_options = %W(--main README.rdoc --title #{name}-#{version} --inline-source)
31
+ spec.files = FileList['Rakefile', '*.rdoc', 'bin/**/*', 'features/**/*', 'lib/**/*', 'resources/**/*', '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?
24
34
  spec.extra_rdoc_files = FileList['*.rdoc'].to_a
25
35
  spec.has_rdoc = true
26
36
  spec.author = `git config --get user.name`.chomp
@@ -33,6 +43,7 @@ class Shoe
33
43
  end
34
44
  end
35
45
 
46
+ # This is where the magic happens.
36
47
  def define_tasks
37
48
  desc 'Remove ignored files'
38
49
  task :clean do
@@ -41,20 +52,29 @@ class Shoe
41
52
 
42
53
  desc 'Generate documentation'
43
54
  task :rdoc do
44
- DocManager.new(local_spec).generate_rdoc
55
+ LocalDocManager.new(spec).generate_rdoc
56
+ sh 'open rdoc/index.html' if RUBY_PLATFORM =~ /darwin/
57
+ end
58
+
59
+ desc 'Run an irb console'
60
+ task :shell do
61
+ # MAYBE include -Iext. I think I'd like to wait until I handle C extensions in general.
62
+ exec 'irb', '-Ilib', "-r#{spec.name}"
45
63
  end
46
64
 
47
- if Pathname.pwd.join('test').directory?
65
+ if File.directory?('test')
66
+ require 'rake/testtask'
48
67
  Rake::TestTask.new { |task| task.pattern = 'test/*_test.rb' }
49
68
  default_depends_on(:test)
50
69
  end
51
70
 
52
- if Pathname.pwd.join('features').directory?
71
+ if File.directory?('features')
72
+ require 'cucumber/rake/task'
53
73
  Cucumber::Rake::Task.new('features', 'Run features')
54
74
  default_depends_on(:features)
55
75
  end
56
76
 
57
- if system("[[ -z `git tag -l #{spec.version}` ]] && git branch | grep -q '* master' && git remote | grep -q origin")
77
+ if these_shell_commands_all_succeed(there_is_no_tag_for_the_current_version, we_are_on_the_master_branch, there_is_a_remote_called_origin)
58
78
  desc "Release #{spec.name}-#{spec.version}"
59
79
  task :release do
60
80
  File.open("#{spec.name}.gemspec", 'w') { |f| f.write spec.to_ruby }
@@ -74,24 +94,42 @@ class Shoe
74
94
  task :default => task_name
75
95
  end
76
96
 
77
- def executables
78
- bin = Pathname.pwd.join('bin')
79
- bin.directory? ? bin.children.map { |child| child.basename.to_s } : []
97
+ def everything_in_the_bin_directory
98
+ File.directory?('bin') ? Dir.entries('bin') - ['.', '..'] : []
80
99
  end
81
100
 
82
- def local_spec
83
- local_spec = spec.dup
84
- def local_spec.full_gem_path
85
- Pathname.pwd
86
- end
87
- local_spec
101
+ # I'm guessing it's a little faster shell out to all these commands
102
+ # together, rather than running each one separately.
103
+ def these_shell_commands_all_succeed(*commands)
104
+ system(commands.join(' && '))
88
105
  end
89
106
 
90
- class DocManager < Gem::DocManager #:nodoc:
107
+ def there_is_no_tag_for_the_current_version
108
+ "[[ -z `git tag -l #{spec.version}` ]]"
109
+ end
110
+
111
+ def we_are_on_the_master_branch
112
+ "git branch | grep -q '* master'"
113
+ end
114
+
115
+ def there_is_a_remote_called_origin
116
+ 'git remote | grep -q origin'
117
+ end
118
+
119
+ # Using Gem::DocManager instead of Rake::RdocTask means you get to see your
120
+ # rdoc *exactly* as users who install your gem will.
121
+ class LocalDocManager < Gem::DocManager #:nodoc:
91
122
  def initialize(spec)
92
123
  @spec = spec
93
- @doc_dir = Pathname.pwd
124
+ @doc_dir = Dir.pwd
94
125
  @rdoc_args = []
126
+ adjust_spec_so_that_we_can_generate_rdoc_locally
127
+ end
128
+
129
+ def adjust_spec_so_that_we_can_generate_rdoc_locally
130
+ def @spec.full_gem_path
131
+ Dir.pwd
132
+ end
95
133
  end
96
134
  end
97
135
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matthewtodd-shoe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Todd
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-20 00:00:00 -07:00
12
+ date: 2009-07-24 00:00:00 -07:00
13
13
  default_executable: shoe
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -52,7 +52,7 @@ rdoc_options:
52
52
  - --main
53
53
  - README.rdoc
54
54
  - --title
55
- - shoe-0.1.4
55
+ - shoe-0.1.5
56
56
  - --inline-source
57
57
  require_paths:
58
58
  - lib
@@ -68,8 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  - !ruby/object:Gem::Version
69
69
  version: "0"
70
70
  version:
71
- requirements: []
72
-
71
+ requirements:
72
+ - git
73
73
  rubyforge_project:
74
74
  rubygems_version: 1.2.0
75
75
  signing_key: