proscribe 0.0.1
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/HISTORY.md +4 -0
- data/README.md +7 -0
- data/bin/proscribe +5 -0
- data/data/default/Gemfile +5 -0
- data/data/default/Gemfile.lock +43 -0
- data/data/default/Protonfile +14 -0
- data/data/default/_extensions/manual/lib/cli.rb +18 -0
- data/data/default/_extensions/manual/lib/extractor.rb +206 -0
- data/data/default/_extensions/manual/lib/helpers.rb +32 -0
- data/data/default/_extensions/manual/manual.rb +2 -0
- data/data/default/_layouts/_nav.haml +8 -0
- data/data/default/_layouts/default.haml +123 -0
- data/data/default/style.scss +412 -0
- data/data/rack/Gemfile +2 -0
- data/data/rack/config.ru +8 -0
- data/lib/proscribe/cli.rb +45 -0
- data/lib/proscribe/extractor.rb +158 -0
- data/lib/proscribe/helpers.rb +42 -0
- data/lib/proscribe/project.rb +92 -0
- data/lib/proscribe/rack_app.rb +26 -0
- data/lib/proscribe/version.rb +11 -0
- data/lib/proscribe/watcher.rb +63 -0
- data/lib/proscribe.rb +40 -0
- metadata +137 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
# Class: Project (ProScribe)
|
2
|
+
# A project.
|
3
|
+
#
|
4
|
+
# ## Internal usage
|
5
|
+
#
|
6
|
+
# p = Project.new(config_file)
|
7
|
+
#
|
8
|
+
module ProScribe
|
9
|
+
class Project
|
10
|
+
# Attribute: config (ProScribe::Project)
|
11
|
+
# Returns a hash of the project's configuration, pulled from Scribefile.
|
12
|
+
#
|
13
|
+
attr_reader :config
|
14
|
+
|
15
|
+
def initialize(config_file)
|
16
|
+
@root = File.dirname(config_file)
|
17
|
+
@config = Hashie::Mash.new(YAML::load_file(config_file))
|
18
|
+
|
19
|
+
# Defaults
|
20
|
+
@config.manual ||= '.'
|
21
|
+
@config.output ||= 'doc'
|
22
|
+
@config.files ||= Array.new
|
23
|
+
end
|
24
|
+
|
25
|
+
# Attribute: root (ProScribe::Project)
|
26
|
+
# Returns the root path.
|
27
|
+
#
|
28
|
+
# ## Usage
|
29
|
+
# project.root
|
30
|
+
# project.root(*args)
|
31
|
+
#
|
32
|
+
def root(*a)
|
33
|
+
File.join(@root, *a)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Attribute: manual_path (ProScribe::Project)
|
37
|
+
# Returns the absolute path to the projects's manual.
|
38
|
+
#
|
39
|
+
def manual_path
|
40
|
+
root(@config.manual)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Method: make (ProScribe::Project)
|
44
|
+
# Creates the temp dir from the project's manual and inline comments.
|
45
|
+
#
|
46
|
+
def make
|
47
|
+
dir
|
48
|
+
|
49
|
+
# Copy the files over
|
50
|
+
copy_files ProScribe.root('data/default/'), dir
|
51
|
+
|
52
|
+
# Copy manual files over
|
53
|
+
copy_files manual_path, dir, :except => ['Gemfile', 'Gemfile.lock', 'config.ru']
|
54
|
+
|
55
|
+
# Extract block comments
|
56
|
+
config.files.each do |group|
|
57
|
+
ex = ProScribe::Extractor.new Dir[root(group.source)]
|
58
|
+
ex.write! File.join(dir, group.target)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Attribute: dir (ProScribe::Project)
|
63
|
+
# Returns the path to the temporary Proton project.
|
64
|
+
#
|
65
|
+
def dir(*a)
|
66
|
+
@dir ||= begin
|
67
|
+
dir = File.join(Dir.tmpdir, File.basename(root))
|
68
|
+
FileUtils.rm_rf dir
|
69
|
+
FileUtils.mkdir_p dir
|
70
|
+
dir
|
71
|
+
end
|
72
|
+
|
73
|
+
File.join(@dir, *a)
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def copy_files(from, to, options={})
|
79
|
+
exceptions = options[:except] || []
|
80
|
+
|
81
|
+
Dir["#{from}/**/*"].each do |f|
|
82
|
+
next unless File.file?(f)
|
83
|
+
next if exceptions.include?(File.basename(f))
|
84
|
+
|
85
|
+
target = File.join(to, f.gsub(from, ''))
|
86
|
+
|
87
|
+
FileUtils.mkdir_p File.dirname(target)
|
88
|
+
FileUtils.cp f, target
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'proton'
|
2
|
+
require 'proton/server'
|
3
|
+
require 'shake'
|
4
|
+
|
5
|
+
# Module: RackApp
|
6
|
+
# Provides a Rack app.
|
7
|
+
#
|
8
|
+
# ## Usage
|
9
|
+
#
|
10
|
+
# Use {ProScribe.rack_app}.
|
11
|
+
#
|
12
|
+
module ProScribe
|
13
|
+
module RackApp
|
14
|
+
def self.run!
|
15
|
+
config = Shake.find_in_project("Scribefile") or return
|
16
|
+
project = ProScribe::Project.new(config)
|
17
|
+
project.make
|
18
|
+
|
19
|
+
watcher = ProScribe::Watcher.new(project) { |_, file| puts "Updated #{file}" }
|
20
|
+
|
21
|
+
proton = Proton::Project.new(project.dir)
|
22
|
+
|
23
|
+
Proton::Server
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Class: Watcher (ProScribe)
|
2
|
+
# Monitors files for changes.
|
3
|
+
#
|
4
|
+
# ## Common usage
|
5
|
+
#
|
6
|
+
# w = Watcher.new(project) { puts 'update' }
|
7
|
+
# w.join
|
8
|
+
#
|
9
|
+
module ProScribe
|
10
|
+
class Watcher
|
11
|
+
def initialize(project, &blk)
|
12
|
+
require 'fssm'
|
13
|
+
|
14
|
+
@threads = Array.new
|
15
|
+
|
16
|
+
# Monitor the project's manual
|
17
|
+
@threads << Thread.new {
|
18
|
+
monitor(project.config.manual) { |*a| project.make; yield *a }
|
19
|
+
}
|
20
|
+
|
21
|
+
# Monitor ProScribe's default theme
|
22
|
+
@threads << Thread.new {
|
23
|
+
monitor(ProScribe.root('data')) { |*a| project.make; yield *a }
|
24
|
+
}
|
25
|
+
|
26
|
+
# Monitor the project's files
|
27
|
+
project.config.files.each do |group|
|
28
|
+
threads << Thread.new {
|
29
|
+
path = project.root(group.source)
|
30
|
+
path = path.gsub(/\*.*$/, '')
|
31
|
+
path = File.realpath(path)
|
32
|
+
|
33
|
+
monitor(path) { |*a| project.make; yield *a }
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute: threads (ProScribe::Watcher)
|
39
|
+
# The threads.
|
40
|
+
#
|
41
|
+
attr_reader :threads
|
42
|
+
|
43
|
+
# Method: join (ProScribe::Watcher)
|
44
|
+
# Asks all threads to join.
|
45
|
+
#
|
46
|
+
def join
|
47
|
+
threads.each { |t| t.join }
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
def monitor(path, &blk)
|
52
|
+
updated = lambda { |path, file|
|
53
|
+
yield path, file
|
54
|
+
}
|
55
|
+
|
56
|
+
FSSM.monitor(path) do
|
57
|
+
update(&updated)
|
58
|
+
create(&updated)
|
59
|
+
delete(&updated)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/proscribe.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'shake'
|
5
|
+
require 'hashie'
|
6
|
+
require 'tilt'
|
7
|
+
|
8
|
+
# Module: ProScribe
|
9
|
+
# The main module.
|
10
|
+
#
|
11
|
+
module ProScribe
|
12
|
+
def self.root(*a)
|
13
|
+
File.join(File.expand_path('../../', __FILE__), *a)
|
14
|
+
end
|
15
|
+
|
16
|
+
PREFIX = File.expand_path('../', __FILE__)
|
17
|
+
|
18
|
+
autoload :Project, "#{PREFIX}/proscribe/project"
|
19
|
+
autoload :Helpers, "#{PREFIX}/proscribe/helpers"
|
20
|
+
autoload :CLI, "#{PREFIX}/proscribe/cli"
|
21
|
+
autoload :Extractor, "#{PREFIX}/proscribe/extractor"
|
22
|
+
autoload :Watcher, "#{PREFIX}/proscribe/watcher"
|
23
|
+
autoload :RackApp, "#{PREFIX}/proscribe/rack_app"
|
24
|
+
|
25
|
+
require "#{PREFIX}/proscribe/version"
|
26
|
+
|
27
|
+
# Class method: rack_app (ProScribe)
|
28
|
+
# Returns a Rack app for the current dir's ProScribe project.
|
29
|
+
#
|
30
|
+
# ## Usage
|
31
|
+
#
|
32
|
+
# [config.ru (ruby)]
|
33
|
+
# require 'proscribe'
|
34
|
+
# run ProScribe.rack_app
|
35
|
+
#
|
36
|
+
def self.rack_app
|
37
|
+
RackApp.run! && Proton::Server
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: proscribe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rico Sta. Cruz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-07-24 00:00:00.000000000 +08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hashie
|
17
|
+
requirement: &2153048280 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2153048280
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: shake
|
28
|
+
requirement: &2153047780 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2153047780
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: tilt
|
39
|
+
requirement: &2153047320 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.2.2
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *2153047320
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: proton
|
50
|
+
requirement: &2153046860 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.3.3
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *2153046860
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: fssm
|
61
|
+
requirement: &2153046400 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.2.7
|
67
|
+
type: :runtime
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *2153046400
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rdiscount
|
72
|
+
requirement: &2153045940 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.6.8
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *2153045940
|
81
|
+
description: Build some documentation for your projects of any language.
|
82
|
+
email:
|
83
|
+
- rico@sinefunc.com
|
84
|
+
executables:
|
85
|
+
- proscribe
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- data/default/_extensions/manual/lib/cli.rb
|
90
|
+
- data/default/_extensions/manual/lib/extractor.rb
|
91
|
+
- data/default/_extensions/manual/lib/helpers.rb
|
92
|
+
- data/default/_extensions/manual/manual.rb
|
93
|
+
- data/default/_layouts/_nav.haml
|
94
|
+
- data/default/_layouts/default.haml
|
95
|
+
- data/default/Gemfile
|
96
|
+
- data/default/Gemfile.lock
|
97
|
+
- data/default/Protonfile
|
98
|
+
- data/default/style.scss
|
99
|
+
- data/rack/config.ru
|
100
|
+
- data/rack/Gemfile
|
101
|
+
- bin/proscribe
|
102
|
+
- lib/proscribe/cli.rb
|
103
|
+
- lib/proscribe/extractor.rb
|
104
|
+
- lib/proscribe/helpers.rb
|
105
|
+
- lib/proscribe/project.rb
|
106
|
+
- lib/proscribe/rack_app.rb
|
107
|
+
- lib/proscribe/version.rb
|
108
|
+
- lib/proscribe/watcher.rb
|
109
|
+
- lib/proscribe.rb
|
110
|
+
- HISTORY.md
|
111
|
+
- README.md
|
112
|
+
has_rdoc: true
|
113
|
+
homepage: http://github.com/rstacruz/proscribe
|
114
|
+
licenses: []
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 1.6.2
|
134
|
+
signing_key:
|
135
|
+
specification_version: 3
|
136
|
+
summary: Documentation generator.
|
137
|
+
test_files: []
|