rake_tasks 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,8 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
-
5
- group :test do
6
- gem 'mocha' , '~> 0.10.0'
7
- gem 'fakefs', '~> 0.4.0', :require => 'fakefs/safe'
8
- end
data/README.md ADDED
@@ -0,0 +1,106 @@
1
+ Welcome to RakeTasks
2
+ ====================
3
+
4
+ RakeTasks provides basic rake tasks for generating documentation,
5
+ building and installing gems, and running tests.
6
+ It will also load additional rake tasks if they are in a folder named 'tasks'.
7
+ mmmm yummy
8
+
9
+ The following assumptions are currently made:
10
+
11
+ * There is a valid .gemspec file in the root folder that is named the same
12
+ as the root folder.
13
+
14
+ * Tests reside in a folder named either 'test' or 'tests'
15
+ and test files are named *_test.rb or test_*.rb.
16
+
17
+ Additionally, if you have sub-folders under test(s)
18
+ (i.e. test/unit, test/performance), they will be available
19
+ using rake test:unit and rake test:performance.
20
+ Sub-folders that do not contain files matching the test file name patterns
21
+ will not be included in this set.
22
+
23
+ You may run a single test from any test file by using the following:
24
+
25
+ rake test:test_file[test_method]
26
+
27
+ test_file is the name of the test file without the pattern,
28
+ so if you have a test named my_class_test.rb with a test method
29
+ named my_test_method, it would be invoked by:
30
+
31
+ rake test:my_class[my_test_method]
32
+
33
+ * Additional rake tasks are named *.rb and reside in a folder named 'tasks'.
34
+
35
+ * README generation useo the gemspec data to populate the license information.
36
+
37
+ If README.md does not exist, one will be created.
38
+ If README.md does exist, a README_GENERATED.md file will be created,
39
+ so as not to overwrite a 'real' README.md file.
40
+
41
+ The default task will be set in the following order:
42
+
43
+ 1. If tests are found, rake will run test:all.
44
+
45
+ 2. If tests are not found, but an appropriately named .gemspec file is,
46
+ gem:build will be run.
47
+
48
+ 3. If no tests or .gemspec are found, rdoc:app will be run.
49
+
50
+ Getting Started
51
+ ---------------
52
+
53
+ Install RakeTasks at the command prompt if you haven't yet:
54
+
55
+ $ gem install rake_tasks
56
+
57
+ Require the gem in your Gemfile:
58
+
59
+ gem 'rake_tasks', '~> 2.0.6'
60
+
61
+ Require the gem wherever you need to use it:
62
+
63
+ require 'rake_tasks'
64
+
65
+ Updates
66
+ -------
67
+
68
+ 2.0.6 Use markdown for generated README.
69
+ Convert rake_task's README to markdown and rename it to README.md.
70
+
71
+ The gemspec is now located by extension rather than root folder.
72
+
73
+ 2.0.5 Specify load order of rake tasks.
74
+
75
+ 2.0.4 Added license files to the included files in the gemspec.
76
+ Excluded Gemfile.lock from included fileo in the gemspec.
77
+
78
+ 2.0.3 Added bundle_install.sh to the included files in the gemspec.
79
+
80
+ 2.0.2 test:[test_file] will now run all the tests in the specified file
81
+ if a method is not specified. It should be noted that 'test_file' is
82
+ the name of the file with the test pattern removed
83
+ (i.e. 'my_module_test.rb' => 'my_module',
84
+ 'test_my_module.rb' => 'my_module').
85
+
86
+ 2.0.1 Added test:full task (requires rvm).
87
+
88
+ test:full allows a user to run tests against multiple ruby/gemset/rake
89
+ configurations by specifying them in a yaml file in the test folder.
90
+
91
+ A common rubies.yml file might look something like this:
92
+
93
+ - ruby: 1.9.2
94
+ gemset: my_gem_test
95
+ - ruby: 1.9.3
96
+ gemset: my_gem_test
97
+
98
+ Additional Documentation
99
+ ------------------------
100
+
101
+ rake rdoc:app
102
+
103
+ License
104
+ -------
105
+
106
+ RakeTasks is released under the LGPLv3 license.
@@ -35,8 +35,8 @@ if RakeTasks::Gem.gem_file?
35
35
 
36
36
  gem_spec_file = RakeTasks::Gem.gem_spec_file
37
37
 
38
- readme = 'README'
39
- readme = 'README_GENERATED' if File.file?(readme)
38
+ readme = 'README.md'
39
+ readme = 'README_GENERATED.md' if File.file?(readme)
40
40
 
41
41
  file readme => gem_spec_file do |t|
42
42
  doc_obj = RakeTasks::Doc.new
File without changes
@@ -14,3 +14,4 @@ rvm use $1@$2
14
14
 
15
15
  gem install bundler --no-rdoc --no-ri
16
16
  bundle install
17
+ bundle clean --force
@@ -48,35 +48,35 @@ module RakeTasks
48
48
  gem_spec = @gem_spec
49
49
 
50
50
  @contents ||= %Q{
51
- #{header} Welcome to #{gem_title}
51
+ #{header :h1, "Welcome to #{gem_title}"}
52
52
 
53
53
  #{gem_spec.description}
54
54
 
55
- #{header} Getting Started
55
+ #{header :h2, 'Getting Started'}
56
56
 
57
- 1. Install #{gem_title} at the command prompt if you haven't yet:
57
+ Install #{gem_title} at the command prompt if you haven't yet:
58
58
 
59
- gem install #{gem_spec.name}
59
+ $ gem install #{gem_spec.name}
60
60
 
61
- 2. Require the gem in your Gemfile:
61
+ Require the gem in your Gemfile:
62
62
 
63
- gem '#{gem_spec.name}', '~> #{gem_spec.version}'
63
+ gem '#{gem_spec.name}', '~> #{gem_spec.version}'
64
64
 
65
- 3. Require the gem wherever you need to use it:
65
+ Require the gem wherever you need to use it:
66
66
 
67
- require '#{gem_spec.name}'
67
+ require '#{gem_spec.name}'
68
68
 
69
- #{header} Usage
69
+ #{header :h2, 'Usage'}
70
70
 
71
71
  TODO
72
72
 
73
- #{header} Additional Notes
73
+ #{header :h2, 'Additional Notes'}
74
74
 
75
75
  TODO
76
76
 
77
- #{header} Additional Documentation
77
+ #{header :h2, 'Additional Documentation'}
78
78
 
79
- rake rdoc:app
79
+ $ rake rdoc:app
80
80
  #{license_details}}.strip
81
81
 
82
82
  return @contents
@@ -86,67 +86,25 @@ rake rdoc:app
86
86
  private
87
87
  ########################################################################
88
88
 
89
- # Header indicator.
90
- def header
91
- '=='
89
+ # Returns formatted headers.
90
+ def header(type, text = nil)
91
+ case type
92
+ when :h1
93
+ "#{text}\n#{'=' * text.length}"
94
+ when :h2
95
+ "#{text}\n#{'-' * text.length}"
96
+ end
92
97
  end
93
98
 
94
99
  # Compose the license details.
95
- # This will include links to the license and image,
96
- # if they exist in the license folder.
97
100
  def license_details
98
101
  return if @gem_spec.licenses.empty?
99
102
 
100
- # Set up the header (and other info. that will be the same regardless).
101
- out = ''
102
- out += "\n#{header} License\n\n"
103
- out += "#{@gem_title} is released under the "
104
-
105
- # Get image files.
106
- images = Dir[
107
- File.join(@license_path, '*.png'),
108
- File.join(@license_path, '*.jpg'),
109
- File.join(@license_path, '*.jpeg'),
110
- File.join(@license_path, '*.gif')
111
- ]
112
-
113
- # Get license files (by removing images from all files).
114
- files = Dir[File.join(@license_path, '*')] - images
115
-
116
- # Find the license file that matches the license.
117
- found = nil
118
- files.each do |file|
119
- next unless File.file?(file)
120
- if @gem_spec.license.downcase == File.basename(file).downcase
121
- found = file
122
- break
123
- end
124
- end
125
-
126
- # Add the link to the license file.
127
- if found
128
- out += "{#{@gem_spec.license} license}[link:../../#{found}].\n"
129
- else
130
- out += "#{@gem_spec.license} license.\n"
131
- end
132
-
133
- # Find the image file that matches the license.
134
- found = nil
135
- images.each do |file|
136
- next unless File.file?(file)
137
- if @gem_spec.license.downcase ==
138
- File.basename(file).sub(/\..+?$/, '').downcase
139
- found = file
140
- break
141
- end
142
- end
143
-
144
- # Add the link to the image file.
145
- if found
146
- out += "\nlink:../../#{found}"
147
- end
103
+ %Q{
104
+ #{header :h2, 'License'}
148
105
 
149
- return out
106
+ #{@gem_title} is released under the #{@gem_spec.licenses.first} license.
107
+ }
150
108
  end
151
109
  end
152
110
  end
@@ -49,15 +49,14 @@ module RakeTasks
49
49
  end
50
50
 
51
51
  # Get the gem specification.
52
- def gem_spec(spec = Kernel.const_get('Gem').const_get('Specification'))
53
- spec.load(gem_spec_file) if gem_file?
52
+ def gem_spec
53
+ ::Gem::Specification.load(gem_spec_file) if gem_file?
54
54
  end
55
55
 
56
56
  # Check for a gem spec file.
57
57
  def gem_spec_file
58
- file = File.basename(Dir.getwd) + '.gemspec'
59
- return nil unless File.file? file
60
- return file
58
+ file_name = Dir['*.gemspec'].first
59
+ return file_name
61
60
  end
62
61
 
63
62
  # Returns the name and version from the specified gem specification.
@@ -68,28 +67,27 @@ module RakeTasks
68
67
  end
69
68
 
70
69
  # Updates the version in the gem specification file.
71
- def version!(value, spec = gem_spec, temp = Tempfile.new('temp_gem_spec'))
72
- return if spec.nil?
70
+ def version!(value, spec = gem_spec)
71
+ return unless gem_spec_file
73
72
 
74
- begin
75
- file = File.open(gem_spec_file, 'r')
73
+ temp = StringIO.new
76
74
 
75
+ File.open(gem_spec_file, 'r') do |file|
77
76
  while line = file.gets
78
77
  if line =~ /version *= *['"]#{spec.version}['"]/
79
- temp.puts line.sub(/(['"])#{spec.version}(['"])/, "\\1#{value}\\2")
78
+ temp.puts line.sub(/['"].*['"]/, "'#{value}'")
80
79
  else
81
80
  temp.puts line
82
81
  end
83
82
  end
83
+ end
84
84
 
85
- temp.flush
85
+ temp.rewind
86
86
 
87
- FileUtils.mv temp.path, gem_spec_file
88
- rescue Exception => ex
89
- raise ex
90
- ensure
91
- temp.close
92
- temp.unlink
87
+ File.open(gem_spec_file, 'w') do |file|
88
+ while line = temp.gets
89
+ file.puts line
90
+ end
93
91
  end
94
92
  end
95
93
  end
File without changes
@@ -9,4 +9,10 @@ else
9
9
  fi
10
10
 
11
11
  rvm use $2
12
- rake $3 $1
12
+
13
+ if [ $# -ge 3 ]; then
14
+ gem install rake -v $3 --no-rdoc --no-ri
15
+ rake _$3_ $1
16
+ else
17
+ bundle exec rake $1
18
+ fi
@@ -128,7 +128,7 @@ module RakeTasks
128
128
 
129
129
  cmd = ['bash', RakeTasks::SCRIPTS[:rubies], 'test:all']
130
130
  cmd << config[:ruby]
131
- cmd << "_#{config[:rake]}_" if config[:rake]
131
+ cmd << config[:rake] if config[:rake]
132
132
 
133
133
  # Run the tests.
134
134
  pid = Process.spawn(*cmd, :out => 'out.log', :err => 'err.log')
File without changes
File without changes
data/lib/rake_tasks.rb CHANGED
@@ -31,7 +31,6 @@
31
31
  require 'rake/testtask'
32
32
  require 'rdoc/task'
33
33
  require 'rake/clean'
34
- require 'tempfile'
35
34
  require 'fileutils'
36
35
  require 'psych'
37
36