hoe 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,11 @@
1
+ === 3.3.0 / 2012-11-12
2
+
3
+ * 3 minor enhancements:
4
+
5
+ * Added Sow#make_sub_modules. (bhenderson)
6
+ * Hoe.normalize_names now returns test class name separately. (bhenderson)
7
+ * Sow now generates test and impl files with proper namespacing. (bhenderson)
8
+
1
9
  === 3.2.0 / 2012-11-09
2
10
 
3
11
  * 3 minor enhancements:
@@ -31,7 +31,7 @@ template/README.txt.erb
31
31
  template/Rakefile.erb
32
32
  template/bin/file_name.erb
33
33
  template/lib/file_name.rb.erb
34
- template/test/test_file_name.rb.erb
34
+ template/test/file_name.rb.erb
35
35
  test/test_hoe.rb
36
36
  test/test_hoe_debug.rb
37
37
  test/test_hoe_gemcutter.rb
data/bin/sow CHANGED
@@ -20,6 +20,16 @@ def check_subdir option
20
20
  end
21
21
  end
22
22
 
23
+ def make_sub_modules klass
24
+ last = nil
25
+ result = ''
26
+ klass.split('::')[0..-2].each do |part|
27
+ last = [last, part].compact.join('::')
28
+ result << "module #{last}; end\n"
29
+ end
30
+ result << "\n" unless result.empty?
31
+ end
32
+
23
33
  op = OptionParser.new do |opts|
24
34
  opts.banner = "Usage: sow [options] project_name"
25
35
 
@@ -79,7 +89,7 @@ project = ARGV.shift
79
89
  abort op.to_s unless project
80
90
  abort "Project #{project} seems to exist" if test ?d, project
81
91
 
82
- _, file_name, klass = Hoe.normalize_names project
92
+ _, file_name, klass, test_klass = Hoe.normalize_names project
83
93
 
84
94
  FileUtils.cp_r template_path, project
85
95
 
@@ -96,7 +106,7 @@ Dir.chdir project do
96
106
  warn "erb: #{path}"
97
107
 
98
108
  File.open path, "w" do |io|
99
- erb = ERB.new file
109
+ erb = ERB.new file, nil, '<>'
100
110
  erb.filename = path
101
111
  io.puts erb.result(binding)
102
112
  end
@@ -105,12 +115,17 @@ Dir.chdir project do
105
115
  paths.grep(/file_name|\.erb$/).each do |file|
106
116
  new_file = file.sub(/file_name/, file_name).sub(/\.erb$/, '')
107
117
 
108
- # TODO change template to separate a flat filename from a directory
109
- # filename
110
- if file =~ /^(bin|test)/ then
118
+ case file
119
+ when /^bin/ then
111
120
  dir, *rest = new_file.split File::SEPARATOR
112
121
 
113
122
  new_file = File.join dir, rest.join('_')
123
+ when /^test/ then
124
+ dir, *rest = new_file.split File::SEPARATOR
125
+
126
+ rest.last.sub! /^/, 'test_'
127
+
128
+ new_file = File.join dir, *rest
114
129
  end
115
130
 
116
131
  FileUtils.mkdir_p File.dirname new_file
data/lib/hoe.rb CHANGED
@@ -91,7 +91,7 @@ class Hoe
91
91
  include Rake::DSL if defined?(Rake::DSL)
92
92
 
93
93
  # duh
94
- VERSION = '3.2.0'
94
+ VERSION = '3.3.0'
95
95
 
96
96
  @@plugins = [:clean, :debug, :deps, :flay, :flog, :newb, :package,
97
97
  :publish, :gemcutter, :signing, :test]
@@ -327,7 +327,7 @@ class Hoe
327
327
  end
328
328
 
329
329
  ##
330
- # Normalize a project name into the project, file, and klass names that
330
+ # Normalize a project name into the project, file, klass and test names that
331
331
  # follow Ruby package naming guidelines.
332
332
  #
333
333
  # Project names are lowercase with _ separating package parts and -
@@ -337,14 +337,17 @@ class Hoe
337
337
  # extension parts. net-http-persistent becomes net/http/persistent.
338
338
  #
339
339
  # Klass names are CamelCase with :: separating extension parts.
340
+ #
341
+ # Test klass names are same as Klass with Test prepended to each part.
340
342
 
341
343
  def self.normalize_names project # :nodoc:
342
- project = project.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, '')
343
- klass = project.gsub(/(?:^|_)([a-z])/) { $1.upcase }
344
- klass = klass. gsub(/(?:^|-)([a-z])/) { "::#{$1.upcase}" }
345
- file_name = project.gsub(/-/, '/')
344
+ project = project.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, '')
345
+ klass = project.gsub(/(?:^|_)([a-z])/) { $1.upcase }
346
+ klass = klass. gsub(/(?:^|-)([a-z])/) { "::#{$1.upcase}" }
347
+ test_klass = klass. gsub(/(^|::)([A-Z])/) { "#{$1}Test#{$2}" }
348
+ file_name = project.gsub(/-/, '/')
346
349
 
347
- return project, file_name, klass
350
+ return project, file_name, klass, test_klass
348
351
  end
349
352
 
350
353
  ##
@@ -1,3 +1,4 @@
1
+ <%= make_sub_modules klass %>
1
2
  class <%= klass %>
2
3
  VERSION = '1.0.0'
3
4
  end
@@ -1,7 +1,8 @@
1
1
  require "test/unit"
2
2
  require "<%= file_name %>"
3
3
 
4
- class Test<%= klass %> < Test::Unit::TestCase
4
+ <%= make_sub_modules test_klass %>
5
+ class <%= test_klass %> < Test::Unit::TestCase
5
6
  def test_sanity
6
7
  flunk "write tests or I will kneecap you"
7
8
  end
@@ -388,14 +388,14 @@ class TestHoe < MiniTest::Unit::TestCase
388
388
  end
389
389
 
390
390
  def test_rename
391
- # project, file_name, klass = Hoe.normalize_names 'project_name'
392
-
393
- assert_equal %w( word word Word), Hoe.normalize_names('word')
394
- assert_equal %w( word word Word), Hoe.normalize_names('Word')
395
- assert_equal %w(two_words two_words TwoWords), Hoe.normalize_names('TwoWords')
396
- assert_equal %w(two_words two_words TwoWords), Hoe.normalize_names('twoWords')
397
- assert_equal %w(two-words two/words Two::Words), Hoe.normalize_names('two-words')
398
- assert_equal %w(two_words two_words TwoWords), Hoe.normalize_names('two_words')
391
+ # project, file_name, klass, test_klass = Hoe.normalize_names 'project_name'
392
+
393
+ assert_equal %w( word word Word TestWord), Hoe.normalize_names('word')
394
+ assert_equal %w( word word Word TestWord), Hoe.normalize_names('Word')
395
+ assert_equal %w(two_words two_words TwoWords TestTwoWords), Hoe.normalize_names('TwoWords')
396
+ assert_equal %w(two_words two_words TwoWords TestTwoWords), Hoe.normalize_names('twoWords')
397
+ assert_equal %w(two-words two/words Two::Words TestTwo::TestWords), Hoe.normalize_names('two-words')
398
+ assert_equal %w(two_words two_words TwoWords TestTwoWords), Hoe.normalize_names('two_words')
399
399
  end
400
400
 
401
401
  def test_nosudo
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoe
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 3.2.0
10
+ version: 3.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Davis
@@ -36,7 +36,7 @@ cert_chain:
36
36
  FBHgymkyj/AOSqKRIpXPhjC6
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2012-11-09 00:00:00 Z
39
+ date: 2012-11-13 00:00:00 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
@@ -61,11 +61,11 @@ dependencies:
61
61
  requirements:
62
62
  - - ~>
63
63
  - !ruby/object:Gem::Version
64
- hash: 25
64
+ hash: 31
65
65
  segments:
66
66
  - 4
67
- - 1
68
- version: "4.1"
67
+ - 2
68
+ version: "4.2"
69
69
  type: :development
70
70
  version_requirements: *id002
71
71
  - !ruby/object:Gem::Dependency
@@ -138,7 +138,7 @@ files:
138
138
  - template/Rakefile.erb
139
139
  - template/bin/file_name.erb
140
140
  - template/lib/file_name.rb.erb
141
- - template/test/test_file_name.rb.erb
141
+ - template/test/file_name.rb.erb
142
142
  - test/test_hoe.rb
143
143
  - test/test_hoe_debug.rb
144
144
  - test/test_hoe_gemcutter.rb
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- e,se�&��,!�oJ��qP���\D�>��C�E�*b Y*]"u����@D�$��%�)�{H� �'�F��524��
1
+ "(r֑���Q��IKnP��=��x��i���p�W�gံ��9�ϴ���J���Y1?�qQ��8��503���E���ʥ+T���ա��K���r���A��$���1������r��'2��\կ2Q ���[׌�H�����[�xw���g`
2
+ ��n��$G� }0=C�Y�:�5v-�*/�a��Ka@]�����Er3�ʪ4�WF�-�l!�Ԯ�F�G�����:��}ΘҨf1�5�