sdoc_all 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -43,6 +43,14 @@ carefully watch indent - 4 spaces for options
43
43
  ruby 1.8.6 source will be downloaded for you from ftp.ruby-lang.org and placed in folder sources
44
44
  - ruby: 1.8.6
45
45
 
46
+ to auto detect ruby version pass `ruby binary` instead of version (this binary will be asked to execute <tt>print "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"</tt>)
47
+ - ruby: `ruby`
48
+ or
49
+ - ruby: `/usr/bin/ruby`
50
+ or
51
+ - ruby: `/usr/bin/env ruby`
52
+
53
+
46
54
  if you don't want updates use this
47
55
  - ruby:
48
56
  version: 1.8.6
data/VERSION.yml CHANGED
@@ -1 +1 @@
1
- [1, 0, 1]
1
+ [1, 0, 2]
@@ -9,16 +9,26 @@ class SdocAll
9
9
 
10
10
  @config = {
11
11
  :update => raw_config.delete(:update) != false,
12
- :version => raw_config.delete(:version),
12
+ :version => raw_config.delete(:version).to_s,
13
13
  :index => raw_config.delete(:index),
14
14
  :stdlib => raw_config.delete(:stdlib),
15
15
  }
16
16
 
17
- version = config[:version]
18
- unless version.present?
17
+ unless config[:version].present?
19
18
  raise ConfigError.new("specify version of ruby (place archive to 'sources' directory or it will be download from ftp://ftp.ruby-lang.org/)")
20
19
  end
21
- self.class.find_or_download_matching_archive(version)
20
+
21
+ if binary = config[:version][/^`(.*)`$/, 1]
22
+ version = `#{binary} -e 'print "\#{RUBY_VERSION}-p\#{RUBY_PATCHLEVEL}"'`
23
+ if $?.success? && version[/^\d+\.\d+\.\d+-p\d+$/]
24
+ config[:version] = version
25
+ puts "binary `#{binary}` is of version #{version}"
26
+ else
27
+ raise ConfigError.new("binary `#{binary}` failed or does not seem to be ruby binary as version returned is #{version.inspect}")
28
+ end
29
+ end
30
+
31
+ self.class.find_or_download_matching_archive(config[:version])
22
32
 
23
33
  if config[:index]
24
34
  index = Pathname(config[:index])
@@ -172,16 +182,34 @@ class SdocAll
172
182
 
173
183
  def download_matching_archive(version)
174
184
  Net::FTP.open('ftp.ruby-lang.org') do |ftp|
175
- remote_path = '/pub/ruby'
185
+ remote_path = Pathname('/pub/ruby')
176
186
  ftp.debug_mode = true
177
187
  ftp.passive = true
178
188
  ftp.login
179
189
  ftp.chdir(remote_path)
180
- paths = ftp.list('ruby-*.tar.bz2').map{ |line| "#{remote_path}/#{line.split.last}" }
181
190
 
182
- if tar = last_matching_ruby_archive(version, paths)
191
+ tar = nil
192
+
193
+ dirs, files = [], []
194
+ ftp.list('*').map do |line|
195
+ full_path = remote_path + line.split.last
196
+ (line.starts_with?('d') ? dirs : files) << full_path
197
+ end
198
+
199
+ tar_bz2_matcher = /(^|\/)ruby-.*\.tar\.bz2$/
200
+
201
+ unless tar = last_matching_ruby_archive(version, files.grep(tar_bz2_matcher)) || last_matching_ruby_archive(version, files)
202
+ dirs = dirs.sort_by{ |dir| s = dir.basename.to_s; v = s.to_f; [v, s] }.reverse.
203
+ select{ |dir| dir.basename.to_s[/^\d/] && dir.basename.to_s.starts_with?(version[0, 3]) }
204
+ dirs.each do |dir|
205
+ files = ftp.nlst(dir)
206
+ break if tar = last_matching_ruby_archive(version, files.grep(tar_bz2_matcher)) || last_matching_ruby_archive(version, files)
207
+ end
208
+ end
209
+
210
+ if tar
183
211
  dest = sources_path.parent + tar.name
184
- unless File.exist?(dest) && File.size(dest) == ftp.size(tar.path)
212
+ unless dest.exist? && dest.size == ftp.size(tar.path)
185
213
  ftp.getbinaryfile(tar.path, dest)
186
214
  end
187
215
  end
data/sdoc_all.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{sdoc_all}
5
- s.version = "1.0.1"
5
+ s.version = "1.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["toy"]
9
- s.date = %q{2009-08-15}
9
+ s.date = %q{2009-08-25}
10
10
  s.default_executable = %q{sdoc-all}
11
11
  s.description = %q{Command line tool to get documentation for ruby, rails, gems and plugins in one place}
12
12
  s.email = %q{ivan@workisfun.ru}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdoc_all
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - toy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-15 00:00:00 +04:00
12
+ date: 2009-08-25 00:00:00 +04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency