yard 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yard might be problematic. Click here for more details.

data/ChangeLog CHANGED
@@ -1,5 +1,18 @@
1
+ 2009-12-16 Loren Segal <lsegal@soen.ca>
2
+
3
+ * ChangeLog, lib/yard.rb, yard.gemspec: Bump version to 0.5.2
4
+
5
+ * lib/yard/cli/yri.rb, lib/yard/core_ext/file.rb, lib/yard/registry_store.rb,
6
+ lib/yard/serializers/file_system_serializer.rb, spec/core_ext/file_spec.rb:
7
+ Ensure '~/.yard' path is created before writing certain config files. - Adds
8
+ File.open! to ensure path exists before writing file Closes gh-57
9
+
10
+ * lib/yard/registry_store.rb: Return true/false in RegistryStore#load!
11
+
1
12
  2009-12-15 Loren Segal <lsegal@soen.ca>
2
13
 
14
+ * docs/WhatsNew.md: Forgot to add version number for changes
15
+
3
16
  * ChangeLog, README.md, lib/yard.rb, yard.gemspec: Bump version to 0.5.1
4
17
 
5
18
  * docs/WhatsNew.md: Update What's New document
data/lib/yard.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module YARD
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  ROOT = File.dirname(__FILE__)
4
4
  TEMPLATE_ROOT = File.join(File.dirname(__FILE__), '..', 'templates')
5
5
  CONFIG_DIR = File.expand_path('~/.yard')
@@ -166,14 +166,14 @@ module YARD
166
166
  Gem.source_index.find_name('').each do |spec|
167
167
  reload = true
168
168
  dir = Registry.yardoc_file_for_gem(spec.name)
169
- next unless dir
170
- if File.directory?(dir) && !rebuild
169
+ if dir && File.directory?(dir) && !rebuild
171
170
  log.debug "#{spec.name} index already exists at '#{dir}'"
172
171
  else
173
- Dir.chdir(spec.full_gem_path)
174
- log.info "Building yardoc index for gem: #{spec.full_name}"
175
172
  yfile = Registry.yardoc_file_for_gem(spec.name, ">= 0", true)
173
+ next unless yfile
176
174
  Registry.clear
175
+ Dir.chdir(spec.full_gem_path)
176
+ log.info "Building yardoc index for gem: #{spec.full_name}"
177
177
  Yardoc.run('-n', '-b', yfile)
178
178
  reload = false
179
179
  end
data/lib/yard/cli/yri.rb CHANGED
@@ -42,7 +42,7 @@ module YARD
42
42
  return if path == Registry.yardoc_file
43
43
  @cache[name] = path
44
44
 
45
- File.open(CACHE_FILE, 'w') do |file|
45
+ File.open!(CACHE_FILE, 'w') do |file|
46
46
  @cache.each do |key, value|
47
47
  file.puts("#{key} #{value}")
48
48
  end
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  class File
2
4
  RELATIVE_PARENTDIR = '..'
3
5
  RELATIVE_SAMEDIR = '.'
@@ -40,4 +42,11 @@ class File
40
42
  end
41
43
  File.join(*path)
42
44
  end
45
+
46
+ # Forces opening a file (for writing) by first creating the file's directory
47
+ def self.open!(file, *args, &block)
48
+ dir = dirname(file)
49
+ FileUtils.mkdir_p(dir) unless directory?(dir)
50
+ open(file, *args, &block)
51
+ end
43
52
  end
@@ -94,8 +94,12 @@ module YARD
94
94
  # @return [Boolean] whether the database was loaded
95
95
  # @see #load_all
96
96
  def load!(file = nil)
97
- load(file)
98
- load_all
97
+ if load(file)
98
+ load_all
99
+ true
100
+ else
101
+ false
102
+ end
99
103
  end
100
104
 
101
105
  # Loads all cached objects into memory
@@ -220,11 +224,11 @@ module YARD
220
224
  end
221
225
 
222
226
  def write_proxy_types
223
- File.open(proxy_types_path, 'wb') {|f| f.write(Marshal.dump(@proxy_types)) }
227
+ File.open!(proxy_types_path, 'wb') {|f| f.write(Marshal.dump(@proxy_types)) }
224
228
  end
225
229
 
226
230
  def write_checksums
227
- File.open(checksums_path, 'w') do |f|
231
+ File.open!(checksums_path, 'w') do |f|
228
232
  @checksums.each {|k, v| f.puts("#{k} #{v}") }
229
233
  end
230
234
  end
@@ -1,5 +1,3 @@
1
- require 'fileutils'
2
-
3
1
  module YARD
4
2
  module Serializers
5
3
  class FileSystemSerializer < Base
@@ -28,9 +26,8 @@ module YARD
28
26
  # @return [String] the written data (for chaining)
29
27
  def serialize(object, data)
30
28
  path = File.join(basepath, *serialized_path(object))
31
- FileUtils.mkdir_p File.dirname(path)
32
29
  log.debug "Serializing to #{path}"
33
- File.open(path, "wb") {|f| f.write data }
30
+ File.open!(path, "wb") {|f| f.write data }
34
31
  end
35
32
 
36
33
  # Implements the serialized path of a code object.
@@ -45,4 +45,20 @@ describe File do
45
45
  File.cleanpath('C/../../D').should == "../D"
46
46
  end
47
47
  end
48
+
49
+ describe '.open!' do
50
+ it "should create the path before opening" do
51
+ File.should_receive(:directory?).with('/path/to').and_return(false)
52
+ FileUtils.should_receive(:mkdir_p).with('/path/to')
53
+ File.should_receive(:open).with('/path/to/file', 'w')
54
+ File.open!('/path/to/file', 'w')
55
+ end
56
+
57
+ it "should just open the file if the path exists" do
58
+ File.should_receive(:directory?).with('/path/to').and_return(true)
59
+ FileUtils.should_not_receive(:mkdir_p)
60
+ File.should_receive(:open).with('/path/to/file', 'w')
61
+ File.open!('/path/to/file', 'w')
62
+ end
63
+ end
48
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Segal
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-15 00:00:00 -05:00
12
+ date: 2009-12-16 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15