bookshop 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +86 -0
- data/bookshop.gemspec +11 -2
- data/lib/bookshop/commands/build.rb +28 -0
- data/lib/bookshop/generators/bookshop/project/USAGE +3 -3
- data/lib/bookshop/generators/bookshop/project/project_generator.rb +7 -2
- data/lib/bookshop/generators/bookshop/project/templates/README.rdoc +0 -2
- data/lib/bookshop/generators/bookshop/project/templates/script/build +4 -32
- data/lib/bookshop/version.rb +1 -1
- metadata +44 -32
- data/lib/bookshop/commands/app_bk +0 -135
- data/lib/bookshop/commands/application.rb +0 -16
- data/lib/bookshop/generators/actions.rb +0 -320
- data/lib/bookshop/generators/base.rb +0 -16
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/avalon-framework-4.2.0.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/batik-all-1.7.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/bsf.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/commons-io-1.3.1.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/commons-logging-1.0.4.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/fop-hyph.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/fop.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/jai_codec.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/jai_core.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/serializer-2.7.0.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/xalan-2.7.0.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/xalansamples.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/xalanservlet.war +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/xercesImpl-2.7.1.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/xml-apis-1.3.04.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/xml-apis-ext-1.3.04.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/xmlgraphics-commons-1.4.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/xsltcapplet.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/xsltcbrazil.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/xsltcejb.jar +0 -0
- data/lib/bookshop/generators/bookshop/project/tools/java-libs/xsltcservlet.jar +0 -0
data/README.rdoc
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
== Welcome to bookShop
|
2
|
+
|
3
|
+
bookShop is an open-source ruby-based development framework for working with DocBook/XSL production flows. The framework is optimized to help developers quickly ramp-up, allowing them to more rapidly jump in and develop their DocBook-to-Output flows, by favoring convention over configuration, setting them up with best practices from the get-go.
|
4
|
+
|
5
|
+
bookShop hopes to simplify the process by:
|
6
|
+
* providing a Ruby Gem to make working with DocBook as easy as 'sudo gem install bookShop'
|
7
|
+
* pulling all the DocBook tools together into one place
|
8
|
+
* giving the developer a set of scripts to automate the redundant stuff
|
9
|
+
* providing an architecture/structure that follows best-practices and simplification (DRY... Don't Repeat Yourself)
|
10
|
+
* providing an extendable framework for other developers to add their own custom templates (and hopefully provide them for the community)
|
11
|
+
|
12
|
+
== How to Install
|
13
|
+
|
14
|
+
=== System Requirements
|
15
|
+
|
16
|
+
* Ruby v1.8.7 or v1.9.2 http://www.ruby-lang.org/en/downloads/
|
17
|
+
* Rubygems v1.3.6 http://docs.rubygems.org/read/chapter/3
|
18
|
+
* Java v1.6 http://www.java.com/
|
19
|
+
|
20
|
+
=== Install bookShop
|
21
|
+
|
22
|
+
<tt>$ sudo gem install bookshop</tt>
|
23
|
+
|
24
|
+
=== Create bookShop project
|
25
|
+
|
26
|
+
<tt>$ bookshop new ~/Path/to/NewProject</tt>
|
27
|
+
|
28
|
+
This will create a new bookshop project in ~/Path/to/NewProject
|
29
|
+
|
30
|
+
== Getting Help
|
31
|
+
|
32
|
+
bookShop comes with a built in help feature. Simply run 'bookshop --help' from the command line to get
|
33
|
+
list of possible commands to issue including possible options. You can also run 'bookshop COMMAND --help'
|
34
|
+
(where COMMAND is the command you want) to get a list of possible options for that particular command
|
35
|
+
|
36
|
+
== Description of Gem Contents
|
37
|
+
|
38
|
+
The basic gem architecture:
|
39
|
+
|
40
|
+
|-- bin
|
41
|
+
|-- lib
|
42
|
+
|
43
|
+
bin
|
44
|
+
command file copied to /usr/bin upon installation (which is then called from the command line)
|
45
|
+
|
46
|
+
lib
|
47
|
+
bookshop gem library files
|
48
|
+
|
49
|
+
== Description of bookShop Project contents
|
50
|
+
|
51
|
+
The default directory structure of a generated bookShop project:
|
52
|
+
|
53
|
+
|-- book
|
54
|
+
|-- builds
|
55
|
+
| |-- epub
|
56
|
+
| |-- html
|
57
|
+
| |-- mobi
|
58
|
+
`-- pdf
|
59
|
+
|-- stylesheets
|
60
|
+
|-- tools
|
61
|
+
|
62
|
+
book
|
63
|
+
Holds all the manuscript DocBook code/files. This is where your master manuscript lives from which everything is built.
|
64
|
+
|
65
|
+
builds
|
66
|
+
Holds all the output files built from the DocBook using their specific Stylesheets
|
67
|
+
|
68
|
+
builds/epub
|
69
|
+
When building the epub, the generated output will reside here in an .epub file.
|
70
|
+
You can rename the .epub extension to .zip then unzip the file to view the contents.
|
71
|
+
|
72
|
+
builds/html
|
73
|
+
When building the html asset, the generated output will reside here.
|
74
|
+
|
75
|
+
build/mobi
|
76
|
+
When building the mobi asset, the generated output will reside here as "book.mobi".
|
77
|
+
|
78
|
+
build/pdf
|
79
|
+
When building the pdf book, the generated output will reside here as "book.pdf".
|
80
|
+
|
81
|
+
stylesheets
|
82
|
+
Holds the XSL stylesheets for customizing your book output.
|
83
|
+
|
84
|
+
tools
|
85
|
+
Holds the dtd and DocBook-XSL specs which serve as the base for building formats.
|
86
|
+
Customization should happen via the stylesheets in the "stylesheets" folder. Files here should remain unchanged.
|
data/bookshop.gemspec
CHANGED
@@ -9,14 +9,23 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = ['da@blueheadpublishing.com']
|
10
10
|
s.homepage = "http://rubygems.org/gems/bookshop"
|
11
11
|
s.summary = "A framework for DocBook happiness and sustainable productivity."
|
12
|
-
s.description = "
|
12
|
+
s.description = "bookShop is an open-source ruby-based development framework for working
|
13
|
+
with DocBook/XSL tool-chain flows. The framework is optimized to help
|
14
|
+
developers quickly ramp-up, allowing them to more rapidly jump in and
|
15
|
+
develop their DocBook-to-Output flows, by favoring convention over
|
16
|
+
configuration, setting them up with best practices, standards and
|
17
|
+
tools from the get-go."
|
13
18
|
|
14
19
|
s.required_rubygems_version = ">= 1.3.6"
|
15
20
|
s.rubyforge_project = "bookshop"
|
21
|
+
s.has_rdoc = true
|
16
22
|
|
23
|
+
|
24
|
+
s.add_dependency "thor", ">= 0.14.6"
|
17
25
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
26
|
+
s.add_development_dependency "rspec"
|
18
27
|
|
19
28
|
s.files = `git ls-files`.split("\n")
|
20
29
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
21
30
|
s.require_path = 'lib'
|
22
|
-
end
|
31
|
+
end
|
@@ -2,7 +2,35 @@ require 'thor/group'
|
|
2
2
|
|
3
3
|
module Bookshop
|
4
4
|
class Build
|
5
|
+
def build_pdf
|
6
|
+
puts "Deleting your old ebook"
|
7
|
+
File.delete("builds/pdf/book.pdf") if File::exists?( "builds/pdf/book.pdf" )
|
8
|
+
puts "File Deleted"
|
9
|
+
puts "Building new pdf at builds/pdf/book.pdf"
|
10
|
+
cmd = %x[java org.apache.fop.cli.Main -xml book/book.xml -xsl stylesheets/fo-stylesheet.xsl builds/pdf/book.pdf]
|
11
|
+
end
|
5
12
|
|
13
|
+
def build_epub
|
14
|
+
puts "Deleting your old ebook"
|
15
|
+
File.delete("builds/epub/book.epub") if File::exists?( "builds/epub/book.epub" )
|
16
|
+
puts "File Deleted"
|
17
|
+
puts "Building new pdf at builds/epub/book.epub"
|
18
|
+
cmd = %x[docbook/templates/epub/bin/dbtoepub -v book/book.xml -o builds/epub/book.epub]
|
19
|
+
end
|
20
|
+
|
21
|
+
if ARGV.empty?
|
22
|
+
puts ""
|
23
|
+
puts "tell me what to build (epub or pdf)"
|
24
|
+
puts ""
|
25
|
+
else
|
26
|
+
ARGV.each do |a|
|
27
|
+
if a == 'pdf'
|
28
|
+
build_pdf
|
29
|
+
elsif a == 'epub'
|
30
|
+
build_epub
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
6
34
|
# shift ARGV's so that value after build (pdf, etc) is then iterated over with options
|
7
35
|
# ARGV.shift
|
8
36
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Description:
|
2
|
-
The 'bookshop new' command creates a new
|
2
|
+
The 'bookshop new' command creates a new Bookshop project with a default
|
3
3
|
directory structure and configuration at the path you specify.
|
4
4
|
|
5
5
|
Example:
|
6
|
-
|
6
|
+
bookshop new ~/Projects/NewBookProject
|
7
7
|
|
8
|
-
This generates a skeletal
|
8
|
+
This generates a skeletal Bookshop installation in ~/Projects/NewBookProject.
|
9
9
|
See the README in the newly created application to get going.
|
@@ -9,26 +9,31 @@ module Bookshop
|
|
9
9
|
|
10
10
|
# Define arguments and options
|
11
11
|
argument :name, :type => :string
|
12
|
+
|
12
13
|
|
13
14
|
class_option :dtd, :type => :string, :aliases => "-dtd",
|
14
15
|
:desc => "DTD version [ 4.5, 5.0 ]", :default => "5.0"
|
15
16
|
|
16
17
|
class_option :xsl, :type => :string, :aliases => "-xsl",
|
17
18
|
:desc => "DocBook-XSL version [ 1.75.2, 1.76.1 ]", :default => "1.76.1"
|
18
|
-
|
19
|
+
|
20
|
+
# Define source root of application
|
19
21
|
def self.source_root
|
20
22
|
File.dirname(__FILE__)
|
21
23
|
end
|
22
24
|
|
23
|
-
|
25
|
+
# Create the project from templates
|
26
|
+
def create_base_project
|
24
27
|
directory "templates", "#{name}"
|
25
28
|
end
|
26
29
|
|
30
|
+
# Adds the dtd specified by user
|
27
31
|
def add_dtd
|
28
32
|
dtd = "#{options[:dtd]}"
|
29
33
|
directory "tools/dtd/#{options[:dtd]}", "#{name}/tools/dtd/#{options[:dtd]}"
|
30
34
|
end
|
31
35
|
|
36
|
+
# Adds the XSL/version specified by user
|
32
37
|
def add_xsl
|
33
38
|
directory "tools/xsl/#{options[:xsl]}", "#{name}/tools/xsl/#{options[:xsl]}"
|
34
39
|
end
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
bookShop is an open-source ruby-based development framework for working with DocBook/XSL production flows. The framework is optimized to help developers quickly ramp-up, allowing them to more rapidly jump in and develop their DocBook-to-Output flows, by favoring convention over configuration, setting them up with best practices from the get-go.
|
4
4
|
|
5
|
-
Let's face it, the DocBook universe is a brutish, uber-complex amalgomation of XML/XSL(T)'s. It's evil... but hey, it works well for what it does best: making your HUMAN-friendly book COMPUTER-friendly, then spitting it out into whatever format you want.
|
6
|
-
|
7
5
|
bookShop hopes to simplify the process by:
|
8
6
|
* providing a Ruby Gem to make working with DocBook as easy as 'sudo gem install bookShop'
|
9
7
|
* pulling all the DocBook tools together into one place
|
@@ -1,34 +1,6 @@
|
|
1
|
-
|
1
|
+
# This command will automatically be run when you run "bookshop" with Bookshop gem installed from the root of your application.
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
puts "Deleting your old ebook"
|
7
|
-
File.delete("builds/pdf/book.pdf") if File::exists?( "builds/pdf/book.pdf" )
|
8
|
-
puts "File Deleted"
|
9
|
-
puts "Building new pdf at builds/pdf/book.pdf"
|
10
|
-
cmd = %x[java org.apache.fop.cli.Main -xml book/book.xml -xsl stylesheets/fo-stylesheet.xsl builds/pdf/book.pdf]
|
11
|
-
end
|
12
|
-
|
13
|
-
def build_epub
|
14
|
-
puts "Deleting your old ebook"
|
15
|
-
File.delete("builds/epub/book.epub") if File::exists?( "builds/epub/book.epub" )
|
16
|
-
puts "File Deleted"
|
17
|
-
puts "Building new pdf at builds/epub/book.epub"
|
18
|
-
cmd = %x[docbook/templates/epub/bin/dbtoepub -v book/book.xml -o builds/epub/book.epub]
|
19
|
-
end
|
20
|
-
|
21
|
-
if ARGV.empty?
|
22
|
-
puts ""
|
23
|
-
puts "tell me what to build (epub or pdf)"
|
24
|
-
puts ""
|
25
|
-
else
|
26
|
-
ARGV.each do |a|
|
27
|
-
if a == 'pdf'
|
28
|
-
build_pdf
|
29
|
-
elsif a == 'epub'
|
30
|
-
build_epub
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
3
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
4
|
+
require File.expand_path('../../config/boot', __FILE__)
|
5
|
+
require 'bookshop/commands'
|
34
6
|
|
data/lib/bookshop/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bookshop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- D.a. Thompson
|
@@ -15,13 +15,29 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-02 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: thor
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 43
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 14
|
33
|
+
- 6
|
34
|
+
version: 0.14.6
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: bundler
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
25
41
|
none: false
|
26
42
|
requirements:
|
27
43
|
- - ">="
|
@@ -33,8 +49,28 @@ dependencies:
|
|
33
49
|
- 0
|
34
50
|
version: 1.0.0
|
35
51
|
type: :development
|
36
|
-
version_requirements: *
|
37
|
-
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rspec
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
description: |-
|
68
|
+
bookShop is an open-source ruby-based development framework for working
|
69
|
+
with DocBook/XSL tool-chain flows. The framework is optimized to help
|
70
|
+
developers quickly ramp-up, allowing them to more rapidly jump in and
|
71
|
+
develop their DocBook-to-Output flows, by favoring convention over
|
72
|
+
configuration, setting them up with best practices, standards and
|
73
|
+
tools from the get-go.
|
38
74
|
email:
|
39
75
|
- da@blueheadpublishing.com
|
40
76
|
executables:
|
@@ -46,16 +82,13 @@ extra_rdoc_files: []
|
|
46
82
|
files:
|
47
83
|
- .gitignore
|
48
84
|
- Gemfile
|
85
|
+
- README.rdoc
|
49
86
|
- Rakefile
|
50
87
|
- bin/bookshop
|
51
88
|
- bookshop.gemspec
|
52
89
|
- lib/bookshop.rb
|
53
90
|
- lib/bookshop/commands.rb
|
54
|
-
- lib/bookshop/commands/app_bk
|
55
|
-
- lib/bookshop/commands/application.rb
|
56
91
|
- lib/bookshop/commands/build.rb
|
57
|
-
- lib/bookshop/generators/actions.rb
|
58
|
-
- lib/bookshop/generators/base.rb
|
59
92
|
- lib/bookshop/generators/bookshop/generator/USAGE
|
60
93
|
- lib/bookshop/generators/bookshop/generator/generator_generator.rb
|
61
94
|
- lib/bookshop/generators/bookshop/generator/templates/%file_name%_generator.rb.tt
|
@@ -128,27 +161,6 @@ files:
|
|
128
161
|
- lib/bookshop/generators/bookshop/project/tools/dtd/5.0/xsd/docbook.xsd
|
129
162
|
- lib/bookshop/generators/bookshop/project/tools/dtd/5.0/xsd/xlink.xsd
|
130
163
|
- lib/bookshop/generators/bookshop/project/tools/dtd/5.0/xsd/xml.xsd
|
131
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/avalon-framework-4.2.0.jar
|
132
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/batik-all-1.7.jar
|
133
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/bsf.jar
|
134
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/commons-io-1.3.1.jar
|
135
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/commons-logging-1.0.4.jar
|
136
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/fop-hyph.jar
|
137
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/fop.jar
|
138
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/jai_codec.jar
|
139
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/jai_core.jar
|
140
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/serializer-2.7.0.jar
|
141
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/xalan-2.7.0.jar
|
142
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/xalansamples.jar
|
143
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/xalanservlet.war
|
144
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/xercesImpl-2.7.1.jar
|
145
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/xml-apis-1.3.04.jar
|
146
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/xml-apis-ext-1.3.04.jar
|
147
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/xmlgraphics-commons-1.4.jar
|
148
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/xsltcapplet.jar
|
149
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/xsltcbrazil.jar
|
150
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/xsltcejb.jar
|
151
|
-
- lib/bookshop/generators/bookshop/project/tools/java-libs/xsltcservlet.jar
|
152
164
|
- lib/bookshop/generators/bookshop/project/tools/xsl/1.75.2/AUTHORS
|
153
165
|
- lib/bookshop/generators/bookshop/project/tools/xsl/1.75.2/BUGS
|
154
166
|
- lib/bookshop/generators/bookshop/project/tools/xsl/1.75.2/COPYING
|
@@ -1,135 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'thor'
|
4
|
-
|
5
|
-
module Bookshop
|
6
|
-
module Application
|
7
|
-
|
8
|
-
class Base < Thor
|
9
|
-
include Thor::Actions
|
10
|
-
include Thor::RakeCompat
|
11
|
-
|
12
|
-
class_option :help, :type => :boolean, :desc => "Show help usage"
|
13
|
-
|
14
|
-
desc "rake", "Execute rake tasks"
|
15
|
-
method_option :environment, :type => :string, :aliases => "-e", :required => true, :default => :development
|
16
|
-
method_option :list, :type => :string, :aliases => "-T", :desc => "Display the tasks (matching optional PATTERN) with descriptions, then exit."
|
17
|
-
method_option :trace, :type => :boolean, :aliases => "-t", :desc => "Turn on invoke/execute tracing, enable full backtrace."
|
18
|
-
method_option :verbose, :type => :boolean, :aliases => "-v", :desc => "Log message to standard output."
|
19
|
-
def rake(*args)
|
20
|
-
prepare :rake
|
21
|
-
args << "-T" if options[:list]
|
22
|
-
args << options[:list] unless options[:list].nil? || options[:list].to_s == "list"
|
23
|
-
args << "--trace" if options[:trace]
|
24
|
-
args << "--verbose" if options[:verbose]
|
25
|
-
ARGV.clear
|
26
|
-
ARGV.concat(args)
|
27
|
-
puts "=> Executing Rake #{ARGV.join(' ')} ..."
|
28
|
-
ENV['BOOKSHOP_LOG_LEVEL'] ||= "test"
|
29
|
-
require File.expand_path(File.dirname(__FILE__) + '/rake')
|
30
|
-
silence(:stdout) { require File.expand_path('config/boot.rb') }
|
31
|
-
bookshopTasks.init
|
32
|
-
end
|
33
|
-
|
34
|
-
desc "generate", "Executes the bookshop generator with given options."
|
35
|
-
def generate(*args)
|
36
|
-
# Build bookshop g as an alias of book-gen
|
37
|
-
begin
|
38
|
-
# We try to load the vendored book-gen if exist
|
39
|
-
book_gen_path = File.expand_path('../../../../../book-gen/lib', __FILE__)
|
40
|
-
$:.unshift(book_gen_path) if File.directory?(book_gen_path) && !$:.include?(book_gen_path)
|
41
|
-
require 'book-core/command'
|
42
|
-
require 'book-gen/command'
|
43
|
-
ARGV.shift
|
44
|
-
bookshop.bin_gen(ARGV)
|
45
|
-
rescue
|
46
|
-
puts "<= You need book-gen! Run: gem install book-gen"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
desc "g", "Executes the bookshop generator with given options."
|
50
|
-
alias :g :generate
|
51
|
-
desc "gen", "Executes the bookshop generator with given options."
|
52
|
-
alias :gen :generate
|
53
|
-
|
54
|
-
desc "version", "Show current bookshop Version"
|
55
|
-
map "-v" => :version, "--version" => :version
|
56
|
-
def version
|
57
|
-
require 'book-core/version'
|
58
|
-
puts "bookshop v. #{bookshop.version}"
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
def prepare(task)
|
63
|
-
if options.help?
|
64
|
-
help(task.to_s)
|
65
|
-
raise SystemExit
|
66
|
-
end
|
67
|
-
ENV["BOOKSHOP_ENV"] ||= options.environment.to_s
|
68
|
-
ENV["RACK_ENV"] = ENV["BOOKSHOP_ENV"] # Also set this for middleware
|
69
|
-
chdir(options.chdir)
|
70
|
-
unless File.exist?('config/boot.rb')
|
71
|
-
puts "=> Could not find boot file in: #{options.chdir}/config/boot.rb !!!"
|
72
|
-
raise SystemExit
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
protected
|
77
|
-
def self.banner(task=nil, *args)
|
78
|
-
"book #{task.name}"
|
79
|
-
end
|
80
|
-
|
81
|
-
def capture(stream)
|
82
|
-
begin
|
83
|
-
stream = stream.to_s
|
84
|
-
eval "$#{stream} = StringIO.new"
|
85
|
-
yield
|
86
|
-
result = eval("$#{stream}").string
|
87
|
-
ensure
|
88
|
-
eval("$#{stream} = #{stream.upcase}")
|
89
|
-
end
|
90
|
-
|
91
|
-
result
|
92
|
-
end
|
93
|
-
alias :silence :capture
|
94
|
-
end # Base
|
95
|
-
end # Cli
|
96
|
-
end # bookshop
|
97
|
-
|
98
|
-
|
99
|
-
#!/usr/bin/env ruby
|
100
|
-
|
101
|
-
require 'rubygems'
|
102
|
-
require 'thor/group'
|
103
|
-
|
104
|
-
class ProjectGenerator < Thor::Group
|
105
|
-
include Thor::Actions
|
106
|
-
|
107
|
-
# Define arguments and options
|
108
|
-
argument :name, :type => :string
|
109
|
-
|
110
|
-
class_option :dtd, :type => :string, :aliases => "-dtd",
|
111
|
-
:desc => "DTD version [ 4.5, 5.0 ]", :default => "5.0"
|
112
|
-
|
113
|
-
class_option :xsl, :type => :string, :aliases => "-xsl",
|
114
|
-
:desc => "DocBook-XSL version [ 1.75.2, 1.76.1 ]", :default => "1.76.1"
|
115
|
-
|
116
|
-
def self.source_root
|
117
|
-
File.dirname(__FILE__)
|
118
|
-
end
|
119
|
-
|
120
|
-
def create_base_app
|
121
|
-
directory "app/project_base", "#{name}"
|
122
|
-
end
|
123
|
-
|
124
|
-
def add_dtd
|
125
|
-
dtd = "#{options[:dtd]}"
|
126
|
-
directory "app/tools/dtd/#{options[:dtd]}", "#{name}/tools/dtd/#{options[:dtd]}"
|
127
|
-
end
|
128
|
-
|
129
|
-
def add_xsl
|
130
|
-
directory "app/tools/xsl/#{options[:xsl]}", "#{name}/tools/xsl/#{options[:xsl]}"
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
ProjectGenerator.start
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'bookshop/version'
|
2
|
-
if %w(--version -v).include? ARGV.first
|
3
|
-
puts "Bookshop #{Bookshop::VERSION::STRING}"
|
4
|
-
exit(0)
|
5
|
-
end
|
6
|
-
|
7
|
-
if ARGV.first != "new"
|
8
|
-
ARGV[0] = "--help"
|
9
|
-
else
|
10
|
-
ARGV.shift
|
11
|
-
end
|
12
|
-
|
13
|
-
# require 'bookshop/generators'
|
14
|
-
require 'bookshop/generators/bookshop/project/project_generator'
|
15
|
-
|
16
|
-
Bookshop::Generators::ProjectGenerator.start
|
@@ -1,320 +0,0 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
require 'rbconfig'
|
3
|
-
|
4
|
-
module Bookshop
|
5
|
-
module Generators
|
6
|
-
module Actions
|
7
|
-
|
8
|
-
# Install a plugin. You must provide either a Subversion url or Git url.
|
9
|
-
#
|
10
|
-
# For a Git-hosted plugin, you can specify a branch and
|
11
|
-
# whether it should be added as a submodule instead of cloned.
|
12
|
-
#
|
13
|
-
# For a Subversion-hosted plugin you can specify a revision.
|
14
|
-
#
|
15
|
-
# ==== Examples
|
16
|
-
#
|
17
|
-
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git'
|
18
|
-
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :branch => 'stable'
|
19
|
-
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true
|
20
|
-
# plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk'
|
21
|
-
# plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk', :revision => 1234
|
22
|
-
#
|
23
|
-
def plugin(name, options)
|
24
|
-
log :plugin, name
|
25
|
-
|
26
|
-
if options[:git] && options[:submodule]
|
27
|
-
options[:git] = "-b #{options[:branch]} #{options[:git]}" if options[:branch]
|
28
|
-
in_root do
|
29
|
-
run "git submodule add #{options[:git]} vendor/plugins/#{name}", :verbose => false
|
30
|
-
end
|
31
|
-
elsif options[:git] || options[:svn]
|
32
|
-
options[:git] = "-b #{options[:branch]} #{options[:git]}" if options[:branch]
|
33
|
-
options[:svn] = "-r #{options[:revision]} #{options[:svn]}" if options[:revision]
|
34
|
-
in_root do
|
35
|
-
run_ruby_script "script/bookshop plugin install #{options[:svn] || options[:git]}", :verbose => false
|
36
|
-
end
|
37
|
-
else
|
38
|
-
log "! no git or svn provided for #{name}. Skipping..."
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Adds an entry into Gemfile for the supplied gem. If env
|
43
|
-
# is specified, add the gem to the given environment.
|
44
|
-
#
|
45
|
-
# ==== Example
|
46
|
-
#
|
47
|
-
# gem "rspec", :env => :test
|
48
|
-
# gem "technoweenie-restful-authentication", :lib => "restful-authentication", :source => "http://gems.github.com/"
|
49
|
-
# gem "bookshop", "3.0", :git => "git://github.com/bookshop/bookshop"
|
50
|
-
#
|
51
|
-
def gem(*args)
|
52
|
-
options = args.extract_options!
|
53
|
-
name, version = args
|
54
|
-
|
55
|
-
# Deal with deprecated options
|
56
|
-
{ :env => :group, :only => :group,
|
57
|
-
:lib => :require, :require_as => :require }.each do |old, new|
|
58
|
-
next unless options[old]
|
59
|
-
options[new] = options.delete(old)
|
60
|
-
ActiveSupport::Deprecation.warn "#{old.inspect} option in gem is deprecated, use #{new.inspect} instead"
|
61
|
-
end
|
62
|
-
|
63
|
-
# Deal with deprecated source
|
64
|
-
if source = options.delete(:source)
|
65
|
-
ActiveSupport::Deprecation.warn ":source option in gem is deprecated, use add_source method instead"
|
66
|
-
add_source(source)
|
67
|
-
end
|
68
|
-
|
69
|
-
# Set the message to be shown in logs. Uses the git repo if one is given,
|
70
|
-
# otherwise use name (version).
|
71
|
-
parts, message = [ name.inspect ], name
|
72
|
-
if version ||= options.delete(:version)
|
73
|
-
parts << version.inspect
|
74
|
-
message << " (#{version})"
|
75
|
-
end
|
76
|
-
message = options[:git] if options[:git]
|
77
|
-
|
78
|
-
log :gemfile, message
|
79
|
-
|
80
|
-
options.each do |option, value|
|
81
|
-
parts << ":#{option} => #{value.inspect}"
|
82
|
-
end
|
83
|
-
|
84
|
-
in_root do
|
85
|
-
append_file "Gemfile", "gem #{parts.join(", ")}\n", :verbose => false
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# Add the given source to Gemfile
|
90
|
-
#
|
91
|
-
# ==== Example
|
92
|
-
#
|
93
|
-
# add_source "http://gems.github.com/"
|
94
|
-
def add_source(source, options={})
|
95
|
-
log :source, source
|
96
|
-
|
97
|
-
in_root do
|
98
|
-
prepend_file "Gemfile", "source #{source.inspect}\n", :verbose => false
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# Adds a line inside the Application class for config/application.rb.
|
103
|
-
#
|
104
|
-
# If options :env is specified, the line is appended to the corresponding
|
105
|
-
# file in config/environments.
|
106
|
-
#
|
107
|
-
def environment(data=nil, options={}, &block)
|
108
|
-
sentinel = /class [a-z_:]+ < Bookshop::Application/i
|
109
|
-
data = block.call if !data && block_given?
|
110
|
-
|
111
|
-
in_root do
|
112
|
-
if options[:env].nil?
|
113
|
-
inject_into_file 'config/application.rb', "\n #{data}", :after => sentinel, :verbose => false
|
114
|
-
else
|
115
|
-
Array.wrap(options[:env]).each do|env|
|
116
|
-
append_file "config/environments/#{env}.rb", "\n#{data}", :verbose => false
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
alias :application :environment
|
122
|
-
|
123
|
-
# Run a command in git.
|
124
|
-
#
|
125
|
-
# ==== Examples
|
126
|
-
#
|
127
|
-
# git :init
|
128
|
-
# git :add => "this.file that.rb"
|
129
|
-
# git :add => "onefile.rb", :rm => "badfile.cxx"
|
130
|
-
#
|
131
|
-
def git(command={})
|
132
|
-
if command.is_a?(Symbol)
|
133
|
-
run "git #{command}"
|
134
|
-
else
|
135
|
-
command.each do |command, options|
|
136
|
-
run "git #{command} #{options}"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
# Create a new file in the vendor/ directory. Code can be specified
|
142
|
-
# in a block or a data string can be given.
|
143
|
-
#
|
144
|
-
# ==== Examples
|
145
|
-
#
|
146
|
-
# vendor("sekrit.rb") do
|
147
|
-
# sekrit_salt = "#{Time.now}--#{3.years.ago}--#{rand}--"
|
148
|
-
# "salt = '#{sekrit_salt}'"
|
149
|
-
# end
|
150
|
-
#
|
151
|
-
# vendor("foreign.rb", "# Foreign code is fun")
|
152
|
-
#
|
153
|
-
def vendor(filename, data=nil, &block)
|
154
|
-
log :vendor, filename
|
155
|
-
create_file("vendor/#{filename}", data, :verbose => false, &block)
|
156
|
-
end
|
157
|
-
|
158
|
-
# Create a new file in the lib/ directory. Code can be specified
|
159
|
-
# in a block or a data string can be given.
|
160
|
-
#
|
161
|
-
# ==== Examples
|
162
|
-
#
|
163
|
-
# lib("crypto.rb") do
|
164
|
-
# "crypted_special_value = '#{rand}--#{Time.now}--#{rand(1337)}--'"
|
165
|
-
# end
|
166
|
-
#
|
167
|
-
# lib("foreign.rb", "# Foreign code is fun")
|
168
|
-
#
|
169
|
-
def lib(filename, data=nil, &block)
|
170
|
-
log :lib, filename
|
171
|
-
create_file("lib/#{filename}", data, :verbose => false, &block)
|
172
|
-
end
|
173
|
-
|
174
|
-
# Create a new Rakefile with the provided code (either in a block or a string).
|
175
|
-
#
|
176
|
-
# ==== Examples
|
177
|
-
#
|
178
|
-
# rakefile("bootstrap.rake") do
|
179
|
-
# project = ask("What is the UNIX name of your project?")
|
180
|
-
#
|
181
|
-
# <<-TASK
|
182
|
-
# namespace :#{project} do
|
183
|
-
# task :bootstrap do
|
184
|
-
# puts "i like boots!"
|
185
|
-
# end
|
186
|
-
# end
|
187
|
-
# TASK
|
188
|
-
# end
|
189
|
-
#
|
190
|
-
# rakefile("seed.rake", "puts 'im plantin ur seedz'")
|
191
|
-
#
|
192
|
-
def rakefile(filename, data=nil, &block)
|
193
|
-
log :rakefile, filename
|
194
|
-
create_file("lib/tasks/#{filename}", data, :verbose => false, &block)
|
195
|
-
end
|
196
|
-
|
197
|
-
# Create a new initializer with the provided code (either in a block or a string).
|
198
|
-
#
|
199
|
-
# ==== Examples
|
200
|
-
#
|
201
|
-
# initializer("globals.rb") do
|
202
|
-
# data = ""
|
203
|
-
#
|
204
|
-
# ['MY_WORK', 'ADMINS', 'BEST_COMPANY_EVAR'].each do
|
205
|
-
# data << "#{const} = :entp"
|
206
|
-
# end
|
207
|
-
#
|
208
|
-
# data
|
209
|
-
# end
|
210
|
-
#
|
211
|
-
# initializer("api.rb", "API_KEY = '123456'")
|
212
|
-
#
|
213
|
-
def initializer(filename, data=nil, &block)
|
214
|
-
log :initializer, filename
|
215
|
-
create_file("config/initializers/#{filename}", data, :verbose => false, &block)
|
216
|
-
end
|
217
|
-
|
218
|
-
# Generate something using a generator from Bookshop or a plugin.
|
219
|
-
# The second parameter is the argument string that is passed to
|
220
|
-
# the generator or an Array that is joined.
|
221
|
-
#
|
222
|
-
# ==== Example
|
223
|
-
#
|
224
|
-
# generate(:authenticated, "user session")
|
225
|
-
#
|
226
|
-
def generate(what, *args)
|
227
|
-
log :generate, what
|
228
|
-
argument = args.map {|arg| arg.to_s }.flatten.join(" ")
|
229
|
-
|
230
|
-
in_root { run_ruby_script("script/bookshop generate #{what} #{argument}", :verbose => false) }
|
231
|
-
end
|
232
|
-
|
233
|
-
# Runs the supplied rake task
|
234
|
-
#
|
235
|
-
# ==== Example
|
236
|
-
#
|
237
|
-
# rake("db:migrate")
|
238
|
-
# rake("db:migrate", :env => "production")
|
239
|
-
# rake("gems:install", :sudo => true)
|
240
|
-
#
|
241
|
-
def rake(command, options={})
|
242
|
-
log :rake, command
|
243
|
-
env = options[:env] || 'development'
|
244
|
-
sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : ''
|
245
|
-
in_root { run("#{sudo}#{extify(:rake)} #{command} BOOKSHOP_ENV=#{env}", :verbose => false) }
|
246
|
-
end
|
247
|
-
|
248
|
-
# Just run the capify command in root
|
249
|
-
#
|
250
|
-
# ==== Example
|
251
|
-
#
|
252
|
-
# capify!
|
253
|
-
#
|
254
|
-
def capify!
|
255
|
-
log :capify, ""
|
256
|
-
in_root { run("#{extify(:capify)} .", :verbose => false) }
|
257
|
-
end
|
258
|
-
|
259
|
-
# Add Bookshop to /vendor/bookshop
|
260
|
-
#
|
261
|
-
# ==== Example
|
262
|
-
#
|
263
|
-
# freeze!
|
264
|
-
#
|
265
|
-
def freeze!(args={})
|
266
|
-
ActiveSupport::Deprecation.warn "freeze! is deprecated since your bookshop app now comes bundled with Bookshop by default, please check your Gemfile"
|
267
|
-
end
|
268
|
-
|
269
|
-
# Make an entry in Bookshop routing file config/routes.rb
|
270
|
-
#
|
271
|
-
# === Example
|
272
|
-
#
|
273
|
-
# route "root :to => 'welcome'"
|
274
|
-
#
|
275
|
-
def route(routing_code)
|
276
|
-
log :route, routing_code
|
277
|
-
sentinel = /\.routes\.draw do(?:\s*\|map\|)?\s*$/
|
278
|
-
|
279
|
-
in_root do
|
280
|
-
inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false }
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
# Reads the given file at the source root and prints it in the console.
|
285
|
-
#
|
286
|
-
# === Example
|
287
|
-
#
|
288
|
-
# readme "README"
|
289
|
-
#
|
290
|
-
def readme(path)
|
291
|
-
say File.read(find_in_source_paths(path))
|
292
|
-
end
|
293
|
-
|
294
|
-
protected
|
295
|
-
|
296
|
-
# Define log for backwards compatibility. If just one argument is sent,
|
297
|
-
# invoke say, otherwise invoke say_status.
|
298
|
-
#
|
299
|
-
def log(*args)
|
300
|
-
if args.size == 1
|
301
|
-
say args.first.to_s
|
302
|
-
else
|
303
|
-
args << (self.behavior == :invoke ? :green : :red)
|
304
|
-
say_status *args
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
# Add an extension to the given name based on the platform.
|
309
|
-
#
|
310
|
-
def extify(name)
|
311
|
-
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
312
|
-
"#{name}.bat"
|
313
|
-
else
|
314
|
-
name
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
|
-
end
|
319
|
-
end
|
320
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'thor/group'
|
3
|
-
rescue LoadError
|
4
|
-
puts "Thor is not available.\nIf you ran this command from a git checkout " \
|
5
|
-
"of Bookshop, please make sure thor is installed,\nand run this command " \
|
6
|
-
"as `ruby #{$0} #{ARGV.join(" ")} --dev`"
|
7
|
-
exit
|
8
|
-
end
|
9
|
-
|
10
|
-
module Bookshop
|
11
|
-
module Generators
|
12
|
-
module Base
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|