webgen 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/VERSION +1 -1
  4. data/data/webgen/passive_sources/stylesheets/api.css +2 -4
  5. data/data/webgen/passive_sources/templates/api.template +1 -1
  6. data/data/webgen/passive_sources/templates/feed.template +1 -1
  7. data/lib/webgen/cli.rb +67 -63
  8. data/lib/webgen/cli/commands/create.rb +4 -6
  9. data/lib/webgen/cli/commands/create_bundle.rb +8 -18
  10. data/lib/webgen/cli/commands/create_website.rb +15 -21
  11. data/lib/webgen/cli/commands/generate.rb +10 -16
  12. data/lib/webgen/cli/commands/install.rb +4 -6
  13. data/lib/webgen/cli/commands/show.rb +3 -3
  14. data/lib/webgen/cli/commands/show_bundles.rb +9 -13
  15. data/lib/webgen/cli/commands/show_config.rb +12 -18
  16. data/lib/webgen/cli/commands/show_dependencies.rb +7 -8
  17. data/lib/webgen/cli/commands/show_extensions.rb +10 -13
  18. data/lib/webgen/cli/commands/show_tree.rb +11 -16
  19. data/lib/webgen/cli/utils.rb +0 -18
  20. data/lib/webgen/content_processor.rb +2 -2
  21. data/lib/webgen/content_processor/sass.rb +6 -0
  22. data/lib/webgen/item_tracker/nodes.rb +8 -1
  23. data/lib/webgen/node_finder.rb +53 -31
  24. data/lib/webgen/path.rb +15 -3
  25. data/lib/webgen/path_handler/api.rb +23 -2
  26. data/lib/webgen/path_handler/page_utils.rb +5 -3
  27. data/lib/webgen/path_handler/sitemap.rb +1 -1
  28. data/lib/webgen/version.rb +1 -1
  29. data/test/webgen/path_handler/test_api.rb +24 -6
  30. data/test/webgen/path_handler/test_page_utils.rb +5 -0
  31. data/test/webgen/test_cli.rb +3 -3
  32. data/test/webgen/test_content_processor.rb +1 -0
  33. data/test/webgen/test_node_finder.rb +5 -4
  34. data/test/webgen/test_path.rb +14 -4
  35. metadata +52 -52
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4549cd7e320897cf555980fefa9d6f11a29c7d73
4
- data.tar.gz: 1e5fcd72bc28df47eb681939fe34c562f11fb09e
3
+ metadata.gz: 8a60ac4c86998c240ed99fd35a34d68d4c58a9ab
4
+ data.tar.gz: 36a48c6b290e92da90225f76b3dda06557fe57c9
5
5
  SHA512:
6
- metadata.gz: 8b30674ab19c718895f896a880b2a3d1c3d1416ab2234b9ccff7abced4cac9ae8aba8d63a8737f60da328e7eedbaa743d5196ca3a5c4e248bfa457bb535b6e09
7
- data.tar.gz: 8241e6eecf941a6232d7a0744d4ced310c63d42a11ddecb769ff59488c06512930784e92068ced694a52955fb9a75032a7bdfd5993d9d9a86a593a35a2456cad
6
+ metadata.gz: 54a4999cee44f7498f01c7e1131e8d64a17c0a8581cda6c4f79577541a436df7d2f9624a1ba79407fec581c923115ad01fca3037c1804c5f8c47e12fe4aeb9e5
7
+ data.tar.gz: fdcecf0497be5d33dc7514aab8775326132c8addfcc5d1fcf4c55e2742edcfff3007c789de6a63b37170a9bfac78bc9fd118920699a06bcd4048a2b73b83c7f0
data/Rakefile CHANGED
@@ -105,9 +105,9 @@ EOF
105
105
 
106
106
  #### Dependencies, requirements and files
107
107
 
108
- s.required_ruby_version = '>= 1.9.3'
108
+ s.required_ruby_version = '>= 2.0.0'
109
109
 
110
- s.add_dependency('cmdparse', '~> 2.0', '>= 2.0.5')
110
+ s.add_dependency('cmdparse', '~> 3.0', '>= 3.0.1')
111
111
  s.add_dependency('systemu', '~> 2.5')
112
112
  s.add_dependency('kramdown', '~> 1.3')
113
113
  s.add_development_dependency('rake', '>= 0.8.3')
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.4.0
@@ -61,7 +61,7 @@
61
61
  }
62
62
 
63
63
  .api-documentation .description p {
64
- margin: 1em 0.4em;
64
+ margin: 1em 0;
65
65
  }
66
66
 
67
67
  .api-documentation .description li p {
@@ -183,9 +183,8 @@
183
183
  .api-documentation .method-detail {
184
184
  margin: 0.5em 0;
185
185
  padding: 0.5em 0;
186
- cursor: pointer;
187
186
  }
188
- .api-documentation .method-detail:hover {
187
+ .api-documentation .method-detail:hover, .api-documentation :target {
189
188
  background-color: #f1edba;
190
189
  }
191
190
  .api-documentation .method-heading {
@@ -244,7 +243,6 @@
244
243
  }
245
244
 
246
245
  .api-documentation #attribute-method-details .method-detail:hover {
247
- background-color: transparent;
248
246
  cursor: default;
249
247
  }
250
248
  .api-documentation .attribute-access-type {
@@ -15,7 +15,7 @@ end
15
15
  --- name:klass pipeline:erb
16
16
  <% klass = context.node.node_info[:rdoc_object] %>
17
17
  <div class="api-documentation api-<%= klass.type %>">
18
- <h1 class="<%= klass.type %>"><%= klass.type %> <%= klass.full_name %></h1>
18
+ <h2 class="<%= klass.type %>"><%= klass.type %> <%= klass.full_name %></h2>
19
19
 
20
20
  <div class="description">
21
21
  <%= klass.description %>
@@ -42,7 +42,7 @@
42
42
  <rss version="2.0">
43
43
  <channel>
44
44
  <title><%= h(context.node['title']) %></title>
45
- <link><%= context.node.feed_link %>"</link>
45
+ <link><%= context.node.feed_link %></link>
46
46
  <description><%= h(context.node['description']) %></description>
47
47
  <% if context.node['created_at'].kind_of?(Time) %>
48
48
  <pubdate><%= context.node['created_at'].rfc822 %></pubdate>
@@ -19,7 +19,7 @@ module Webgen
19
19
  #
20
20
  # A CLI command is an extension that can be invoked from the webgen CLI and thus needs to be
21
21
  # derived from CmdParse::Command. For detailed information on this class and the whole cmdparse
22
- # package have a look at http://cmdparse.rubyforge.org!
22
+ # package have a look at http://cmdparse.gettalong.org!
23
23
  #
24
24
  # == Sample CLI command extension
25
25
  #
@@ -28,39 +28,31 @@ module Webgen
28
28
  # class SampleCommand < CmdParse::Command
29
29
  #
30
30
  # def initialize
31
- # super('sample', false)
32
- # self.short_desc = "This sample command just outputs its parameters"
33
- # self.description = Webgen::CLI::Utils.format_command_desc("Uses the global verbosity level " +
34
- # "and outputs additional "information when the level is set to verbose!")
31
+ # super('sample', takes_commands: false)
32
+ # short_desc("This sample command just outputs its parameters")
33
+ # description("Uses the global verbosity level and outputs additional information when " +
34
+ # "the level is set to verbose!")
35
35
  # @username = nil
36
- # self.options = CmdParse::OptionParserWrapper.new do |opts|
37
- # opts.separator "Options:"
38
- # opts.on('-u', '--user USER', String,
39
- # *Webgen::CLI::Util.format_option_desc('Specify an additional user name to output')) do |username|
40
- # @username = username
41
- # end
36
+ # options.on('-u', '--user USER', String, 'Specify an additional user name to output') do |username|
37
+ # @username = username
42
38
  # end
43
39
  # end
44
40
  #
45
- # def execute(args)
46
- # if args.length == 0
47
- # raise OptionParser::MissingArgument.new('ARG1 [ARG2 ...]')
48
- # else
49
- # puts "Command line arguments:"
50
- # args.each {|arg| puts arg}
51
- # if commandparser.log_level <= 1
52
- # puts "Some debug information here"
53
- # end
54
- # puts "The entered username: #{@username}" if @username
41
+ # def execute(required, *optional)
42
+ # puts "Command line arguments:"
43
+ # ([required] + optional).each {|arg| puts arg}
44
+ # if command_parser.log_level <= 1
45
+ # puts "Some debug information here"
55
46
  # end
47
+ # puts "The entered username: #{@username}" if @username
56
48
  # end
57
49
  #
58
50
  # end
59
51
  #
60
52
  # website.ext.cli.add_command(SampleCommand.new)
61
53
  #
62
- # Note the use of Webgen::CLI::Utils.format in the initialize method so that the long text gets
63
- # wrapped correctly! The Utils class provides some other useful methods, too!
54
+ # The Webgen::CLI::Utils module provides some useful methods for outputting formatted or
55
+ # highlighted text.
64
56
  #
65
57
  module CLI
66
58
 
@@ -91,65 +83,67 @@ module Webgen
91
83
 
92
84
  # Create a new CommandParser class.
93
85
  def initialize
94
- super(false, true, false)
86
+ super(handle_exceptions: :no_help)
95
87
  @directory = nil
96
88
  @verbose = false
97
89
  @do_search = false
98
90
  @log_level = ::Logger::INFO
99
91
  @config_options = {}
100
92
 
101
- self.add_command(CmdParse::VersionCommand.new)
102
- self.add_command(CmdParse::HelpCommand.new)
93
+ add_command(CmdParse::VersionCommand.new(add_switches: false))
94
+ add_command(CmdParse::HelpCommand.new)
103
95
 
104
- self.program_name = "webgen"
105
- self.program_version = Webgen::VERSION
106
- self.options = CmdParse::OptionParserWrapper.new do |opts|
107
- opts.separator "Global options:"
108
- opts.on("--directory DIR", "-d", String,
109
- *Utils.format_option_desc("The website directory to use")) do |d|
96
+ main_options.program_name = "webgen"
97
+ main_options.version = Webgen::VERSION
98
+ main_options do |opts|
99
+ opts.on("--directory DIR", "-d", String, "The website directory to use") do |d|
110
100
  @directory = d
111
101
  end
112
- opts.on("--search-dirs", "-s",
113
- *Utils.format_option_desc("Search parent directories for website directory")) do |s|
102
+ opts.on("--search-dirs", "-s", "Search parent directories for website directory") do |s|
114
103
  @do_search = s
115
104
  end
116
- opts.on("-c", "--[no-]color",
117
- *Utils.format_option_desc("Colorize output (default: #{Webgen::CLI::Utils.use_colors ? "yes" : "no"})")) do |a|
105
+ opts.on("--version", "-V", "Show webgen version information") do
106
+ main_command.commands['version'].execute
107
+ end
108
+ end
109
+
110
+ global_options do |opts|
111
+ opts.on("-c", "--[no-]color", "Colorize output (default: #{Webgen::CLI::Utils.use_colors ? "yes" : "no"})") do |a|
118
112
  Webgen::CLI::Utils.use_colors = a
119
113
  end
120
- opts.on("-v", "--[no-]verbose",
121
- *Utils.format_option_desc("Verbose output (default: no)")) do |v|
114
+ opts.on("-v", "--[no-]verbose", "Verbose output (default: no)") do |v|
122
115
  @verbose = v
116
+ update_logger(@website.logger) unless @website.nil?
123
117
  end
124
- opts.on("-q", "--[no-]quiet",
125
- *Utils.format_option_desc("Quiet output (default: no)")) do |v|
118
+ opts.on("-q", "--[no-]quiet", "Quiet output (default: no)") do |v|
126
119
  @log_level = (v ? ::Logger::WARN : :Logger::INFO)
120
+ update_logger(@website.logger) unless @website.nil?
127
121
  end
128
- opts.on("-n", "--[no-]dry-run",
129
- *Utils.format_option_desc("Do a dry run, i.e. don't actually write anything (default: no)")) do |v|
122
+ opts.on("-n", "--[no-]dry-run", "Do a dry run, i.e. don't actually write anything (default: no)") do |v|
130
123
  @config_options['website.dry_run'] = v
124
+ unless @website.nil?
125
+ update_config(@website.config)
126
+ update_logger(@website.logger)
127
+ end
131
128
  end
132
- opts.on("-o", "--option CONFIG_OPTION", String,
133
- *Utils.format_option_desc("Specify a simple configuration option (key=value)")) do |v|
129
+ opts.on("-o", "--option CONFIG_OPTION", String, "Specify a simple configuration option (key=value)") do |v|
134
130
  k, v = v.split('=')
135
131
  begin
136
132
  @config_options[k.to_s] = YAML.load(v.to_s)
137
133
  rescue YAML::SyntaxError
138
134
  raise ConfigurationOptionError.new("Couldn't parse value for '#{k}': #{$!}")
139
135
  end
136
+ update_config(@website.config) unless @website.nil?
140
137
  end
141
- opts.on("--[no-]debug",
142
- *Utils.format_option_desc("Enable debugging")) do |v|
138
+ opts.on("--[no-]debug", "Enable debugging") do |v|
143
139
  @log_level = (v ? ::Logger::DEBUG : :Logger::INFO)
144
- end
145
- opts.on_tail("--version", "-V", "Show webgen version information") do
146
- main_command.commands['version'].execute([])
140
+ update_logger(@website.logger) unless @website.nil?
147
141
  end
148
142
  end
149
- self.add_command(Webgen::CLI::GenerateCommand.new, true)
150
- self.add_command(Webgen::CLI::ShowCommand.new)
151
- self.add_command(Webgen::CLI::CreateCommand.new)
152
- self.add_command(Webgen::CLI::InstallCommand.new)
143
+ add_command(Webgen::CLI::GenerateCommand.new, default: true)
144
+ add_command(Webgen::CLI::ShowCommand.new)
145
+ add_command(Webgen::CLI::CreateCommand.new)
146
+ add_command(Webgen::CLI::InstallCommand.new)
153
147
  end
154
148
 
155
149
  # Utility method for getting the Webgen::Website object.
@@ -169,20 +163,30 @@ module Webgen
169
163
  @website = Webgen::Website.new(@directory, Webgen::CLI::Logger.new) do |site, before_init|
170
164
  if before_init
171
165
  site.ext.cli = self
172
- site.logger.level = @log_level
173
- site.logger.verbose = @verbose
174
- site.logger.prefix = '[DRY-RUN] ' if @config_options['website.dry_run']
166
+ update_logger(site.logger)
175
167
  else
176
- @config_options.each do |k, v|
177
- if site.config.option?(k)
178
- site.config[k] = v
179
- else
180
- raise ConfigurationOptionError.new("Unknown option '#{k}'")
181
- end
182
- end
168
+ update_config(site.config)
169
+ end
170
+ end
171
+ end
172
+
173
+ def update_logger(logger)
174
+ logger.level = @log_level
175
+ logger.verbose = @verbose
176
+ logger.prefix = '[DRY-RUN] ' if @config_options['website.dry_run']
177
+ end
178
+ private :update_logger
179
+
180
+ def update_config(config)
181
+ @config_options.each do |k, v|
182
+ if config.option?(k)
183
+ config[k] = v
184
+ else
185
+ raise ConfigurationOptionError.new("Unknown option '#{k}'")
183
186
  end
184
187
  end
185
188
  end
189
+ private :update_config
186
190
 
187
191
  # Parse the command line arguments.
188
192
  #
@@ -11,12 +11,10 @@ module Webgen
11
11
  class CreateCommand < CmdParse::Command
12
12
 
13
13
  def initialize # :nodoc:
14
- super('create', true, true, false)
15
- self.short_desc = 'Create some product'
16
- self.description = Webgen::CLI::Utils.format_command_desc(<<DESC)
17
- Groups various commands together that are used for creating products, like a
18
- website or an extension bundle.
19
- DESC
14
+ super('create')
15
+ short_desc('Create a website or an extension bundle')
16
+ long_desc("Groups various commands together that are used for creating products, like a " +
17
+ "website or an extension bundle")
20
18
  add_command(CreateWebsiteCommand.new)
21
19
  add_command(CreateBundleCommand.new)
22
20
  end
@@ -11,33 +11,23 @@ module Webgen
11
11
  class CreateBundleCommand < CmdParse::Command
12
12
 
13
13
  def initialize # :nodoc:
14
- super('bundle', false, false, true)
15
- self.short_desc = 'Create an extension bundle'
16
- self.description = Utils.format_command_desc(<<DESC)
14
+ super('bundle', takes_commands: false)
15
+ short_desc('Create an extension bundle')
16
+ long_desc(<<DESC)
17
17
  Creates a new extension bundle. This command can either create a local bundle in the
18
18
  website's ext/ directory or a bundle that can be distributed via Rubygems. In the
19
19
  latter case you can optionally specify the directory under which the bundle should
20
20
  be created.
21
21
  DESC
22
- self.options = CmdParse::OptionParserWrapper.new do |opts|
23
- opts.separator "Options:"
24
- opts.on("-d", "--distribution-format",
25
- *Utils.format_option_desc("Create the bundle in distribution format")) do
26
- @type = :gem
27
- end
22
+ options.on("-d", "--distribution-format", "Create the bundle in distribution format") do
23
+ @type = :gem
28
24
  end
29
25
  @type = :local
30
26
  end
31
27
 
32
- def usage # :nodoc:
33
- "Usage: webgen [global options] create bundle [options] BUNDLE_NAME [DIRECTORY]"
34
- end
35
-
36
- def execute(args) # :nodoc:
37
- bundle_name = args.shift
38
- raise "The argument NAME is mandatory" if bundle_name.to_s.empty?
39
- directory = args.shift || bundle_name
40
- commandparser.website.execute_task(:create_bundle, bundle_name, @type, directory)
28
+ def execute(bundle_name, directory = nil) # :nodoc:
29
+ directory ||= bundle_name
30
+ command_parser.website.execute_task(:create_bundle, bundle_name, @type, directory)
41
31
  end
42
32
 
43
33
  end
@@ -10,9 +10,9 @@ module Webgen
10
10
  class CreateWebsiteCommand < CmdParse::Command
11
11
 
12
12
  def initialize # :nodoc:
13
- super('website', false)
14
- self.short_desc = 'Create a basic webgen website'
15
- self.description = Utils.format_command_desc(<<DESC)
13
+ super('website', takes_commands: false)
14
+ short_desc('Create a basic webgen website')
15
+ long_desc(<<DESC)
16
16
  Creates a webgen website at the specified directory. If the --template
17
17
  option is not used, a basic website is created. Otherwise the template
18
18
  defines the content of website.
@@ -22,36 +22,30 @@ displayed.
22
22
  DESC
23
23
 
24
24
  @template = nil
25
- self.options = CmdParse::OptionParserWrapper.new do |opts|
26
- opts.separator "Options:"
27
- opts.on('-t', '--template TEMPLATE', String, "A website template (optional)") do |val|
28
- @template = val
29
- end
30
- opts.separator ""
31
- opts.separator "Arguments:"
32
- opts.separator opts.summary_indent + "DIR: the directory in which the website should be created"
25
+ options.on('-t', '--template TEMPLATE', String, "A website template (optional)") do |val|
26
+ @template = val
33
27
  end
34
28
  end
35
29
 
36
- def show_help #:nodoc:
37
- super
38
- templates = commandparser.website.ext.task.data(:create_website)[:templates].keys.sort
39
- puts "Available templates:"
30
+ def help #:nodoc:
31
+ help_output = super
32
+ templates = command_parser.website.ext.task.data(:create_website)[:templates].keys.sort
33
+ help_output << "Available templates:\n"
40
34
  output = if templates.empty?
41
35
  "No templates available"
42
36
  else
43
37
  templates.join(', ')
44
38
  end
45
- puts Utils.format(output, Utils::DEFAULT_WIDTH - 4, 4, true).join("\n")
39
+ help_output << Utils.format(output, command_parser.help_line_width - command_parser.help_indent,
40
+ command_parser.help_indent, true).join("\n")
46
41
  end
47
42
 
48
- def execute(args) # :nodoc:
49
- raise OptionParser::MissingArgument.new('DIR') if args.length == 0
50
- Webgen::Website.new(args[0], Webgen::CLI::Logger.new) do |website|
51
- website.logger.verbose = commandparser.verbose
43
+ def execute(dir) # :nodoc:
44
+ Webgen::Website.new(dir, Webgen::CLI::Logger.new) do |website|
45
+ website.logger.verbose = command_parser.verbose
52
46
  website.config['website.tmpdir'] = Dir.tmpdir
53
47
  end.execute_task(:create_website, @template)
54
- puts "Created a new webgen website in <#{args[0]}>" + (@template ? " using the '#{@template}' template" : '')
48
+ puts "Created a new webgen website in <#{dir}>" + (@template ? " using the '#{@template}' template" : '')
55
49
  rescue Webgen::Task::CreateWebsite::Error => e
56
50
  puts "An error occured while creating the website: #{e.message}"
57
51
  end
@@ -9,24 +9,18 @@ module Webgen
9
9
  class GenerateCommand < CmdParse::Command
10
10
 
11
11
  def initialize # :nodoc:
12
- super('generate', false, false, false)
13
- self.short_desc = 'Generate the webgen website'
14
- self.description = Webgen::CLI::Utils.format_command_desc(<<EOF)
15
- This command is executed by default when no other command was specified.
16
- EOF
17
- self.options = CmdParse::OptionParserWrapper.new do |opts|
18
- opts.separator "Options:"
19
- opts.on('-a', '--auto [SEC]', Integer,
20
- *Utils.format_option_desc("Auto-generate the website every SEC seconds (5=default, 0=off)")) do |val|
21
- @auto_generate_secs = val || 5
22
- end
12
+ super('generate', takes_commands: false)
13
+ short_desc('Generate the webgen website')
14
+ long_desc("This command is executed by default when no other command was specified.")
15
+ options.on('-a', '--auto [SEC]', Integer, "Auto-generate the website every SEC seconds (5=default, 0=off)") do |val|
16
+ @auto_generate_secs = val || 5
23
17
  end
24
18
  @auto_generate_secs = 0
25
19
  end
26
20
 
27
- def execute(args) # :nodoc:
21
+ def execute # :nodoc:
28
22
  if @auto_generate_secs <= 0
29
- commandparser.website.execute_task(:generate_website)
23
+ command_parser.website.execute_task(:generate_website)
30
24
  else
31
25
  auto_generate
32
26
  end
@@ -38,8 +32,8 @@ EOF
38
32
  time = Time.now
39
33
  abort = false
40
34
  old_paths = []
41
- dirs = "{" << commandparser.website.config['sources'].map do |mp, type, *args|
42
- type == :file_system ? File.join(commandparser.website.directory, args[0], args[1] || '**/*') : nil
35
+ dirs = "{" << command_parser.website.config['sources'].map do |mp, type, *args|
36
+ type == :file_system ? File.join(command_parser.website.directory, args[0], args[1] || '**/*') : nil
43
37
  end.compact.join(',') << "}"
44
38
 
45
39
  Signal.trap('INT') {abort = true}
@@ -48,7 +42,7 @@ EOF
48
42
  paths = Dir[dirs].sort
49
43
  if old_paths != paths || paths.any? {|p| File.file?(p) && File.mtime(p) > time}
50
44
  begin
51
- commandparser.website(true).execute_task(:generate_website)
45
+ command_parser.website(true).execute_task(:generate_website)
52
46
  rescue Webgen::Error => e
53
47
  puts e.message
54
48
  end