noe 1.7.3 → 1.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ # 1.7.4 / 2012-02-26
2
+
3
+ * Avoid creating the project folder if 'noe prepare' is going to fail due to unknown
4
+ template or layout.
5
+ * Enhance an error message when unknown template or layout.
6
+ * Noe uses the epath gem for easy file management. Noe's public API(s) should not be
7
+ affected at all by this change.
8
+
1
9
  # 1.7.3 / 2012-02-25
2
10
 
3
11
  * Most important changes are in default ruby skeleton, see its own CHANGELOG
data/Gemfile CHANGED
@@ -2,21 +2,22 @@ source 'http://rubygems.org'
2
2
 
3
3
  group :test do
4
4
  gem "rake", "~> 0.9.2"
5
- gem "rspec", "~> 2.7.0"
5
+ gem "rspec", "~> 2.9"
6
6
  end
7
7
 
8
8
  group :release do
9
9
  gem "rake", "~> 0.9.2"
10
- gem "rspec", "~> 2.7.0"
10
+ gem "rspec", "~> 2.9"
11
11
  end
12
12
 
13
13
  group :doc do
14
14
  gem "yard", "~> 0.7.2"
15
- gem "bluecloth", "~> 2.2.0"
15
+ gem "bluecloth", "~> 2.2"
16
16
  end
17
17
 
18
18
  group :runtime do
19
19
  gem "wlang", "~> 0.10.2"
20
20
  gem "quickl", "~> 0.4.1"
21
- gem "highline", "~> 1.6.0"
21
+ gem "highline", "~> 1.6"
22
+ gem "epath", "~> 0.1.1"
22
23
  end
@@ -3,29 +3,31 @@ GEM
3
3
  specs:
4
4
  bluecloth (2.2.0)
5
5
  diff-lcs (1.1.3)
6
- highline (1.6.2)
7
- quickl (0.4.1)
6
+ epath (0.1.1)
7
+ highline (1.6.11)
8
+ quickl (0.4.3)
8
9
  rake (0.9.2.2)
9
- rspec (2.7.0)
10
- rspec-core (~> 2.7.0)
11
- rspec-expectations (~> 2.7.0)
12
- rspec-mocks (~> 2.7.0)
13
- rspec-core (2.7.1)
14
- rspec-expectations (2.7.0)
15
- diff-lcs (~> 1.1.2)
16
- rspec-mocks (2.7.0)
10
+ rspec (2.9.0)
11
+ rspec-core (~> 2.9.0)
12
+ rspec-expectations (~> 2.9.0)
13
+ rspec-mocks (~> 2.9.0)
14
+ rspec-core (2.9.0)
15
+ rspec-expectations (2.9.1)
16
+ diff-lcs (~> 1.1.3)
17
+ rspec-mocks (2.9.0)
17
18
  wlang (0.10.2)
18
- yard (0.7.2)
19
+ yard (0.7.5)
19
20
 
20
21
  PLATFORMS
21
22
  java
22
23
  ruby
23
24
 
24
25
  DEPENDENCIES
25
- bluecloth (~> 2.2.0)
26
- highline (~> 1.6.0)
26
+ bluecloth (~> 2.2)
27
+ epath (~> 0.1.1)
28
+ highline (~> 1.6)
27
29
  quickl (~> 0.4.1)
28
30
  rake (~> 0.9.2)
29
- rspec (~> 2.7.0)
31
+ rspec (~> 2.9)
30
32
  wlang (~> 0.10.2)
31
33
  yard (~> 0.7.2)
data/Rakefile CHANGED
@@ -1,7 +1,3 @@
1
- # Dynamically load the gem spec
2
- $gemspec_file = File.expand_path('../noe.gemspec', __FILE__)
3
- $gemspec = Kernel.eval(File.read($gemspec_file))
4
-
5
1
  # We run tests by default
6
2
  task :default => :test
7
3
 
data/lib/noe.rb CHANGED
@@ -6,7 +6,6 @@ end # module Noe
6
6
  require 'noe/version'
7
7
  require 'noe/loader'
8
8
  require 'yaml'
9
- require 'fileutils'
10
9
  require 'noe/ext/array'
11
10
  require 'noe/ext/hash'
12
11
  require 'noe/config'
@@ -4,7 +4,7 @@ module Noe
4
4
  # Install options
5
5
  def self.add_common_options(opt)
6
6
  opt.on_tail("--version", "Show version") do
7
- raise Quickl::Exit, "#{File.basename($0 || 'noe')} #{Noe::VERSION} (c) 2011, Bernard Lambeau"
7
+ raise Quickl::Exit, "noe #{Noe::VERSION} (c) 2011, Bernard Lambeau"
8
8
  end
9
9
  opt.on_tail('--help', "Show detailed help") do
10
10
  raise Quickl::Help
@@ -21,15 +21,15 @@ module Noe
21
21
  end
22
22
 
23
23
  def template(name = config.default)
24
- Template.new(File.join(templates_dir, name))
24
+ Template.new(templates_dir/name)
25
25
  end
26
26
 
27
27
  def find_noespec_file(args)
28
28
  # Find spec file
29
29
  spec_file = if args.size == 1
30
- Quickl.valid_read_file!(args.first)
30
+ Path(Quickl.valid_read_file!(args.first))
31
31
  else
32
- spec_files = Dir['*.noespec']
32
+ spec_files = Path.glob('*.noespec')
33
33
  if spec_files.size > 1
34
34
  raise Noe::Error, "Ambiguous request, multiple specs: #{spec_files.join(', ')}"
35
35
  end
@@ -2,10 +2,10 @@ module Noe
2
2
  class Config
3
3
 
4
4
  # Path to the default configuration file
5
- DEFAULT_CONFIG_FILE = File.expand_path('../default.yaml', __FILE__)
5
+ DEFAULT_CONFIG_FILE = Path.relative('default.yaml')
6
6
 
7
7
  # Default configuration hash
8
- DEFAULT_CONFIG = YAML::load(File.read(DEFAULT_CONFIG_FILE)).merge(
8
+ DEFAULT_CONFIG = DEFAULT_CONFIG_FILE.load.merge(
9
9
  'config_file' => DEFAULT_CONFIG_FILE,
10
10
  'version' => Noe::VERSION)
11
11
 
@@ -22,7 +22,7 @@ module Noe
22
22
  case arg
23
23
  when Hash
24
24
  super
25
- when String
25
+ when Path
26
26
  __load_from_file(arg)
27
27
  when NilClass
28
28
  super(DEFAULT_CONFIG)
@@ -34,13 +34,13 @@ module Noe
34
34
  # Loads configuration from YAML file
35
35
  def self.__load_from_file(file)
36
36
  # check loaded file
37
- file = File.expand_path(file)
38
- unless File.file?(file) and File.readable?(file)
37
+ file = file.expand
38
+ unless file.file? and file.readable?
39
39
  raise Noe::Error, "Not a file or not readable: #{file}"
40
40
  end
41
41
 
42
42
  # load YAML
43
- loaded = YAML::load(File.read(file))
43
+ loaded = YAML::load(file.read)
44
44
  unless loaded.is_a?(Hash)
45
45
  raise Noe::Error, "Corrupted or invalid config file: #{file}"
46
46
  end
@@ -50,8 +50,8 @@ module Noe
50
50
  config = Config.new(config_hash)
51
51
 
52
52
  # Some sanity check
53
- templates_dir = config.templates_dir
54
- unless File.directory?(templates_dir) and File.readable?(templates_dir)
53
+ templates_dir = Path(config.templates_dir)
54
+ unless templates_dir.dir? and templates_dir.readable?
55
55
  raise Noe::Error, "Invalid noe config, not a directory or unreadable: #{templates_dir}"
56
56
  end
57
57
 
@@ -66,7 +66,7 @@ module Noe
66
66
  # Returns folder where templates are located. Always returns an
67
67
  # absolute path.
68
68
  def templates_dir
69
- @templates_dir ||= File.expand_path(config['templates-dir'], File.dirname(file))
69
+ @templates_dir ||= Path(config['templates-dir']).expand(file.dir)
70
70
  end
71
71
 
72
72
  # Returns expected noe's version
@@ -127,8 +127,8 @@ module Noe
127
127
 
128
128
  # Checks if one is a file and the other a directory or the inverse
129
129
  def kind_clash?(entry, relocated)
130
- (entry.file? and File.directory?(relocated)) or
131
- (entry.directory? and File.file?(relocated))
130
+ (entry.file? and relocated.directory?) or
131
+ (entry.directory? and relocated.file?)
132
132
  end
133
133
 
134
134
  def build_one_directory(entry, variables)
@@ -137,7 +137,7 @@ module Noe
137
137
  todo = []
138
138
 
139
139
  skipped = false
140
- if File.exists?(relocated)
140
+ if relocated.exists?
141
141
  # file exists already exists, check what can be done!
142
142
  if kind_clash?(entry, relocated)
143
143
  if interactive?
@@ -175,7 +175,7 @@ module Noe
175
175
  todo = []
176
176
 
177
177
  skipped = false
178
- if File.exists?(relocated)
178
+ if relocated.exists?
179
179
  # name clash, the file exists
180
180
  if adds_only?
181
181
  # file exists and we are only allowed to add new things
@@ -227,7 +227,7 @@ module Noe
227
227
 
228
228
  # Load spec now
229
229
  spec_file = find_noespec_file(args)
230
- spec = YAML::load(File.read(spec_file))
230
+ spec = YAML::load(spec_file.read)
231
231
  template = template(spec['template-info']['name'])
232
232
  template.merge_spec(spec)
233
233
  variables = template.variables
@@ -272,7 +272,7 @@ module Noe
272
272
  class MkDir < DoSomething
273
273
 
274
274
  def run
275
- FileUtils.mkdir relocated
275
+ relocated.mkdir
276
276
  end
277
277
 
278
278
  def to_s
@@ -284,7 +284,7 @@ module Noe
284
284
  class Rm < DoSomething
285
285
 
286
286
  def run
287
- FileUtils.rm_rf relocated
287
+ relocated.rm_rf
288
288
  end
289
289
 
290
290
  def to_s
@@ -296,11 +296,11 @@ module Noe
296
296
  class FileInstantiate < DoSomething
297
297
 
298
298
  def run
299
- File.open(relocated, 'w') do |out|
299
+ relocated.open('w') do |out|
300
300
  dialect = entry.wlang_dialect
301
301
  braces = entry.wlang_braces
302
302
  variables.methodize!
303
- out << WLang::file_instantiate(entry.realpath, variables, dialect, braces)
303
+ out << WLang::file_instantiate(entry.realpath.to_s, variables, dialect, braces)
304
304
  end
305
305
  end
306
306
 
@@ -1,4 +1,3 @@
1
- require 'fileutils'
2
1
  module Noe
3
2
  class Main
4
3
  #
@@ -43,39 +42,37 @@ module Noe
43
42
  if args.size > 1
44
43
  raise Quickl::InvalidArgument, "Needless arguments: #{args[1..-1].join(' ')}"
45
44
  end
46
- folder = args.first || ENV['HOME']
45
+ folder = Path(args.first || Path.home)
47
46
 
48
- noerc_file = File.join(folder, '.noerc')
49
- noe_folder = File.join(folder, '.noe')
47
+ noerc_file = folder/'.noerc'
48
+ noe_folder = folder/'.noe'
50
49
 
51
50
  # generate .noerc
52
- if File.exists?(noerc_file) and not(force)
51
+ if noerc_file.exists? and not(force)
53
52
  raise Noe::Error, "#{noerc_file} already exists, use --force to override"
54
53
  end
55
- File.open(noerc_file, 'w') do |out|
56
- def_config = File.join(File.dirname(__FILE__), 'config.yaml')
57
- context = { :templates_dir => noe_folder }
54
+ noerc_file.open('w') do |out|
55
+ def_config = Path.relative('config.yaml').to_s
56
+ context = { :templates_dir => noe_folder.to_s }
58
57
  out << WLang::file_instantiate(def_config, context, 'wlang/active-string')
59
58
  end
60
59
 
61
60
  # generate .noe folder
62
- unless File.exists?(noe_folder)
63
- FileUtils.mkdir(noe_folder)
64
- end
61
+ noe_folder.mkdir unless noe_folder.exists?
65
62
 
66
63
  # copy default templates
67
- tdir = File.expand_path('../../../templates', __FILE__)
68
- Dir[File.join(tdir, '*')].each do |tpl|
69
- target = File.join(noe_folder, File.basename(tpl))
70
- if File.exists?(target)
71
- if force
72
- FileUtils.rm_rf target
64
+ tdir = Path.relative '../../templates'
65
+ tdir.each_child do |tpl|
66
+ target = noe_folder/tpl.basename
67
+ if target.exists?
68
+ if force
69
+ target.rm_rf
73
70
  else
74
71
  puts "#{target} already exists, use --force to override"
75
72
  next
76
73
  end
77
74
  end
78
- FileUtils.cp_r tpl, noe_folder
75
+ tpl.cp_r(noe_folder)
79
76
  end
80
77
 
81
78
  # say something!
@@ -29,7 +29,7 @@ module Noe
29
29
  raise Quickl::InvalidArgument, "Needless argument: #{args.join(', ')}"
30
30
  end
31
31
 
32
- tpls = Dir[File.join(templates_dir, '**')].collect{|tpldir| Template.new(tpldir)}
32
+ tpls = templates_dir.glob('**').map { |tpldir| Template.new(tpldir) }
33
33
  columns = [:name, :version, :layouts, :summary]
34
34
  data = [ columns ] + tpls.collect{|tpl|
35
35
  begin
@@ -1,3 +1,4 @@
1
1
  require "wlang"
2
2
  require "quickl"
3
3
  require "highline"
4
+ require "epath"
@@ -38,8 +38,8 @@ module Noe
38
38
 
39
39
  # Finds the configuration file and loads automatically
40
40
  def find_config_file
41
- in_home = File.join(ENV['HOME'], '.noerc')
42
- File.file?(in_home) ? in_home : nil
41
+ in_home = Path.home/'.noerc'
42
+ in_home if in_home.file?
43
43
  end
44
44
 
45
45
  # Install options
@@ -47,7 +47,7 @@ module Noe
47
47
  # Set a specific configuration file to use
48
48
  opt.on('--config=FILE',
49
49
  'Use a specific config file (defaults to ~/.noerc)') do |f|
50
- @config_file = Quickl.valid_read_file!(f)
50
+ @config_file = Path(Quickl.valid_read_file!(f))
51
51
  end
52
52
  # Show backtrace on error
53
53
  opt.on_tail("--backtrace",
@@ -1,4 +1,3 @@
1
- require 'fileutils'
2
1
  module Noe
3
2
  class Main
4
3
  #
@@ -85,13 +84,16 @@ module Noe
85
84
  end
86
85
 
87
86
  def generate_noespec_file(where)
88
- if File.exists?(where) and not(force)
87
+ if where.exists? and not(force)
89
88
  raise Noe::Error, "File #{where} already exists, remove it first or set --force."
90
89
  else
91
90
  tpl = template
92
- File.open(where, 'w') do |out|
93
- context = {'template_name' => tpl.name}
94
- out << WLang::file_instantiate(tpl.spec_layout_file(@layout), context, "wlang/active-text")
91
+ unless (parent = where.parent).exists?
92
+ parent.mkdir_p
93
+ end
94
+ where.open('w') do |out|
95
+ context = {'template_name' => tpl.name.to_s}
96
+ out << WLang::file_instantiate(tpl.spec_layout_file(@layout).to_s, context, "wlang/active-text")
95
97
  end
96
98
  end
97
99
  where
@@ -101,12 +103,11 @@ module Noe
101
103
  pname, where = nil, nil
102
104
  case args.size
103
105
  when 0
104
- pname = File.basename(File.expand_path('.'))
105
- where = generate_noespec_file("#{pname}.noespec")
106
+ pname = Path.getwd.basename
107
+ where = generate_noespec_file(pname.add_ext(".noespec"))
106
108
  when 1
107
- pname = args.first
108
- FileUtils.mkdir(pname) unless File.exists?(pname)
109
- where = generate_noespec_file(File.join(pname, "#{pname}.noespec"))
109
+ pname = Path(args.first)
110
+ where = generate_noespec_file(pname/pname.add_ext(".noespec"))
110
111
  else
111
112
  raise Quickl::Help unless args.size > 1
112
113
  end
@@ -34,7 +34,7 @@ module Noe
34
34
  def execute(args)
35
35
  raise Quickl::Help if args.size > 1
36
36
  spec_file = find_noespec_file(args)
37
- spec = YAML::load(File.read(spec_file))
37
+ spec = YAML::load(spec_file.read)
38
38
  template = template(spec['template-info']['name'])
39
39
  template.merge_spec(spec)
40
40
  puts template.to_yaml
@@ -16,32 +16,32 @@ module Noe
16
16
 
17
17
  # Loads the template from its folder
18
18
  def __load
19
- if File.file?(spec_file) and File.readable?(spec_file)
20
- @spec = YAML::load(File.read(spec_file))
19
+ if spec_file.file? and spec_file.readable?
20
+ @spec = YAML::load(spec_file.read)
21
21
  else
22
22
  raise Noe::Error, "Unable to find template: #{spec_file}"
23
23
  end
24
24
  end
25
25
 
26
26
  def spec_layout_file(layout = 'noespec')
27
- file = File.join(folder, "#{layout}.yaml")
28
- if File.exists?(file)
27
+ file = folder/"#{layout}.yaml"
28
+ if file.exists?
29
29
  file
30
30
  else
31
- puts "On #{file}"
32
- raise Noe::Error, "Unknown specification layout: #{layout}, try 'noe list'"
31
+ $stderr.puts "Config file: #{file}"
32
+ raise Noe::Error, "No such file or directory: #{file}, try 'noe list'"
33
33
  end
34
34
  end
35
35
  alias :spec_file :spec_layout_file
36
36
 
37
37
  # Returns an array with available layout names
38
38
  def layouts
39
- Dir[File.join(folder, '*.yaml')].collect{|f| File.basename(f, '.yaml')}
39
+ folder.glob('*.yaml').map { |file| file.base.to_s }
40
40
  end
41
41
 
42
42
  # Merges another spec file inside this template
43
43
  def merge_spec_file(file)
44
- merge_spec YAML::load(File.read(spec_file))
44
+ merge_spec YAML::load(spec_file.read)
45
45
  end
46
46
 
47
47
  # Merges template spec with another spec given from a Hash
@@ -51,7 +51,7 @@ module Noe
51
51
 
52
52
  # Returns template name
53
53
  def name
54
- File.basename(folder)
54
+ folder.basename
55
55
  end
56
56
 
57
57
  # Returns template summary
@@ -80,23 +80,18 @@ module Noe
80
80
 
81
81
  # Returns path to the sources folder
82
82
  def src_folder
83
- File.join(folder, "src")
84
- end
85
-
86
- # Ignore some file?
87
- def ignore?(file)
88
- ['.', '..'].include? File.basename(file)
83
+ folder/"src"
89
84
  end
90
85
 
91
86
  # Returns an entry for a given relative path
92
87
  def entry(*paths)
93
- Entry.new(self, paths.join(File::PATH_SEPARATOR))
88
+ Entry.new(self, paths.join(File::SEPARATOR))
94
89
  end
95
90
 
96
91
  # Returns manifest Hash for a given entry
97
92
  def manifest_for(entry)
98
93
  manifest = spec['template-info']['manifest'] || {}
99
- manifest[entry.path] || {
94
+ manifest[entry.path.to_s] || {
100
95
  'description' => "No description for #{entry.path}",
101
96
  'safe-override' => false
102
97
  }
@@ -110,11 +105,9 @@ module Noe
110
105
  entry = Entry.new(self, nil)
111
106
  end
112
107
  if entry.directory?
113
- Dir.foreach(entry.realpath) do |child|
108
+ entry.realpath.each_child(false) do |child|
114
109
  childentry = entry.child_entry(child)
115
- unless ignore?(childentry.realpath)
116
- visit(childentry, &block)
117
- end
110
+ visit(childentry, &block)
118
111
  end
119
112
  end
120
113
  end
@@ -139,31 +132,30 @@ module Noe
139
132
  # Creates an entry instance
140
133
  def initialize(template, path)
141
134
  @template = template
142
- @path = path
135
+ @path = Path(path)
143
136
  end
144
137
 
145
138
  # Returns real absolute path of the entry
146
139
  def realpath
147
- path.nil? ? template.src_folder : File.join(template.src_folder, path)
140
+ template.src_folder/path
148
141
  end
149
142
 
150
143
  # Returns entry name
151
144
  def name
152
- File.basename(realpath)
145
+ realpath.basename
153
146
  end
154
147
 
155
148
  # Relocate the path according to variables
156
149
  def relocate(variables = template.variables)
157
- path.split(File::PATH_SEPARATOR).
158
- collect{|v| rename_one(variables, v)}.
159
- join(File::PATH_SEPARATOR)
150
+ # path must be relative (or the initial / might be lost)
151
+ Path(*path.each_filename.map { |v| rename_one(variables, v) })
160
152
  end
161
153
 
162
154
  # Returns the target name, according to some variables
163
155
  def rename_one(variables, name = self.name)
164
- if name =~ /__([a-z]+)__/
156
+ if name.to_s =~ /__([a-z]+)__/
165
157
  if x = variables[$1]
166
- name.gsub(/__([a-z]+)__/, x)
158
+ Path(name.to_s.gsub(/__([a-z]+)__/, x))
167
159
  else
168
160
  raise Noe::Error, "Missing variable #{$1}"
169
161
  end
@@ -174,17 +166,17 @@ module Noe
174
166
 
175
167
  # Is the entry a file?
176
168
  def file?
177
- File.file?(realpath)
169
+ realpath.file?
178
170
  end
179
171
 
180
172
  # Is the entry a directory?
181
173
  def directory?
182
- File.directory?(realpath)
174
+ realpath.directory?
183
175
  end
184
176
 
185
177
  # Builds an child entry for a given name
186
178
  def child_entry(name)
187
- template.entry(path.nil? ? name : File.join(path, name))
179
+ template.entry(path/name)
188
180
  end
189
181
 
190
182
  # Returns the hash with the manifest for this entry
@@ -202,7 +194,7 @@ module Noe
202
194
 
203
195
  # Infers the wlang dialect to use for the entry
204
196
  def self.infer_wlang_dialect(uri, default = nil)
205
- res = case d = WLang::infer_dialect(uri)
197
+ res = case d = WLang::infer_dialect(uri.to_s)
206
198
  when nil
207
199
  nil
208
200
  when /^wlang/
@@ -3,7 +3,7 @@ module Noe
3
3
 
4
4
  MAJOR = 1
5
5
  MINOR = 7
6
- TINY = 3
6
+ TINY = 4
7
7
 
8
8
  def self.to_s
9
9
  [ MAJOR, MINOR, TINY ].join('.')
@@ -124,12 +124,13 @@ Gem::Specification.new do |s|
124
124
  # for each development dependency. These gems are required for developers
125
125
  #
126
126
  s.add_development_dependency("rake", "~> 0.9.2")
127
- s.add_development_dependency("rspec", "~> 2.7.0")
127
+ s.add_development_dependency("rspec", "~> 2.9")
128
128
  s.add_development_dependency("yard", "~> 0.7.2")
129
- s.add_development_dependency("bluecloth", "~> 2.2.0")
129
+ s.add_development_dependency("bluecloth", "~> 2.2")
130
130
  s.add_dependency("wlang", "~> 0.10.2")
131
131
  s.add_dependency("quickl", "~> 0.4.1")
132
- s.add_dependency("highline", "~> 1.6.0")
132
+ s.add_dependency("highline", "~> 1.6")
133
+ s.add_dependency("epath", "~> 0.1.1")
133
134
 
134
135
  # The version of ruby required by this gem
135
136
  #
@@ -10,7 +10,7 @@ template-info:
10
10
  variables:
11
11
  lower: noe
12
12
  upper: Noe
13
- version: 1.7.3
13
+ version: 1.7.4
14
14
  summary:
15
15
  Noe is a simple, general-purpose and extensible skeleton generator from project templates
16
16
  description:
@@ -28,12 +28,13 @@ variables:
28
28
  - http://revision-zero.org/noe
29
29
  dependencies:
30
30
  - {name: rake, version: "~> 0.9.2", groups: [test, release]}
31
- - {name: rspec, version: "~> 2.7.0", groups: [test, release]}
31
+ - {name: rspec, version: "~> 2.9", groups: [test, release]}
32
32
  - {name: yard, version: "~> 0.7.2", groups: [doc ]}
33
- - {name: bluecloth, version: "~> 2.2.0", groups: [doc ]}
33
+ - {name: bluecloth, version: "~> 2.2", groups: [doc ]}
34
34
  - {name: wlang, version: "~> 0.10.2", groups: [runtime ]}
35
35
  - {name: quickl, version: "~> 0.4.1", groups: [runtime ]}
36
- - {name: highline, version: "~> 1.6.0", groups: [runtime ]}
36
+ - {name: highline, version: "~> 1.6", groups: [runtime ]}
37
+ - {name: epath, version: "~> 0.1.1", groups: [runtime ]}
37
38
  rake_tasks:
38
39
  spec_test:
39
40
  pattern: spec/**/*_spec.rb
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
  describe 'noe go' do
3
3
 
4
4
  let(:go){ Noe::Main::Go.new }
@@ -1,18 +1,18 @@
1
- require File.expand_path('../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
  describe 'line endings and trailing spaces' do
3
3
  it 'all files should end with a single \n and have no trailing spaces' do
4
4
  begin
5
- dir = File.expand_path('../../fixtures', __FILE__)
6
- project_dir = dir + '/test'
7
- Dir.chdir(dir) do
5
+ dir = Path.relative '../fixtures'
6
+ project_dir = dir / 'test'
7
+ dir.chdir do
8
8
  Noe::Main.run(%w{prepare --silent test})
9
9
  end
10
- Dir.chdir(project_dir) do
11
- FileUtils.cp dir+'/test.noespec', project_dir
10
+ project_dir.chdir do
11
+ (dir/'test.noespec').cp(project_dir)
12
12
  Noe::Main.run(['go'])
13
- Dir["**/*"].each { |file|
14
- if File.file?(file) and File.size(file) > 0
15
- contents = File.read(file)
13
+ Path.glob("**/*") { |file|
14
+ if file.file? and !file.empty?
15
+ contents = file.read
16
16
  tail = contents[-3..-1]
17
17
  contents.each_line.with_index { |line, i|
18
18
  line.should match(/(?:^|\S)$/),
@@ -24,7 +24,7 @@ describe 'line endings and trailing spaces' do
24
24
  }
25
25
  end
26
26
  ensure
27
- FileUtils.rm_r(project_dir) if File.exist? project_dir
27
+ project_dir.rm_r if project_dir.exist?
28
28
  end
29
29
  end
30
30
  end
@@ -1,3 +1,3 @@
1
- $noe_root = File.expand_path('../../../', __FILE__)
2
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
2
  require 'noe'
3
+ $noe_root = Path.dir.parent
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
  module Noe
3
3
  describe "Config.new" do
4
4
 
@@ -14,7 +14,7 @@ module Noe
14
14
  end # without argument
15
15
 
16
16
  context 'with a hash' do
17
- let(:hash){ {'config_file' => File.expand_path("../config1.yaml", __FILE__)} }
17
+ let(:hash){ {'config_file' => Path.relative("config1.yaml")} }
18
18
  subject{ Config.new(hash) }
19
19
 
20
20
  it 'should create a configuration instance' do
@@ -30,14 +30,14 @@ module Noe
30
30
  context 'with an invalid file' do
31
31
 
32
32
  it 'should raise a Noe::Error' do
33
- file = File.expand_path("../unexistsing.yaml", __FILE__)
33
+ file = Path.relative("unexistsing.yaml")
34
34
  lambda{ Config.new(file) }.should raise_error(Noe::Error)
35
35
  end
36
36
 
37
37
  end # with an invalid file
38
38
 
39
39
  context 'with an valid file' do
40
- let(:file){ File.expand_path("../config1.yaml", __FILE__) }
40
+ let(:file){ Path.relative("config1.yaml") }
41
41
  subject{ Config.new(file) }
42
42
 
43
43
  it 'should create a valid configuration' do
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
  module Noe
3
3
  describe "Config#templates_dir" do
4
4
 
@@ -8,24 +8,24 @@ module Noe
8
8
  let(:config){ Config.new }
9
9
 
10
10
  it "should be Noe's template dir" do
11
- subject.should == File.join($noe_root, "templates")
11
+ subject.should == $noe_root/"templates"
12
12
  end
13
13
 
14
14
  end # on default config
15
15
 
16
16
  context 'when a relative path is used' do
17
- let(:file) { File.expand_path("../config1.yaml", __FILE__) }
17
+ let(:file) { Path.relative("config1.yaml") }
18
18
  let(:config){ Config.new(file) }
19
19
 
20
20
  it "should be an absolute path" do
21
- subject.should == File.expand_path("../templates", __FILE__)
21
+ subject.should == Path.relative("templates")
22
22
  end
23
23
 
24
24
  end # relative path
25
25
 
26
26
  context 'when an absolute path is used' do
27
- let(:file) { File.expand_path("../config1.yaml", __FILE__) }
28
- let(:tdir) { File.expand_path("../templates", __FILE__) }
27
+ let(:file) { Path.relative("config1.yaml") }
28
+ let(:tdir) { Path.relative("templates") }
29
29
  let(:hash) { { "config_file" => file, "templates-dir" => tdir } }
30
30
  let(:config){ Config.new(hash) }
31
31
 
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
  module Noe
3
3
  describe "Hash#methodize!" do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
  module Noe
3
3
  describe "Hash#noe_merge" do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path('../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
  describe Noe do
3
3
 
4
4
  it "should have a version number" do
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
  module Noe
3
3
  describe "Template::Entry#infer_wlang_dialect" do
4
4
 
@@ -1,9 +1,9 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
  module Noe
3
3
  describe "Template::Entry#relocate" do
4
4
 
5
5
  let(:template){
6
- Template.new(File.expand_path('../../../../../templates/ruby', __FILE__))
6
+ Template.new(Path.relative('../../../../templates/ruby'))
7
7
  }
8
8
  let(:vars){
9
9
  {"lower" => "project"}
@@ -14,27 +14,27 @@ module Noe
14
14
 
15
15
  describe "when nothing has to change" do
16
16
  let(:entry){ template.entry('.gitignore') }
17
- it{ should == ".gitignore" }
17
+ it{ should == Path(".gitignore") }
18
18
  end
19
19
 
20
20
  describe "when exactly a replacement" do
21
21
  let(:entry){ template.entry("__lower__") }
22
- it { should == "project" }
22
+ it { should == Path("project") }
23
23
  end
24
24
 
25
25
  describe "when a replacement inside something else" do
26
26
  let(:entry){ template.entry("__lower___spec.rb") }
27
- it { should == "project_spec.rb" }
27
+ it { should == Path("project_spec.rb") }
28
28
  end
29
29
 
30
30
  describe "when no replace and sub file" do
31
31
  let(:entry){ template.entry("lib", "README.md") }
32
- it { should == ["lib", "README.md"].join(File::PATH_SEPARATOR) }
32
+ it { should == Path("lib/README.md") }
33
33
  end
34
34
 
35
35
  describe "when no replace and sub file with replacement" do
36
36
  let(:entry){ template.entry("lib", "__lower__.rb") }
37
- it { should == ["lib", "project.rb"].join(File::PATH_SEPARATOR) }
37
+ it { should == Path("lib/project.rb") }
38
38
  end
39
39
 
40
40
  end
@@ -1,9 +1,9 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
  module Noe
3
3
  describe "Template::Entry#rename_one" do
4
4
 
5
5
  let(:template){
6
- Template.new(File.expand_path('../../../../../templates/ruby', __FILE__))
6
+ Template.new(Path.relative('../../../../templates/ruby'))
7
7
  }
8
8
  let(:vars){
9
9
  {"lower" => "project"}
@@ -14,17 +14,17 @@ module Noe
14
14
 
15
15
  describe "when nothing has to change" do
16
16
  let(:entry){ template.entry("project") }
17
- it { should == "project" }
17
+ it { should == Path("project") }
18
18
  end
19
19
 
20
20
  describe "when exactly a replacement" do
21
21
  let(:entry){ template.entry("__lower__") }
22
- it { should == "project" }
22
+ it { should == Path("project") }
23
23
  end
24
24
 
25
25
  describe "when a replacement inside something else" do
26
26
  let(:entry){ template.entry("__lower___spec.rb") }
27
- it { should == "project_spec.rb" }
27
+ it { should == Path("project_spec.rb") }
28
28
  end
29
29
 
30
30
  end
@@ -25,13 +25,18 @@
25
25
  #
26
26
  begin
27
27
  require 'rubygems/package_task'
28
- Gem::PackageTask.new($gemspec) do |t|
28
+
29
+ # Dynamically load the gem spec
30
+ gemspec_file = File.expand_path('../../noe.gemspec', __FILE__)
31
+ gemspec = Kernel.eval(File.read(gemspec_file))
32
+
33
+ Gem::PackageTask.new(gemspec) do |t|
29
34
 
30
35
  # Name of the package
31
- t.name = $gemspec.name
36
+ t.name = gemspec.name
32
37
 
33
38
  # Version of the package
34
- t.version = $gemspec.version
39
+ t.version = gemspec.version
35
40
 
36
41
  # Directory used to store the package files
37
42
  t.package_dir = "pkg"
@@ -49,7 +54,7 @@ begin
49
54
  t.need_zip = false
50
55
 
51
56
  # List of files to be included in the package.
52
- t.package_files = $gemspec.files
57
+ t.package_files = gemspec.files
53
58
 
54
59
  # Tar command for gzipped or bzip2ed archives.
55
60
  t.tar_command = "tar"
@@ -1,7 +1,3 @@
1
- # Dynamically load the gem spec
2
- $gemspec_file = File.expand_path('../!{lower}.gemspec', __FILE__)
3
- $gemspec = Kernel.eval(File.read($gemspec_file))
4
-
5
1
  # We run tests by default
6
2
  task :default => :test
7
3
 
@@ -1,4 +1,4 @@
1
- require File.expand_path('../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
  describe !{upper} do
3
3
 
4
4
  it "should have a version number" do
@@ -25,13 +25,18 @@
25
25
  #
26
26
  begin
27
27
  require 'rubygems/package_task'
28
- Gem::PackageTask.new($gemspec) do |t|
28
+
29
+ # Dynamically load the gem spec
30
+ gemspec_file = File.expand_path('../../!{lower}.gemspec', __FILE__)
31
+ gemspec = Kernel.eval(File.read(gemspec_file))
32
+
33
+ Gem::PackageTask.new(gemspec) do |t|
29
34
 
30
35
  # Name of the package
31
- t.name = $gemspec.name
36
+ t.name = gemspec.name
32
37
 
33
38
  # Version of the package
34
- t.version = $gemspec.version
39
+ t.version = gemspec.version
35
40
 
36
41
  # Directory used to store the package files
37
42
  t.package_dir = +{rake_tasks.gem.package_dir}
@@ -49,7 +54,7 @@ begin
49
54
  t.need_zip = +{rake_tasks.gem.need_zip}
50
55
 
51
56
  # List of files to be included in the package.
52
- t.package_files = $gemspec.files
57
+ t.package_files = gemspec.files
53
58
 
54
59
  # Tar command for gzipped or bzip2ed archives.
55
60
  t.tar_command = +{rake_tasks.gem.tar_command}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.3
4
+ version: 1.7.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-25 00:00:00.000000000Z
12
+ date: 2012-04-26 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70417630 !ruby/object:Gem::Requirement
16
+ requirement: &70144303386380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: 0.9.2
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70417630
24
+ version_requirements: *70144303386380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70417350 !ruby/object:Gem::Requirement
27
+ requirement: &70144303385840 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 2.7.0
32
+ version: '2.9'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70417350
35
+ version_requirements: *70144303385840
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yard
38
- requirement: &70417050 !ruby/object:Gem::Requirement
38
+ requirement: &70144303367700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,21 +43,21 @@ dependencies:
43
43
  version: 0.7.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70417050
46
+ version_requirements: *70144303367700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bluecloth
49
- requirement: &70416770 !ruby/object:Gem::Requirement
49
+ requirement: &70144303367020 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 2.2.0
54
+ version: '2.2'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70416770
57
+ version_requirements: *70144303367020
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: wlang
60
- requirement: &70416520 !ruby/object:Gem::Requirement
60
+ requirement: &70144303366320 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.10.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70416520
68
+ version_requirements: *70144303366320
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: quickl
71
- requirement: &70416220 !ruby/object:Gem::Requirement
71
+ requirement: &70144303365540 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,18 +76,29 @@ dependencies:
76
76
  version: 0.4.1
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70416220
79
+ version_requirements: *70144303365540
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: highline
82
- requirement: &70415950 !ruby/object:Gem::Requirement
82
+ requirement: &70144303364940 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
86
86
  - !ruby/object:Gem::Version
87
- version: 1.6.0
87
+ version: '1.6'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70415950
90
+ version_requirements: *70144303364940
91
+ - !ruby/object:Gem::Dependency
92
+ name: epath
93
+ requirement: &70144303364260 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 0.1.1
99
+ type: :runtime
100
+ prerelease: false
101
+ version_requirements: *70144303364260
91
102
  description: Noe is a tool that generates project skeletons from predefined templates.
92
103
  A template is designed for a specific product (a ruby library, a static or dynamic
93
104
  web site, ...). Noe instantiates templates and helps you maintaining your product
@@ -109,21 +120,21 @@ files:
109
120
  - CHANGELOG.md
110
121
  - Gemfile
111
122
  - Gemfile.lock
112
- - lib/noe/help.rb
113
- - lib/noe/prepare.rb
114
- - lib/noe/go.rb
115
- - lib/noe/show_spec.rb
116
- - lib/noe/main.rb
117
- - lib/noe/template.rb
118
123
  - lib/noe/commons.rb
119
- - lib/noe/list.rb
120
- - lib/noe/install.rb
121
124
  - lib/noe/config.rb
122
- - lib/noe/loader.rb
125
+ - lib/noe/config.yaml
123
126
  - lib/noe/default.yaml
124
- - lib/noe/ext/hash.rb
125
127
  - lib/noe/ext/array.rb
126
- - lib/noe/config.yaml
128
+ - lib/noe/ext/hash.rb
129
+ - lib/noe/go.rb
130
+ - lib/noe/help.rb
131
+ - lib/noe/install.rb
132
+ - lib/noe/list.rb
133
+ - lib/noe/loader.rb
134
+ - lib/noe/main.rb
135
+ - lib/noe/prepare.rb
136
+ - lib/noe/show_spec.rb
137
+ - lib/noe/template.rb
127
138
  - lib/noe/version.rb
128
139
  - lib/noe.rb
129
140
  - LICENCE.md
@@ -132,52 +143,51 @@ files:
132
143
  - noe.noespec
133
144
  - Rakefile
134
145
  - README.md
135
- - spec/integration/spec_helper.rb
136
- - spec/integration/spaces_spec.rb
137
- - spec/integration/go/go_spec.rb
146
+ - spec/fixtures/test.noespec
147
+ - spec/fixtures/typitpl/noespec.yaml
148
+ - spec/fixtures/typitpl/src/README.txt
138
149
  - spec/integration/go/after_prepare/after_prepare.noespec
139
150
  - spec/integration/go/after_prepare/README.md
140
- - spec/unit/spec_helper.rb
141
- - spec/unit/template/entry/rename_one_spec.rb
142
- - spec/unit/template/entry/relocate_spec.rb
143
- - spec/unit/template/entry/infer_wlang_dialect_spec.rb
151
+ - spec/integration/go/go_spec.rb
152
+ - spec/integration/spaces_spec.rb
153
+ - spec/spec_helper.rb
144
154
  - spec/unit/config/config1.yaml
145
155
  - spec/unit/config/new_spec.rb
146
156
  - spec/unit/config/templates_dir_spec.rb
147
- - spec/unit/noe_spec.rb
148
- - spec/unit/ext/hash/noe_merge_spec.rb
149
157
  - spec/unit/ext/hash/methodize_spec.rb
150
- - spec/fixtures/typitpl/noespec.yaml
151
- - spec/fixtures/typitpl/src/README.txt
152
- - spec/fixtures/test.noespec
158
+ - spec/unit/ext/hash/noe_merge_spec.rb
159
+ - spec/unit/noe_spec.rb
160
+ - spec/unit/template/entry/infer_wlang_dialect_spec.rb
161
+ - spec/unit/template/entry/relocate_spec.rb
162
+ - spec/unit/template/entry/rename_one_spec.rb
153
163
  - tasks/debug_mail.rake
154
- - tasks/yard.rake
164
+ - tasks/debug_mail.txt
155
165
  - tasks/gem.rake
156
166
  - tasks/spec_test.rake
157
167
  - tasks/unit_test.rake
158
- - tasks/debug_mail.txt
159
- - templates/ruby/noespec.yaml
168
+ - tasks/yard.rake
160
169
  - templates/ruby/CHANGELOG.md
170
+ - templates/ruby/noespec.yaml
161
171
  - templates/ruby/README.md
162
- - templates/ruby/src/CHANGELOG.md
163
- - templates/ruby/src/README.md
164
- - templates/ruby/src/Manifest.txt
165
- - templates/ruby/src/Rakefile
172
+ - templates/ruby/short.yaml
166
173
  - templates/ruby/src/__lower__.gemspec
167
- - templates/ruby/src/lib/__lower__.rb
174
+ - templates/ruby/src/CHANGELOG.md
175
+ - templates/ruby/src/Gemfile
168
176
  - templates/ruby/src/lib/__lower__/loader.rb
169
177
  - templates/ruby/src/lib/__lower__/version.rb
178
+ - templates/ruby/src/lib/__lower__.rb
170
179
  - templates/ruby/src/LICENCE.md
180
+ - templates/ruby/src/Manifest.txt
181
+ - templates/ruby/src/Rakefile
182
+ - templates/ruby/src/README.md
171
183
  - templates/ruby/src/spec/spec_helper.rb
172
184
  - templates/ruby/src/spec/test___lower__.rb
173
185
  - templates/ruby/src/tasks/debug_mail.rake
174
- - templates/ruby/src/tasks/yard.rake
186
+ - templates/ruby/src/tasks/debug_mail.txt
175
187
  - templates/ruby/src/tasks/gem.rake
176
188
  - templates/ruby/src/tasks/spec_test.rake
177
189
  - templates/ruby/src/tasks/unit_test.rake
178
- - templates/ruby/src/tasks/debug_mail.txt
179
- - templates/ruby/src/Gemfile
180
- - templates/ruby/short.yaml
190
+ - templates/ruby/src/tasks/yard.rake
181
191
  - templates/ruby/src/.travis.yml
182
192
  - templates/ruby/src/.gitignore
183
193
  homepage: http://github.com/blambeau/noe
@@ -202,27 +212,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
212
  version: '0'
203
213
  requirements: []
204
214
  rubyforge_project:
205
- rubygems_version: 1.8.15
215
+ rubygems_version: 1.8.10
206
216
  signing_key:
207
217
  specification_version: 3
208
218
  summary: Noe is a simple, general-purpose and extensible skeleton generator from project
209
219
  templates
210
220
  test_files:
211
- - spec/integration/spec_helper.rb
212
- - spec/integration/spaces_spec.rb
213
- - spec/integration/go/go_spec.rb
221
+ - spec/fixtures/test.noespec
222
+ - spec/fixtures/typitpl/noespec.yaml
223
+ - spec/fixtures/typitpl/src/README.txt
214
224
  - spec/integration/go/after_prepare/after_prepare.noespec
215
225
  - spec/integration/go/after_prepare/README.md
216
- - spec/unit/spec_helper.rb
217
- - spec/unit/template/entry/rename_one_spec.rb
218
- - spec/unit/template/entry/relocate_spec.rb
219
- - spec/unit/template/entry/infer_wlang_dialect_spec.rb
226
+ - spec/integration/go/go_spec.rb
227
+ - spec/integration/spaces_spec.rb
228
+ - spec/spec_helper.rb
220
229
  - spec/unit/config/config1.yaml
221
230
  - spec/unit/config/new_spec.rb
222
231
  - spec/unit/config/templates_dir_spec.rb
223
- - spec/unit/noe_spec.rb
224
- - spec/unit/ext/hash/noe_merge_spec.rb
225
232
  - spec/unit/ext/hash/methodize_spec.rb
226
- - spec/fixtures/typitpl/noespec.yaml
227
- - spec/fixtures/typitpl/src/README.txt
228
- - spec/fixtures/test.noespec
233
+ - spec/unit/ext/hash/noe_merge_spec.rb
234
+ - spec/unit/noe_spec.rb
235
+ - spec/unit/template/entry/infer_wlang_dialect_spec.rb
236
+ - spec/unit/template/entry/relocate_spec.rb
237
+ - spec/unit/template/entry/rename_one_spec.rb
@@ -1,3 +0,0 @@
1
- $noe_root = File.expand_path('../../../', __FILE__)
2
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
- require 'noe'