yard_gems 1.0
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/.gitignore +8 -0
- data/Gemfile.passenger_ignore +4 -0
- data/README +4 -0
- data/Rakefile +1 -0
- data/bin/yard-gems +23 -0
- data/config.ru +4 -0
- data/lib/yard_gems.rb +5 -0
- data/lib/yard_gems/rack_adapter.rb +60 -0
- data/lib/yard_gems/version.rb +3 -0
- data/yard_gems.gemspec +23 -0
- metadata +105 -0
data/.gitignore
ADDED
data/README
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/yard-gems
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require "rubygems" # ruby1.9 doesn't "require" it though
|
|
3
|
+
require "thor"
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
|
|
6
|
+
class YardGems < Thor
|
|
7
|
+
desc "install PATH", "Installs a YARD gems application the supplied path"
|
|
8
|
+
def install(path)
|
|
9
|
+
puts "I will install it here: #{path}"
|
|
10
|
+
FileUtils.mkdir_p(path + '/public')
|
|
11
|
+
FileUtils.mkdir_p(path + '/tmp')
|
|
12
|
+
FileUtils.cp(File.expand_path("../../config.ru", __FILE__), path + "/config.ru")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc "pow", "Installs the yard gems application to ~/.pow"
|
|
16
|
+
def pow(path="~/.pow")
|
|
17
|
+
path = File.join(File.expand_path(path), "yard")
|
|
18
|
+
install(path)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
YardGems.start
|
|
23
|
+
|
data/config.ru
ADDED
data/lib/yard_gems.rb
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'yard'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
|
|
4
|
+
class YardGems::RackAdapter
|
|
5
|
+
def initialize
|
|
6
|
+
@cached_libraries = load_cached_libraries
|
|
7
|
+
|
|
8
|
+
load_libraries
|
|
9
|
+
|
|
10
|
+
if @cached_libraries != @libraries
|
|
11
|
+
FileUtils.rm_f 'public.html'
|
|
12
|
+
cache_libraries
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
@last_refresh = Time.now
|
|
16
|
+
@yard_server = YARD::Server::RackAdapter.new(@libraries, {:caching => true}, :DocumentRoot => 'public')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
REFRESH_INTERVAL = 60 #seconds
|
|
20
|
+
|
|
21
|
+
def call(env)
|
|
22
|
+
if Time.now - @last_refresh > REFRESH_INTERVAL
|
|
23
|
+
$stderr.puts "Checking for new gems"
|
|
24
|
+
Gem.source_index.refresh!
|
|
25
|
+
|
|
26
|
+
load_libraries
|
|
27
|
+
|
|
28
|
+
if @cached_libraries != @libraries
|
|
29
|
+
$stderr.puts "Reloading gems"
|
|
30
|
+
|
|
31
|
+
FileUtils.rm_f 'public.html'
|
|
32
|
+
@yard_server.libraries = @libraries
|
|
33
|
+
cache_libraries
|
|
34
|
+
end
|
|
35
|
+
@last_refresh = Time.now
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
@yard_server.call(env)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
def load_cached_libraries
|
|
43
|
+
Marshal.load(IO.read('tmp/gems.index')) if File.exist?('tmp/gems.index')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def load_libraries
|
|
47
|
+
@libraries = {}
|
|
48
|
+
gems = Gem.source_index.find_name('').each do |spec|
|
|
49
|
+
@libraries[spec.name] ||= []
|
|
50
|
+
@libraries[spec.name] << YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def cache_libraries
|
|
55
|
+
File.open('tmp/gems.index', 'w') do |f|
|
|
56
|
+
f << Marshal.dump(@libraries)
|
|
57
|
+
end
|
|
58
|
+
@cached_libraries = @libraries
|
|
59
|
+
end
|
|
60
|
+
end
|
data/yard_gems.gemspec
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "yard_gems/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "yard_gems"
|
|
7
|
+
s.version = YardGems::VERSION
|
|
8
|
+
s.authors = ["Doug Barth"]
|
|
9
|
+
s.email = ["dougbarth@gmail.com"]
|
|
10
|
+
s.homepage = ""
|
|
11
|
+
s.summary = %q{Local On Demand YARD Docs for Rubygems}
|
|
12
|
+
s.description = %q{Easily install a YARD backed site for viewing locally installed Rubygem docs. Install this and disable rdoc generation on gem install.}
|
|
13
|
+
|
|
14
|
+
s.rubyforge_project = "yard_gems"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
19
|
+
s.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
s.add_runtime_dependency "yard"
|
|
22
|
+
s.add_runtime_dependency "rack"
|
|
23
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: yard_gems
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 15
|
|
5
|
+
prerelease:
|
|
6
|
+
segments:
|
|
7
|
+
- 1
|
|
8
|
+
- 0
|
|
9
|
+
version: "1.0"
|
|
10
|
+
platform: ruby
|
|
11
|
+
authors:
|
|
12
|
+
- Doug Barth
|
|
13
|
+
autorequire:
|
|
14
|
+
bindir: bin
|
|
15
|
+
cert_chain: []
|
|
16
|
+
|
|
17
|
+
date: 2011-09-17 00:00:00 -05:00
|
|
18
|
+
default_executable:
|
|
19
|
+
dependencies:
|
|
20
|
+
- !ruby/object:Gem::Dependency
|
|
21
|
+
name: yard
|
|
22
|
+
prerelease: false
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
none: false
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
hash: 3
|
|
29
|
+
segments:
|
|
30
|
+
- 0
|
|
31
|
+
version: "0"
|
|
32
|
+
type: :runtime
|
|
33
|
+
version_requirements: *id001
|
|
34
|
+
- !ruby/object:Gem::Dependency
|
|
35
|
+
name: rack
|
|
36
|
+
prerelease: false
|
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
38
|
+
none: false
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
hash: 3
|
|
43
|
+
segments:
|
|
44
|
+
- 0
|
|
45
|
+
version: "0"
|
|
46
|
+
type: :runtime
|
|
47
|
+
version_requirements: *id002
|
|
48
|
+
description: Easily install a YARD backed site for viewing locally installed Rubygem docs. Install this and disable rdoc generation on gem install.
|
|
49
|
+
email:
|
|
50
|
+
- dougbarth@gmail.com
|
|
51
|
+
executables:
|
|
52
|
+
- yard-gems
|
|
53
|
+
extensions: []
|
|
54
|
+
|
|
55
|
+
extra_rdoc_files: []
|
|
56
|
+
|
|
57
|
+
files:
|
|
58
|
+
- .gitignore
|
|
59
|
+
- Gemfile.passenger_ignore
|
|
60
|
+
- README
|
|
61
|
+
- Rakefile
|
|
62
|
+
- bin/yard-gems
|
|
63
|
+
- config.ru
|
|
64
|
+
- lib/yard_gems.rb
|
|
65
|
+
- lib/yard_gems/rack_adapter.rb
|
|
66
|
+
- lib/yard_gems/version.rb
|
|
67
|
+
- public/.gitkeep
|
|
68
|
+
- tmp/.gitkeep
|
|
69
|
+
- yard_gems.gemspec
|
|
70
|
+
has_rdoc: true
|
|
71
|
+
homepage: ""
|
|
72
|
+
licenses: []
|
|
73
|
+
|
|
74
|
+
post_install_message:
|
|
75
|
+
rdoc_options: []
|
|
76
|
+
|
|
77
|
+
require_paths:
|
|
78
|
+
- lib
|
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
|
+
none: false
|
|
81
|
+
requirements:
|
|
82
|
+
- - ">="
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
hash: 3
|
|
85
|
+
segments:
|
|
86
|
+
- 0
|
|
87
|
+
version: "0"
|
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
|
+
none: false
|
|
90
|
+
requirements:
|
|
91
|
+
- - ">="
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
hash: 3
|
|
94
|
+
segments:
|
|
95
|
+
- 0
|
|
96
|
+
version: "0"
|
|
97
|
+
requirements: []
|
|
98
|
+
|
|
99
|
+
rubyforge_project: yard_gems
|
|
100
|
+
rubygems_version: 1.4.2
|
|
101
|
+
signing_key:
|
|
102
|
+
specification_version: 3
|
|
103
|
+
summary: Local On Demand YARD Docs for Rubygems
|
|
104
|
+
test_files: []
|
|
105
|
+
|