nanoc3 3.2.4 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. metadata +14 -313
  2. data/.gemtest +0 -0
  3. data/ChangeLog +0 -3
  4. data/Gemfile +0 -29
  5. data/LICENSE +0 -19
  6. data/NEWS.md +0 -449
  7. data/README.md +0 -108
  8. data/Rakefile +0 -14
  9. data/bin/nanoc3 +0 -12
  10. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  11. data/lib/nanoc3.rb +0 -28
  12. data/lib/nanoc3/base.rb +0 -49
  13. data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
  14. data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
  15. data/lib/nanoc3/base/compilation/compiler.rb +0 -455
  16. data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
  17. data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
  18. data/lib/nanoc3/base/compilation/filter.rb +0 -165
  19. data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
  20. data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
  21. data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
  22. data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
  23. data/lib/nanoc3/base/compilation/rule.rb +0 -73
  24. data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
  25. data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
  26. data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
  27. data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
  28. data/lib/nanoc3/base/context.rb +0 -47
  29. data/lib/nanoc3/base/core_ext.rb +0 -6
  30. data/lib/nanoc3/base/core_ext/array.rb +0 -62
  31. data/lib/nanoc3/base/core_ext/hash.rb +0 -63
  32. data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
  33. data/lib/nanoc3/base/core_ext/string.rb +0 -46
  34. data/lib/nanoc3/base/directed_graph.rb +0 -275
  35. data/lib/nanoc3/base/errors.rb +0 -174
  36. data/lib/nanoc3/base/memoization.rb +0 -67
  37. data/lib/nanoc3/base/notification_center.rb +0 -84
  38. data/lib/nanoc3/base/ordered_hash.rb +0 -200
  39. data/lib/nanoc3/base/plugin_registry.rb +0 -165
  40. data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
  41. data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
  42. data/lib/nanoc3/base/source_data/configuration.rb +0 -24
  43. data/lib/nanoc3/base/source_data/data_source.rb +0 -234
  44. data/lib/nanoc3/base/source_data/item.rb +0 -301
  45. data/lib/nanoc3/base/source_data/layout.rb +0 -130
  46. data/lib/nanoc3/base/source_data/site.rb +0 -361
  47. data/lib/nanoc3/base/store.rb +0 -135
  48. data/lib/nanoc3/cli.rb +0 -133
  49. data/lib/nanoc3/cli/command.rb +0 -139
  50. data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
  51. data/lib/nanoc3/cli/commands/compile.rb +0 -280
  52. data/lib/nanoc3/cli/commands/create_item.rb +0 -62
  53. data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
  54. data/lib/nanoc3/cli/commands/create_site.rb +0 -410
  55. data/lib/nanoc3/cli/commands/debug.rb +0 -119
  56. data/lib/nanoc3/cli/commands/info.rb +0 -98
  57. data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
  58. data/lib/nanoc3/cli/commands/update.rb +0 -72
  59. data/lib/nanoc3/cli/commands/view.rb +0 -84
  60. data/lib/nanoc3/cli/commands/watch.rb +0 -125
  61. data/lib/nanoc3/cli/error_handler.rb +0 -193
  62. data/lib/nanoc3/cli/logger.rb +0 -91
  63. data/lib/nanoc3/data_sources.rb +0 -29
  64. data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
  65. data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
  66. data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
  67. data/lib/nanoc3/data_sources/filesystem.rb +0 -299
  68. data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
  69. data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
  70. data/lib/nanoc3/extra.rb +0 -22
  71. data/lib/nanoc3/extra/auto_compiler.rb +0 -103
  72. data/lib/nanoc3/extra/chick.rb +0 -125
  73. data/lib/nanoc3/extra/core_ext.rb +0 -4
  74. data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
  75. data/lib/nanoc3/extra/core_ext/time.rb +0 -19
  76. data/lib/nanoc3/extra/deployers.rb +0 -11
  77. data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
  78. data/lib/nanoc3/extra/file_proxy.rb +0 -40
  79. data/lib/nanoc3/extra/validators.rb +0 -12
  80. data/lib/nanoc3/extra/validators/links.rb +0 -264
  81. data/lib/nanoc3/extra/validators/w3c.rb +0 -95
  82. data/lib/nanoc3/extra/vcs.rb +0 -66
  83. data/lib/nanoc3/extra/vcses.rb +0 -17
  84. data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
  85. data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
  86. data/lib/nanoc3/extra/vcses/git.rb +0 -25
  87. data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
  88. data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
  89. data/lib/nanoc3/filters.rb +0 -53
  90. data/lib/nanoc3/filters/asciidoc.rb +0 -38
  91. data/lib/nanoc3/filters/bluecloth.rb +0 -19
  92. data/lib/nanoc3/filters/coderay.rb +0 -21
  93. data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
  94. data/lib/nanoc3/filters/erb.rb +0 -35
  95. data/lib/nanoc3/filters/erubis.rb +0 -27
  96. data/lib/nanoc3/filters/haml.rb +0 -27
  97. data/lib/nanoc3/filters/kramdown.rb +0 -20
  98. data/lib/nanoc3/filters/less.rb +0 -53
  99. data/lib/nanoc3/filters/markaby.rb +0 -20
  100. data/lib/nanoc3/filters/maruku.rb +0 -20
  101. data/lib/nanoc3/filters/mustache.rb +0 -24
  102. data/lib/nanoc3/filters/rainpress.rb +0 -19
  103. data/lib/nanoc3/filters/rdiscount.rb +0 -22
  104. data/lib/nanoc3/filters/rdoc.rb +0 -33
  105. data/lib/nanoc3/filters/redcarpet.rb +0 -27
  106. data/lib/nanoc3/filters/redcloth.rb +0 -47
  107. data/lib/nanoc3/filters/relativize_paths.rb +0 -45
  108. data/lib/nanoc3/filters/rubypants.rb +0 -20
  109. data/lib/nanoc3/filters/sass.rb +0 -66
  110. data/lib/nanoc3/filters/slim.rb +0 -25
  111. data/lib/nanoc3/filters/typogruby.rb +0 -23
  112. data/lib/nanoc3/filters/uglify_js.rb +0 -42
  113. data/lib/nanoc3/helpers.rb +0 -16
  114. data/lib/nanoc3/helpers/blogging.rb +0 -319
  115. data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
  116. data/lib/nanoc3/helpers/capturing.rb +0 -138
  117. data/lib/nanoc3/helpers/filtering.rb +0 -50
  118. data/lib/nanoc3/helpers/html_escape.rb +0 -55
  119. data/lib/nanoc3/helpers/link_to.rb +0 -151
  120. data/lib/nanoc3/helpers/rendering.rb +0 -140
  121. data/lib/nanoc3/helpers/tagging.rb +0 -71
  122. data/lib/nanoc3/helpers/text.rb +0 -44
  123. data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
  124. data/lib/nanoc3/tasks.rb +0 -10
  125. data/lib/nanoc3/tasks/clean.rake +0 -16
  126. data/lib/nanoc3/tasks/clean.rb +0 -29
  127. data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
  128. data/lib/nanoc3/tasks/validate.rake +0 -92
  129. data/nanoc3.gemspec +0 -49
  130. data/tasks/doc.rake +0 -16
  131. data/tasks/test.rake +0 -44
  132. data/test/base/core_ext/array_spec.rb +0 -73
  133. data/test/base/core_ext/hash_spec.rb +0 -98
  134. data/test/base/core_ext/pathname_spec.rb +0 -27
  135. data/test/base/core_ext/string_spec.rb +0 -37
  136. data/test/base/test_checksum_store.rb +0 -35
  137. data/test/base/test_code_snippet.rb +0 -31
  138. data/test/base/test_compiler.rb +0 -316
  139. data/test/base/test_compiler_dsl.rb +0 -161
  140. data/test/base/test_context.rb +0 -31
  141. data/test/base/test_data_source.rb +0 -46
  142. data/test/base/test_dependency_tracker.rb +0 -262
  143. data/test/base/test_directed_graph.rb +0 -283
  144. data/test/base/test_filter.rb +0 -83
  145. data/test/base/test_item.rb +0 -179
  146. data/test/base/test_item_rep.rb +0 -553
  147. data/test/base/test_layout.rb +0 -59
  148. data/test/base/test_memoization.rb +0 -90
  149. data/test/base/test_notification_center.rb +0 -34
  150. data/test/base/test_outdatedness_checker.rb +0 -394
  151. data/test/base/test_plugin.rb +0 -30
  152. data/test/base/test_rule.rb +0 -19
  153. data/test/base/test_rule_context.rb +0 -65
  154. data/test/base/test_site.rb +0 -190
  155. data/test/cli/commands/test_compile.rb +0 -33
  156. data/test/cli/commands/test_create_item.rb +0 -14
  157. data/test/cli/commands/test_create_layout.rb +0 -28
  158. data/test/cli/commands/test_create_site.rb +0 -24
  159. data/test/cli/commands/test_help.rb +0 -12
  160. data/test/cli/commands/test_info.rb +0 -11
  161. data/test/cli/commands/test_update.rb +0 -10
  162. data/test/cli/test_cli.rb +0 -102
  163. data/test/cli/test_error_handler.rb +0 -29
  164. data/test/cli/test_logger.rb +0 -10
  165. data/test/data_sources/test_filesystem.rb +0 -433
  166. data/test/data_sources/test_filesystem_unified.rb +0 -536
  167. data/test/data_sources/test_filesystem_verbose.rb +0 -357
  168. data/test/extra/core_ext/test_enumerable.rb +0 -30
  169. data/test/extra/core_ext/test_time.rb +0 -15
  170. data/test/extra/deployers/test_rsync.rb +0 -232
  171. data/test/extra/test_auto_compiler.rb +0 -417
  172. data/test/extra/test_file_proxy.rb +0 -19
  173. data/test/extra/test_vcs.rb +0 -22
  174. data/test/extra/validators/test_links.rb +0 -51
  175. data/test/extra/validators/test_w3c.rb +0 -47
  176. data/test/filters/test_asciidoc.rb +0 -22
  177. data/test/filters/test_bluecloth.rb +0 -18
  178. data/test/filters/test_coderay.rb +0 -44
  179. data/test/filters/test_colorize_syntax.rb +0 -283
  180. data/test/filters/test_erb.rb +0 -99
  181. data/test/filters/test_erubis.rb +0 -70
  182. data/test/filters/test_haml.rb +0 -96
  183. data/test/filters/test_kramdown.rb +0 -18
  184. data/test/filters/test_less.rb +0 -113
  185. data/test/filters/test_markaby.rb +0 -24
  186. data/test/filters/test_maruku.rb +0 -18
  187. data/test/filters/test_mustache.rb +0 -25
  188. data/test/filters/test_rainpress.rb +0 -29
  189. data/test/filters/test_rdiscount.rb +0 -31
  190. data/test/filters/test_rdoc.rb +0 -18
  191. data/test/filters/test_redcarpet.rb +0 -63
  192. data/test/filters/test_redcloth.rb +0 -33
  193. data/test/filters/test_relativize_paths.rb +0 -332
  194. data/test/filters/test_rubypants.rb +0 -18
  195. data/test/filters/test_sass.rb +0 -229
  196. data/test/filters/test_slim.rb +0 -35
  197. data/test/filters/test_typogruby.rb +0 -21
  198. data/test/filters/test_uglify_js.rb +0 -30
  199. data/test/gem_loader.rb +0 -11
  200. data/test/helper.rb +0 -179
  201. data/test/helpers/test_blogging.rb +0 -754
  202. data/test/helpers/test_breadcrumbs.rb +0 -81
  203. data/test/helpers/test_capturing.rb +0 -41
  204. data/test/helpers/test_filtering.rb +0 -106
  205. data/test/helpers/test_html_escape.rb +0 -32
  206. data/test/helpers/test_link_to.rb +0 -249
  207. data/test/helpers/test_rendering.rb +0 -89
  208. data/test/helpers/test_tagging.rb +0 -87
  209. data/test/helpers/test_text.rb +0 -24
  210. data/test/helpers/test_xml_sitemap.rb +0 -103
  211. data/test/tasks/test_clean.rb +0 -67
@@ -1,135 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3
4
-
5
- # An abstract superclass for classes that need to store data to the
6
- # filesystem, such as checksums, cached compiled content and dependency
7
- # graphs.
8
- #
9
- # Each store has a version number. When attempting to load data from a store
10
- # that has an incompatible version number, no data will be loaded, but
11
- # {#version_mismatch_detected} will be called.
12
- #
13
- # @abstract Subclasses must implement {#data} and {#data=}, and may
14
- # implement {#no_data_found} and {#version_mismatch_detected}.
15
- #
16
- # @api private
17
- class Store
18
-
19
- # @return [String] The name of the file where data will be loaded from and
20
- # stored to.
21
- attr_reader :filename
22
-
23
- # @return [Numeric] The version number corresponding to the file format
24
- # the data is in. When the file format changes, the version number
25
- # should be incremented.
26
- attr_reader :version
27
-
28
- # Creates a new store for the given filename.
29
- #
30
- # @param [String] filename The name of the file where data will be loaded
31
- # from and stored to.
32
- #
33
- # @param [Numeric] version The version number corresponding to the file
34
- # format the data is in. When the file format changes, the version
35
- # number should be incremented.
36
- def initialize(filename, version)
37
- @filename = filename
38
- @version = version
39
- end
40
-
41
- # @group Loading and storing data
42
-
43
- # @return The data that should be written to the disk
44
- #
45
- # @abstract This method must be implemented by the subclass.
46
- def data
47
- raise NotImplementedError.new("Nanoc3::Store subclasses must implement #data and #data=")
48
- end
49
-
50
- # @param new_data The data that has been loaded from the disk
51
- #
52
- # @abstract This method must be implemented by the subclass.
53
- #
54
- # @return [void]
55
- def data=(new_data)
56
- raise NotImplementedError.new("Nanoc3::Store subclasses must implement #data and #data=")
57
- end
58
-
59
- # Loads the data from the filesystem into memory. This method will set the
60
- # loaded data using the {#data=} method.
61
- #
62
- # @return [void]
63
- def load
64
- # Don’t load twice
65
- if @loaded
66
- return
67
- end
68
-
69
- # Check file existance
70
- if !File.file?(self.filename)
71
- no_data_found
72
- @loaded = true
73
- return
74
- end
75
-
76
- pstore.transaction do
77
- # Check version
78
- if pstore[:version] != self.version
79
- version_mismatch_detected
80
- @loaded = true
81
- return
82
- end
83
-
84
- # Load
85
- self.data = pstore[:data]
86
- @loaded = true
87
- end
88
- end
89
-
90
- # Undoes the effects of {#load}. Used when {#load} raises an exception.
91
- #
92
- # @api private
93
- def unload
94
- end
95
-
96
- # Stores the data contained in memory to the filesystem. This method will
97
- # use the {#data} method to fetch the data that should be written.
98
- #
99
- # @return [void]
100
- def store
101
- FileUtils.mkdir_p(File.dirname(self.filename))
102
-
103
- pstore.transaction do
104
- pstore[:data] = self.data
105
- pstore[:version] = self.version
106
- end
107
- end
108
-
109
- # @group Callback methods
110
-
111
- # Callback method that is called when no data file was found. By default,
112
- # this implementation does nothing, but it should probably be overridden
113
- # by the subclass.
114
- #
115
- # @return [void]
116
- def no_data_found
117
- end
118
-
119
- # Callback method that is called when a version mismatch is detected. By
120
- # default, this implementation does nothing, but it should probably be
121
- # overridden by the subclass.
122
- #
123
- # @return [void]
124
- def version_mismatch_detected
125
- end
126
-
127
- private
128
-
129
- def pstore
130
- @pstore ||= PStore.new(self.filename)
131
- end
132
-
133
- end
134
-
135
- end
@@ -1,133 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'cri'
4
-
5
- module Nanoc3::CLI
6
-
7
- module Commands
8
- end
9
-
10
- autoload 'Logger', 'nanoc3/cli/logger'
11
- autoload 'Command', 'nanoc3/cli/command'
12
- autoload 'ErrorHandler', 'nanoc3/cli/error_handler'
13
-
14
- # @return [Boolean] true if debug output is enabled, false if not
15
- #
16
- # @since 3.2.0
17
- def self.debug?
18
- @debug || false
19
- end
20
-
21
- # @param [Boolean] boolean true if debug output should be enabled,
22
- # false if it should not
23
- #
24
- # @return [void]
25
- #
26
- # @since 3.2.0
27
- def self.debug=(boolean)
28
- @debug = boolean
29
- end
30
-
31
- # Invokes the nanoc commandline tool with the given arguments.
32
- #
33
- # @param [Array<String>] args An array of commandline arguments
34
- #
35
- # @return [void]
36
- def self.run(args)
37
- Nanoc3::CLI::ErrorHandler.handle_while do
38
- self.setup
39
- self.load_custom_commands
40
- self.root_command.run(args)
41
- end
42
- end
43
-
44
- # Adds the given command to the collection of available commands.
45
- #
46
- # @param [Cri::Command] cmd The command to add
47
- #
48
- # @return [void]
49
- def self.add_command(cmd)
50
- self.root_command.add_command(cmd)
51
- end
52
-
53
- protected
54
-
55
- # Makes the commandline interface ready for using by loading the commands.
56
- #
57
- # @return [void]
58
- def self.setup
59
- # Reinit
60
- @root_command = nil
61
-
62
- # Add help command
63
- help_cmd = Cri::Command.new_basic_help
64
- self.add_command(help_cmd)
65
-
66
- # Add other commands
67
- cmd_filenames = Dir[File.dirname(__FILE__) + '/cli/commands/*.rb']
68
- cmd_filenames.each do |filename|
69
- next if File.basename(filename, '.rb') == 'nanoc'
70
- cmd = self.load_command_at(filename)
71
- self.add_command(cmd)
72
- end
73
- end
74
-
75
- # Loads the commands in `commands/`.
76
- #
77
- # @return [void]
78
- def self.load_custom_commands
79
- self.recursive_contents_of('commands').each do |filename|
80
- # Create command
81
- command = Nanoc3::CLI.load_command_at(filename)
82
-
83
- # Get supercommand
84
- pieces = filename.gsub(/^commands\/|\.rb$/, '').split('/')
85
- pieces = pieces[0, pieces.size-1] || []
86
- root = Nanoc3::CLI.root_command
87
- supercommand = pieces.inject(root) do |cmd, piece|
88
- cmd.nil? ? nil : cmd.command_named(piece)
89
- end
90
-
91
- # Add to supercommand
92
- if supercommand.nil?
93
- raise "Cannot load command at #{filename} because its supercommand cannot be found"
94
- end
95
- supercommand.add_command(command)
96
- end
97
- end
98
-
99
- # Loads the command in the file with the given filename.
100
- #
101
- # @param [String] filename The name of the file that contains the command
102
- #
103
- # @return [Cri::Command] The loaded command
104
- def self.load_command_at(filename, command_name=nil)
105
- # Load
106
- code = File.read(filename)
107
- cmd = Cri::Command.define(code, filename)
108
-
109
- # Set name
110
- command_name ||= File.basename(filename, '.rb')
111
- cmd.modify { name command_name }
112
-
113
- # Done
114
- cmd
115
- end
116
-
117
- # @return [Cri::Command] The root command, i.e. the commandline tool itself
118
- def self.root_command
119
- @root_command ||= begin
120
- filename = File.dirname(__FILE__) + "/cli/commands/nanoc.rb"
121
- self.load_command_at(filename)
122
- end
123
- end
124
-
125
- # @return [Array] The directory contents
126
- def self.recursive_contents_of(path)
127
- return [] unless File.directory?(path)
128
- files, dirs = *Dir[path + '/*'].sort.partition { |e| File.file?(e) }
129
- dirs.each { |d| files.concat self.recursive_contents_of(d) }
130
- files
131
- end
132
-
133
- end
@@ -1,139 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3::CLI
4
-
5
- # An abstract superclass for commands that can be executed. These are not
6
- # the same as Cri commands, but are used in conjuction with Cri commands.
7
- # nanoc commands will be called by Cri commands and will perform the actual
8
- # execution of the command, as well as perform error handling if necessary.
9
- class Command
10
-
11
- # @return [Hash] A hash contain the options and their values
12
- attr_reader :options
13
-
14
- # @return [Array] The list of arguments
15
- attr_reader :arguments
16
-
17
- # @return [Cri::Command] The Cri command
18
- attr_reader :command
19
-
20
- # @param [Hash] options A hash contain the options and their values
21
- #
22
- # @param [Array] arguments The list of arguments
23
- #
24
- # @param [Cri::Command] command The Cri command
25
- def initialize(options, arguments, command)
26
- @options = options
27
- @arguments = arguments
28
- @command = command
29
- end
30
-
31
- # Runs the command with the given options, arguments and Cri command. This
32
- # is a convenience method so that no individual command needs to be
33
- # created.
34
- #
35
- # @param [Hash] options A hash contain the options and their values
36
- #
37
- # @param [Array] arguments The list of arguments
38
- #
39
- # @param [Cri::Command] command The Cri command
40
- #
41
- # @return [void]
42
- def self.call(options, arguments, command)
43
- self.new(options, arguments, command).call
44
- end
45
-
46
- # Runs the command.
47
- #
48
- # @return [void]
49
- def call
50
- Nanoc3::CLI::ErrorHandler.handle_while(:command => self) do
51
- self.run
52
- end
53
- end
54
-
55
- # Performs the actual execution of the command.
56
- #
57
- # @return [void]
58
- #
59
- # @abstract
60
- def run
61
- end
62
-
63
- # Gets the site ({Nanoc3::Site} instance) in the current directory and
64
- # loads its data.
65
- #
66
- # @return [Nanoc3::Site] The site in the current working directory
67
- def site
68
- # Load site if possible
69
- @site ||= nil
70
- if File.file?('config.yaml') && @site.nil?
71
- begin
72
- @site = Nanoc3::Site.new('.')
73
- rescue Nanoc3::Errors::UnknownDataSource => e
74
- $stderr.puts "Unknown data source: #{e}"
75
- exit 1
76
- end
77
- end
78
-
79
- @site
80
- end
81
-
82
- protected
83
-
84
- # @return [Boolean] true if debug output is enabled, false if not
85
- #
86
- # @see Nanoc3::CLI.debug?
87
- def debug?
88
- Nanoc3::CLI.debug?
89
- end
90
-
91
- # Asserts that the current working directory contains a site
92
- # ({Nanoc3::Site} instance). If no site is present, prints an error
93
- # message and exits.
94
- #
95
- # @return [void]
96
- def require_site
97
- @site = nil
98
- if site.nil?
99
- $stderr.puts 'The current working directory does not seem to be a ' +
100
- 'valid/complete nanoc site directory; aborting.'
101
- exit 1
102
- end
103
- end
104
-
105
- # Sets the data source's VCS to the VCS with the given name. Does nothing
106
- # when the site's data source does not support VCSes (i.e. does not
107
- # implement #vcs=).
108
- #
109
- # @param [String] vcs_name The name of the VCS that should be used
110
- #
111
- # @return [void]
112
- def set_vcs(vcs_name)
113
- # Skip if not possible
114
- return if vcs_name.nil? || site.nil?
115
-
116
- # Find VCS
117
- vcs_class = Nanoc3::Extra::VCS.named(vcs_name.to_sym)
118
- if vcs_class.nil?
119
- $stderr.puts "A VCS named #{vcs_name} was not found; aborting."
120
- exit 1
121
- end
122
-
123
- site.data_sources.each do |data_source|
124
- # Skip if not possible
125
- next if !data_source.respond_to?(:vcs=)
126
-
127
- # Set VCS
128
- data_source.vcs = vcs_class.new
129
- end
130
- end
131
-
132
- # @return [Array] The compilation stack.
133
- def stack
134
- (self.site && self.site.compiler.stack) || []
135
- end
136
-
137
- end
138
-
139
- end
@@ -1,60 +0,0 @@
1
- # encoding: utf-8
2
-
3
- usage 'autocompile [options]'
4
- summary 'start the autocompiler'
5
- aliases :aco
6
- description <<-EOS
7
- Start the autocompiler web server. Unless specified, the web server will run
8
- on port 3000 and listen on all IP addresses. Running the autocompiler requires
9
- the 'mime/types' and 'rack' gems.
10
- EOS
11
-
12
- required :H, :handler, 'specify the handler to use (webrick/mongrel/...)'
13
- required :o, :host, 'specify the host to listen on (default: 0.0.0.0)'
14
- required :p, :port, 'specify the port to listen on (default: 3000)'
15
-
16
- run do |opts, args, cmd|
17
- Nanoc3::CLI::Commands::AutoCompile.call(opts, args, cmd)
18
- end
19
-
20
- module Nanoc3::CLI::Commands
21
-
22
- class AutoCompile < ::Nanoc3::CLI::Command
23
-
24
- def run
25
- require 'rack'
26
-
27
- # Make sure we are in a nanoc site directory
28
- self.require_site
29
-
30
- # Set options
31
- options_for_rack = {
32
- :Port => (options[:port] || 3000).to_i,
33
- :Host => (options[:host] || '0.0.0.0')
34
- }
35
-
36
- # Guess which handler we should use
37
- unless handler = Rack::Handler.get(options[:handler])
38
- begin
39
- handler = Rack::Handler::Mongrel
40
- rescue LoadError => e
41
- handler = Rack::Handler::WEBrick
42
- end
43
- end
44
-
45
- # Build app
46
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
47
- app = Rack::Builder.new do
48
- use Rack::CommonLogger, $stderr
49
- use Rack::ShowExceptions
50
- run autocompiler
51
- end.to_app
52
-
53
- # Run autocompiler
54
- puts "Running on http://#{options_for_rack[:Host]}:#{options_for_rack[:Port]}/"
55
- handler.run(app, options_for_rack)
56
- end
57
-
58
- end
59
-
60
- end