nanoc 4.0.0a2 → 4.0.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +16 -2
  3. data/NEWS.md +23 -1
  4. data/lib/nanoc/base/compilation/compiler.rb +4 -3
  5. data/lib/nanoc/base/compilation/compiler_dsl.rb +9 -5
  6. data/lib/nanoc/base/compilation/filter.rb +2 -0
  7. data/lib/nanoc/base/source_data/identifier.rb +12 -1
  8. data/lib/nanoc/base/views/item.rb +3 -16
  9. data/lib/nanoc/base/views/item_collection.rb +10 -0
  10. data/lib/nanoc/base/views/item_rep.rb +0 -75
  11. data/lib/nanoc/base/views/layout_collection.rb +34 -0
  12. data/lib/nanoc/base/views/site.rb +0 -20
  13. data/lib/nanoc/cli/commands/compile.rb +0 -3
  14. data/lib/nanoc/cli/commands/create-site.rb +1 -1
  15. data/lib/nanoc/cli/commands/shell.rb +1 -1
  16. data/lib/nanoc/helpers/capturing.rb +5 -5
  17. data/lib/nanoc/helpers/filtering.rb +3 -3
  18. data/lib/nanoc/helpers/rendering.rb +5 -4
  19. data/lib/nanoc/helpers/tagging.rb +3 -4
  20. data/lib/nanoc/version.rb +1 -1
  21. data/tasks/test.rake +1 -1
  22. data/test/base/test_compiler_dsl.rb +29 -0
  23. data/test/cli/commands/test_create_site.rb +10 -0
  24. data/test/filters/test_markaby.rb +0 -6
  25. data/test/helper.rb +0 -1
  26. data/test/helpers/test_capturing.rb +13 -11
  27. data/test/helpers/test_filtering.rb +6 -0
  28. data/test/helpers/test_rendering.rb +48 -9
  29. data/test/helpers/test_tagging.rb +5 -5
  30. metadata +2 -9
  31. data/lib/nanoc/tasks.rb +0 -11
  32. data/lib/nanoc/tasks/clean.rake +0 -16
  33. data/lib/nanoc/tasks/clean.rb +0 -23
  34. data/lib/nanoc/tasks/deploy/rsync.rake +0 -16
  35. data/lib/nanoc/tasks/validate.rake +0 -30
  36. data/test/extra/test_file_proxy.rb +0 -15
  37. data/test/tasks/test_clean.rb +0 -63
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1055bcfad80c114e2f54b3e67d89468c828ce18
4
- data.tar.gz: 121523a9ee6c375e4a4dc4fc56c680f7501b97ad
3
+ metadata.gz: 90ed92857b63ba5cdfc7ea40b6f8a47d028a9dd4
4
+ data.tar.gz: 634df8e12745fe703ff012cea92e430a90dc5880
5
5
  SHA512:
6
- metadata.gz: 0da18d11db64365759e7be6dd9c6fd72334baa823813d39c7286d34f8ebf406cf73bb1059c2dc35d1955c0697495af986bb657a2003ac1ef7f88b8e1c19be249
7
- data.tar.gz: 609b1ec27cad20f169346917dd688d08dbb4e8a12b4497d4884a1bb3f2dcf1492b36e34a9a4c6d27c77d58f6d346d98c4c6ee37933dc884932acb8dfebeefb3f
6
+ metadata.gz: 0fcd435c5cfd92929ce88041689e8ad9cfe370194335a40d70ead941acdb22579a4741d53a3331bf75ff1cf248496233289140d207c0a734893859398b34306c
7
+ data.tar.gz: 3e19e77f09ae7a5afbc52cfadf2a53f10e267e2c4dba4c436b75b749181ec1972adcf07f4795015074ec799fec2bd7afeaf1b7fbe2afd90b8983c6c0fca0ca8d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nanoc (4.0.0a2)
4
+ nanoc (4.0.0b1)
5
5
  cri (~> 2.3)
6
6
 
7
7
  GEM
@@ -9,6 +9,7 @@ GEM
9
9
  specs:
10
10
  CFPropertyList (2.3.1)
11
11
  RedCloth (4.2.9)
12
+ RedCloth (4.2.9-java)
12
13
  addressable (2.3.8)
13
14
  adsf (1.2.0)
14
15
  rack (>= 1.0.0)
@@ -49,6 +50,7 @@ GEM
49
50
  excon (0.45.3)
50
51
  execjs (2.5.2)
51
52
  ffi (1.9.8)
53
+ ffi (1.9.8-java)
52
54
  fission (0.5.0)
53
55
  CFPropertyList (~> 2.2)
54
56
  fog (1.30.0)
@@ -127,7 +129,7 @@ GEM
127
129
  fog-serverlove (0.1.2)
128
130
  fog-core
129
131
  fog-json
130
- fog-softlayer (0.4.5)
132
+ fog-softlayer (0.4.6)
131
133
  fog-core
132
134
  fog-json
133
135
  fog-storm_on_demand (0.1.1)
@@ -154,11 +156,13 @@ GEM
154
156
  therubyracer (~> 0.12.1)
155
157
  handlebars-source (3.0.3)
156
158
  hitimes (1.2.2)
159
+ hitimes (1.2.2-java)
157
160
  http-cookie (1.0.2)
158
161
  domain_name (~> 0.5)
159
162
  inflecto (0.0.2)
160
163
  ipaddress (0.8.0)
161
164
  json (1.8.2)
165
+ json (1.8.2-java)
162
166
  kramdown (1.7.0)
163
167
  less (2.6.0)
164
168
  commonjs (~> 0.2.7)
@@ -185,6 +189,7 @@ GEM
185
189
  netrc (0.10.3)
186
190
  nokogiri (1.6.6.2)
187
191
  mini_portile (~> 0.6.0)
192
+ nokogiri (1.6.6.2-java)
188
193
  pandoc-ruby (1.0.0)
189
194
  parser (2.2.2.2)
190
195
  ast (>= 1.1, < 3.0)
@@ -194,6 +199,11 @@ GEM
194
199
  coderay (~> 1.1.0)
195
200
  method_source (~> 0.8.1)
196
201
  slop (~> 3.4)
202
+ pry (0.10.1-java)
203
+ coderay (~> 1.1.0)
204
+ method_source (~> 0.8.1)
205
+ slop (~> 3.4)
206
+ spoon (~> 0.0)
197
207
  pygments.rb (0.6.3)
198
208
  posix-spawn (~> 0.3.6)
199
209
  yajl-ruby (~> 1.2.0)
@@ -245,6 +255,8 @@ GEM
245
255
  temple (~> 0.7.3)
246
256
  tilt (>= 1.3.3, < 2.1)
247
257
  slop (3.6.0)
258
+ spoon (0.0.4)
259
+ ffi
248
260
  temple (0.7.5)
249
261
  term-ansicolor (1.3.0)
250
262
  tins (~> 1.0)
@@ -263,6 +275,7 @@ GEM
263
275
  json (>= 1.8.0)
264
276
  unf (0.1.4)
265
277
  unf_ext
278
+ unf (0.1.4-java)
266
279
  unf_ext (0.0.7.1)
267
280
  vcr (2.9.3)
268
281
  w3c_validators (1.2)
@@ -276,6 +289,7 @@ GEM
276
289
  yuicompressor (1.3.3)
277
290
 
278
291
  PLATFORMS
292
+ java
279
293
  ruby
280
294
 
281
295
  DEPENDENCIES
data/NEWS.md CHANGED
@@ -1,6 +1,28 @@
1
1
  # nanoc news
2
2
 
3
- ## 4.0.0a2 (2015-05-??)
3
+ ## 4.0.0b1 (2015-05-??)
4
+
5
+ Changes:
6
+
7
+ * Removed tasks
8
+ * Removed several private methods in the view API
9
+ * Removed default `base_url` in tagging helper
10
+
11
+ Enhancements:
12
+
13
+ * Removed unused options from CLI
14
+ * Added `Nanoc::Identifier#without_ext`
15
+ * Made `Nanoc::Identifier#=~` work with a glob
16
+ * Added `Nanoc::LayoutCollectionView#[]`
17
+ * Added `--force` to `create-site` command (#549) [David Alexander]
18
+
19
+ Fixes:
20
+
21
+ * Fixed `#passthrough` for identifiers with extensions
22
+ * Fixed rendering helper for identifiers with extensions
23
+ * Fixed filtering helper
24
+
25
+ ## 4.0.0a2 (2015-05-12)
4
26
 
5
27
  Features:
6
28
 
@@ -336,9 +336,10 @@ module Nanoc::Int
336
336
  compile_rep(rep)
337
337
  content_dependency_graph.delete_vertex(rep)
338
338
  rescue Nanoc::Int::Errors::UnmetDependency => e
339
- content_dependency_graph.add_edge(e.rep, rep)
340
- unless content_dependency_graph.vertices.include?(e.rep)
341
- content_dependency_graph.add_vertex(e.rep)
339
+ other_rep = e.rep.unwrap rescue e.rep
340
+ content_dependency_graph.add_edge(other_rep, rep)
341
+ unless content_dependency_graph.vertices.include?(other_rep)
342
+ content_dependency_graph.add_vertex(other_rep)
342
343
  end
343
344
  end
344
345
  end
@@ -194,11 +194,15 @@ module Nanoc::Int
194
194
 
195
195
  # Create routing rule
196
196
  routing_block = proc do
197
- # This is a temporary solution until an item can map back to its data
198
- # source.
199
- # ATM item[:content_filename] is nil for items coming from the static
200
- # data source.
201
- item[:extension].nil? || (item[:content_filename].nil? && item.identifier =~ %r{#{item[:extension]}/$}) ? item.identifier.chop : item.identifier.chop + '.' + item[:extension]
197
+ if item.identifier.full?
198
+ item.identifier.to_s
199
+ else
200
+ # This is a temporary solution until an item can map back to its data
201
+ # source.
202
+ # ATM item[:content_filename] is nil for items coming from the static
203
+ # data source.
204
+ item[:extension].nil? || (item[:content_filename].nil? && item.identifier =~ %r{#{item[:extension]}/$}) ? item.identifier.chop : item.identifier.chop + '.' + item[:extension]
205
+ end
202
206
  end
203
207
  routing_rule = Nanoc::Int::Rule.new(create_pattern(identifier), rep_name, routing_block, snapshot_name: :last)
204
208
  @rules_collection.add_item_routing_rule(routing_rule)
@@ -185,6 +185,8 @@ module Nanoc
185
185
  #
186
186
  # @return [void]
187
187
  def depend_on(items)
188
+ items = items.map { |i| i.unwrap rescue i }
189
+
188
190
  # Notify
189
191
  items.each do |item|
190
192
  Nanoc::Int::NotificationCenter.post(:visit_started, item)
@@ -43,13 +43,19 @@ module Nanoc
43
43
  end
44
44
 
45
45
  def =~(pat)
46
- to_s =~ pat
46
+ Nanoc::Int::Pattern.from(pat).match?(to_s) ? 0 : nil
47
47
  end
48
48
 
49
49
  def <=>(other)
50
50
  to_s <=> other.to_s
51
51
  end
52
52
 
53
+ # @return [Boolean] True if this is a full-style identifier (i.e. includes
54
+ # the extension), false otherwise
55
+ def full?
56
+ @style == :full
57
+ end
58
+
53
59
  # @return [String]
54
60
  def chop
55
61
  to_s.chop
@@ -97,6 +103,11 @@ module Nanoc
97
103
  end
98
104
  end
99
105
 
106
+ # @return [String]
107
+ def without_ext
108
+ with_ext('')
109
+ end
110
+
100
111
  def to_s
101
112
  @string
102
113
  end
@@ -125,12 +125,9 @@ module Nanoc
125
125
  @item.raw_content
126
126
  end
127
127
 
128
- # @api private
129
- def reference
130
- @item.reference
131
- end
132
-
133
- # @api private
128
+ # Returns the representations of this item.
129
+ #
130
+ # @return [Enumerable<Nanoc::ItemRepView>]
134
131
  def reps
135
132
  @item.reps.map { |r| Nanoc::ItemRepView.new(r) }
136
133
  end
@@ -139,15 +136,5 @@ module Nanoc
139
136
  def raw_filename
140
137
  @item.raw_filename
141
138
  end
142
-
143
- # @api private
144
- def forced_outdated?
145
- @item.forced_outdated?
146
- end
147
-
148
- # @api private
149
- def __nanoc_checksum
150
- @item.__nanoc_checksum
151
- end
152
139
  end
153
140
  end
@@ -50,6 +50,16 @@ module Nanoc
50
50
  item && view_class.new(item)
51
51
  end
52
52
 
53
+ # Finds all items whose identifier matches the given argument.
54
+ #
55
+ # @param [String, Regex] arg
56
+ #
57
+ # @return [Enumerable<Nanoc::ItemView>]
58
+ def find_all(arg)
59
+ pat = Nanoc::Int::Pattern.from(arg)
60
+ @items.select { |i| pat.match?(i.identifier) }
61
+ end
62
+
53
63
  # @overload [](string)
54
64
  #
55
65
  # Finds the item whose identifier matches the given string.
@@ -60,89 +60,14 @@ module Nanoc
60
60
  Nanoc::ItemView.new(@item_rep.item)
61
61
  end
62
62
 
63
- # @api private
64
- def to_recording_proxy
65
- @item_rep.to_recording_proxy
66
- end
67
-
68
63
  # @api private
69
64
  def raw_path(params = {})
70
65
  @item_rep.raw_path(params)
71
66
  end
72
67
 
73
- # @api private
74
- def compiled?
75
- @item_rep.compiled?
76
- end
77
-
78
- # @api private
79
- def compiled=(new_compiled)
80
- @item_rep.compiled = new_compiled
81
- end
82
-
83
- # @api private
84
- def forget_progress
85
- @item_rep.forget_progress
86
- end
87
-
88
- # @api private
89
- def assigns
90
- @item_rep.assigns
91
- end
92
-
93
- # @api private
94
- def assigns=(new_assigns)
95
- @item_rep.assigns = new_assigns
96
- end
97
-
98
- # @api private
99
- def type
100
- @item_rep.type
101
- end
102
-
103
- # @api private
104
- def reference
105
- @item_rep.reference
106
- end
107
-
108
- # @api private
109
- def snapshot(snapshot_name, params = {})
110
- @item_rep.snapshot(snapshot_name, params)
111
- end
112
-
113
- # @api private
114
- def filter(filter_name, filter_args = {})
115
- @item_rep.filter(filter_name, filter_args)
116
- end
117
-
118
- # @api private
119
- def layout(layout, filter_name, filter_args)
120
- @item_rep.layout(layout, filter_name, filter_args)
121
- end
122
-
123
- # @api private
124
- def proxy?
125
- @item_rep.proxy?
126
- end
127
-
128
68
  # @api private
129
69
  def binary?
130
70
  @item_rep.binary?
131
71
  end
132
-
133
- # @api private
134
- def has_snapshot?(snapshot_name)
135
- @item_rep.has_snapshot?(snapshot_name)
136
- end
137
-
138
- # @api private
139
- def content
140
- @item_rep.content
141
- end
142
-
143
- # @api private
144
- def temporary_filenames
145
- @item_rep.temporary_filenames
146
- end
147
72
  end
148
73
  end
@@ -28,5 +28,39 @@ module Nanoc
28
28
  @layouts.each { |l| yield view_class.new(l) }
29
29
  self
30
30
  end
31
+
32
+ # @overload [](string)
33
+ #
34
+ # Finds the item whose identifier matches the given string.
35
+ #
36
+ # If the glob syntax is enabled, the string can be a glob, in which case
37
+ # this method finds the first item that matches the given glob.
38
+ #
39
+ # @param [String] string
40
+ #
41
+ # @return [nil] if no item matches the string
42
+ #
43
+ # @return [Nanoc::ItemView] if an item was found
44
+ #
45
+ # @overload [](regex)
46
+ #
47
+ # Finds the item whose identifier matches the given regular expression.
48
+ #
49
+ # @param [Regex] regex
50
+ #
51
+ # @return [nil] if no item matches the regex
52
+ #
53
+ # @return [Nanoc::ItemView] if an item was found
54
+ def [](arg)
55
+ layout = @layouts.find { |l| l.identifier == arg }
56
+ return view_class.new(layout) if layout
57
+
58
+ # FIXME: this should only work if globs are enabled
59
+ pat = Nanoc::Int::Pattern.from(arg)
60
+ layout = @layouts.find { |l| pat.match?(l.identifier) }
61
+ return view_class.new(layout) if layout
62
+
63
+ nil
64
+ end
31
65
  end
32
66
  end
@@ -11,25 +11,5 @@ module Nanoc
11
11
  def unwrap
12
12
  @site
13
13
  end
14
-
15
- # @api private
16
- def layouts
17
- @site.layouts.map { |l| Nanoc::LayoutView.new(l) }
18
- end
19
-
20
- # @api private
21
- def captures_store
22
- @site.captures_store
23
- end
24
-
25
- # @api private
26
- def captures_store_compiled_items
27
- @site.captures_store_compiled_items
28
- end
29
-
30
- # @api private
31
- def compiler
32
- @site.compiler
33
- end
34
14
  end
35
15
  end
@@ -17,9 +17,6 @@ SKIP - The item was deemed not outdated and was therefore not recompiled
17
17
 
18
18
  EOS
19
19
 
20
- option :a, :all, '(ignored)'
21
- option :f, :force, '(ignored)'
22
-
23
20
  module Nanoc::CLI::Commands
24
21
  class Compile < ::Nanoc::CLI::CommandRunner
25
22
  extend Nanoc::Int::Memoization
@@ -280,7 +280,7 @@ EOS
280
280
  data_source = options[:datasource] || 'filesystem_unified'
281
281
 
282
282
  # Check whether site exists
283
- if File.exist?(path)
283
+ if File.exist?(path) && (!File.directory?(path) || !(Dir.entries(path) - %w{ . .. }).empty?)
284
284
  raise Nanoc::Int::Errors::GenericTrivial, "A site at '#{path}' already exists."
285
285
  end
286
286
 
@@ -4,7 +4,7 @@ usage 'shell'
4
4
  summary 'open a shell on the nanoc environment'
5
5
  aliases 'console'
6
6
  description "
7
- Open an IRB shell on a context that contains @items, @layouts, @config and @site.
7
+ Open an IRB shell on a context that contains @items, @layouts, and @config.
8
8
  "
9
9
 
10
10
  module Nanoc::CLI::Commands
@@ -90,7 +90,7 @@ module Nanoc::Helpers
90
90
 
91
91
  # Capture and store
92
92
  content = capture(&block)
93
- @site.captures_store[@item, name.to_sym] = content
93
+ @site.unwrap.captures_store[@item, name.to_sym] = content
94
94
  else # Get content
95
95
  # Get args
96
96
  if args.size != 2
@@ -102,7 +102,7 @@ module Nanoc::Helpers
102
102
  name = args[1]
103
103
 
104
104
  # Create dependency
105
- current_item = @site.compiler.dependency_tracker.top
105
+ current_item = @site.unwrap.compiler.dependency_tracker.top
106
106
  if item != current_item
107
107
  Nanoc::Int::NotificationCenter.post(:visit_started, item)
108
108
  Nanoc::Int::NotificationCenter.post(:visit_ended, item)
@@ -111,8 +111,8 @@ module Nanoc::Helpers
111
111
  # item from which we use content. For this, we need to manually edit
112
112
  # the content attribute to reset it. :(
113
113
  # FIXME: clean this up
114
- unless @site.captures_store_compiled_items.include? item
115
- @site.captures_store_compiled_items << item
114
+ unless @site.unwrap.captures_store_compiled_items.include? item
115
+ @site.unwrap.captures_store_compiled_items << item
116
116
  item.forced_outdated = true
117
117
  item.reps.each do |r|
118
118
  raw_content = item.raw_content
@@ -123,7 +123,7 @@ module Nanoc::Helpers
123
123
  end
124
124
 
125
125
  # Get content
126
- @site.captures_store[item, name.to_sym]
126
+ @site.unwrap.captures_store[item, name.to_sym]
127
127
  end
128
128
  end
129
129
 
@@ -33,12 +33,12 @@ module Nanoc::Helpers
33
33
  # Find filter
34
34
  klass = Nanoc::Filter.named(filter_name)
35
35
  raise Nanoc::Int::Errors::UnknownFilter.new(filter_name) if klass.nil?
36
- filter = klass.new(@item_rep.assigns)
36
+ filter = klass.new(@item_rep.unwrap.assigns)
37
37
 
38
38
  # Filter captured data
39
- Nanoc::Int::NotificationCenter.post(:filtering_started, @item_rep, filter_name)
39
+ Nanoc::Int::NotificationCenter.post(:filtering_started, @item_rep.unwrap, filter_name)
40
40
  filtered_data = filter.setup_and_run(data, arguments)
41
- Nanoc::Int::NotificationCenter.post(:filtering_ended, @item_rep, filter_name)
41
+ Nanoc::Int::NotificationCenter.post(:filtering_ended, @item_rep.unwrap, filter_name)
42
42
 
43
43
  # Append filtered data to buffer
44
44
  buffer = eval('_erbout', block.binding)
@@ -77,8 +77,9 @@ module Nanoc::Helpers
77
77
  # invoked with a block
78
78
  def render(identifier, other_assigns = {}, &block)
79
79
  # Find layout
80
- layout = @site.layouts.find { |l| l.identifier == identifier.__nanoc_cleaned_identifier }
81
- raise Nanoc::Int::Errors::UnknownLayout.new(identifier.__nanoc_cleaned_identifier) if layout.nil?
80
+ layout = @layouts[identifier]
81
+ layout ||= @layouts[identifier.__nanoc_cleaned_identifier]
82
+ raise Nanoc::Int::Errors::UnknownLayout.new(identifier) if layout.nil?
82
83
 
83
84
  # Visit
84
85
  Nanoc::Int::NotificationCenter.post(:visit_started, layout)
@@ -93,14 +94,14 @@ module Nanoc::Helpers
93
94
  item: @item,
94
95
  item_rep: @item_rep,
95
96
  items: @items,
96
- layout: layout,
97
+ layout: Nanoc::LayoutView.new(layout),
97
98
  layouts: @layouts,
98
99
  config: @config,
99
100
  site: @site
100
101
  }.merge(other_assigns)
101
102
 
102
103
  # Get filter name
103
- filter_name, filter_args = @site.compiler.rules_collection.filter_for_layout(layout)
104
+ filter_name, filter_args = @site.unwrap.compiler.rules_collection.filter_for_layout(layout)
104
105
  raise Nanoc::Int::Errors::CannotDetermineFilter.new(layout.identifier) if filter_name.nil?
105
106
 
106
107
  # Get filter class
@@ -17,9 +17,8 @@ module Nanoc::Helpers
17
17
  # tags will be linked using the {#link_for_tag} function; the
18
18
  # HTML-escaping rules for {#link_for_tag} apply here as well.
19
19
  #
20
- # @option params [String] base_url ("http://technorati.com/tag/") The URL
21
- # to which the tag will be appended to construct the link URL. This URL
22
- # must have a trailing slash.
20
+ # @option params [String] base_url The URL to which the tag will be appended
21
+ # to construct the link URL. This URL must have a trailing slash.
23
22
  #
24
23
  # @option params [String] none_text ("(none)") The text to display when
25
24
  # the item has no tags
@@ -29,7 +28,7 @@ module Nanoc::Helpers
29
28
  #
30
29
  # @return [String] A hyperlinked list of tags for the given item
31
30
  def tags_for(item, params = {})
32
- base_url = params[:base_url] || 'http://technorati.com/tag/'
31
+ base_url = params.fetch(:base_url)
33
32
  none_text = params[:none_text] || '(none)'
34
33
  separator = params[:separator] || ', '
35
34
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nanoc
4
4
  # The current nanoc version.
5
- VERSION = '4.0.0a2'
5
+ VERSION = '4.0.0b1'
6
6
  end
@@ -26,7 +26,7 @@ namespace :test do
26
26
  end
27
27
 
28
28
  # test:...
29
- %w( base cli data_sources extra filters helpers tasks ).each do |dir|
29
+ %w( base cli data_sources extra filters helpers ).each do |dir|
30
30
  desc "Run all #{dir} tests"
31
31
  task dir.to_sym do |_task|
32
32
  run_tests "test/#{dir}/**/"
@@ -174,6 +174,35 @@ EOS
174
174
  end
175
175
  end
176
176
 
177
+ def test_passthrough_with_full_identifiers
178
+ with_site do
179
+ File.open('nanoc.yaml', 'w') do |io|
180
+ io << 'data_sources:' << "\n"
181
+ io << ' -' << "\n"
182
+ io << ' type: filesystem_unified' << "\n"
183
+ io << ' identifier_style: full' << "\n"
184
+ end
185
+
186
+ # Create rules
187
+ File.open('Rules', 'w') do |io|
188
+ io << 'passthrough \'*\''
189
+ end
190
+
191
+ # Create items
192
+ assert Dir['content/*'].empty?
193
+ File.open('content/robots.txt', 'w') do |io|
194
+ io.write 'Hello I am robots'
195
+ end
196
+
197
+ # Compile
198
+ site = Nanoc::Int::Site.new('.')
199
+ site.compile
200
+
201
+ # Check paths
202
+ assert_equal ['output/robots.txt'], Dir['output/*']
203
+ end
204
+ end
205
+
177
206
  def test_ignore
178
207
  with_site do
179
208
  # Create rules
@@ -17,6 +17,16 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
17
17
  end
18
18
  end
19
19
 
20
+ def test_can_compile_new_site_in_current_directory
21
+ FileUtils.mkdir('foo')
22
+
23
+ FileUtils.cd('foo') do
24
+ Nanoc::CLI.run %w( create_site ./ )
25
+ site = Nanoc::Int::Site.new('.')
26
+ site.compile
27
+ end
28
+ end
29
+
20
30
  def test_can_compile_new_site_with_binary_items
21
31
  Nanoc::CLI.run %w( create_site foo )
22
32
 
@@ -2,12 +2,6 @@
2
2
 
3
3
  class Nanoc::Filters::MarkabyTest < Nanoc::TestCase
4
4
  def test_filter
5
- # Don’t run this test on 1.9.x, because it breaks and it annoys me
6
- if RUBY_VERSION >= '1.9'
7
- skip 'Markaby is not compatible with 1.9.x'
8
- return
9
- end
10
-
11
5
  if_have 'markaby' do
12
6
  # Create filter
13
7
  filter = ::Nanoc::Filters::Markaby.new
@@ -18,7 +18,6 @@ Coveralls.wear!
18
18
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
19
19
  require 'nanoc'
20
20
  require 'nanoc/cli'
21
- require 'nanoc/tasks'
22
21
  Nanoc::CLI.setup
23
22
 
24
23
  # Load miscellaneous requirements
@@ -17,9 +17,11 @@ class Nanoc::Helpers::CapturingTest < Nanoc::TestCase
17
17
  '<% end %> foot'
18
18
 
19
19
  # Build site
20
- @site = Nanoc::Int::Site.new({})
21
- @item = Nanoc::Int::Item.new('moo', {}, '/blah/')
22
- @item.site = @site
20
+ site = Nanoc::Int::Site.new({})
21
+ item = Nanoc::Int::Item.new('moo', {}, '/blah/')
22
+ item.site = site
23
+ @site = Nanoc::SiteView.new(Nanoc::Int::Site.new({}))
24
+ @item = Nanoc::ItemView.new(item)
23
25
 
24
26
  # Evaluate content
25
27
  result = ::ERB.new(content).result(binding)
@@ -33,8 +35,8 @@ class Nanoc::Helpers::CapturingTest < Nanoc::TestCase
33
35
  require 'erb'
34
36
 
35
37
  # Build site
36
- @site = Nanoc::Int::Site.new({})
37
- @item = Nanoc::Int::Item.new('moo', {}, '/blah/')
38
+ @site = Nanoc::SiteView.new(Nanoc::Int::Site.new({}))
39
+ @item = Nanoc::ItemView.new(Nanoc::Int::Item.new('moo', {}, '/blah/'))
38
40
 
39
41
  # Capture
40
42
  _erbout = 'foo'
@@ -67,8 +69,8 @@ head
67
69
  foot
68
70
  EOS
69
71
 
70
- @site = Nanoc::Int::Site.new({})
71
- @item = Nanoc::Int::Item.new('content', {}, '/')
72
+ @site = Nanoc::SiteView.new(Nanoc::Int::Site.new({}))
73
+ @item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', {}, '/'))
72
74
 
73
75
  result = ::ERB.new(content).result(binding)
74
76
 
@@ -85,16 +87,16 @@ EOS
85
87
  io.write "route '*' do ; item.identifier + 'index.html' ; end\n"
86
88
  end
87
89
 
88
- @site = Nanoc::Int::Site.new({})
89
- @item = Nanoc::Int::Item.new('content', {}, '/')
90
+ @site = Nanoc::SiteView.new(Nanoc::Int::Site.new({}))
91
+ @item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', {}, '/'))
90
92
  content = '<% content_for :a do %>Content One<% end %>'
91
93
  ::ERB.new(content).result(binding)
92
94
 
93
95
  assert_equal 'Content One', content_for(@item, :a)
94
96
  assert_equal nil, content_for(@item, :b)
95
97
 
96
- @site = Nanoc::Int::Site.new({})
97
- @item = Nanoc::Int::Item.new('content', {}, '/')
98
+ @site = Nanoc::SiteView.new(Nanoc::Int::Site.new({}))
99
+ @item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', {}, '/'))
98
100
  content = '<% content_for :b do %>Content Two<% end %>'
99
101
  ::ERB.new(content).result(binding)
100
102
 
@@ -14,6 +14,7 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
14
14
  # Mock item and rep
15
15
  @item_rep = mock
16
16
  @item_rep.expects(:assigns).returns({})
17
+ @item_rep = Nanoc::ItemRepView.new(@item_rep)
17
18
 
18
19
  # Evaluate content
19
20
  result = ::ERB.new(content).result(binding)
@@ -36,12 +37,14 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
36
37
  @item = mock
37
38
  @item.expects(:[]).with(:title).returns('Bar...')
38
39
  @item.expects(:identifier).returns('/blah/')
40
+ @item = Nanoc::ItemView.new(@item)
39
41
  @item_rep = mock
40
42
  @item_rep.expects(:name).returns('default')
41
43
  @item_rep.expects(:assigns).returns({
42
44
  item: @item,
43
45
  item_rep: @item_rep
44
46
  })
47
+ @item_rep = Nanoc::ItemRepView.new(@item_rep)
45
48
 
46
49
  # Evaluate content
47
50
  result = ::ERB.new(content).result(binding)
@@ -75,6 +78,7 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
75
78
  # Mock item and rep
76
79
  @item_rep = mock
77
80
  @item_rep.expects(:assigns).returns({})
81
+ @item_rep = Nanoc::ItemRepView.new(@item_rep)
78
82
 
79
83
  # Evaluate content
80
84
  result = ::ERB.new(content).result(binding)
@@ -93,6 +97,7 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
93
97
  # Mock item and rep
94
98
  @item_rep = mock
95
99
  @item_rep.expects(:assigns).returns({})
100
+ @item_rep = Nanoc::ItemRepView.new(@item_rep)
96
101
 
97
102
  # Evaluate content
98
103
  result = ::Haml::Engine.new(content).render(binding)
@@ -113,6 +118,7 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
113
118
  # Mock item and rep
114
119
  @item_rep = mock
115
120
  @item_rep.expects(:assigns).returns({})
121
+ @item_rep = Nanoc::ItemRepView.new(@item_rep)
116
122
 
117
123
  ::ERB.new(content).result(binding)
118
124
 
@@ -5,8 +5,6 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
5
5
 
6
6
  def test_render
7
7
  with_site do |site|
8
- @site = site
9
-
10
8
  File.open('Rules', 'w') do |io|
11
9
  io.write("layout '/foo/', :erb\n")
12
10
  end
@@ -15,13 +13,51 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
15
13
  io.write 'This is the <%= @layout.identifier %> layout.'
16
14
  end
17
15
 
16
+ @site = Nanoc::SiteView.new(site)
17
+ @layouts = Nanoc::LayoutCollectionView.new(site.layouts)
18
+
18
19
  assert_equal('This is the /foo/ layout.', render('/foo/'))
19
20
  end
20
21
  end
21
22
 
23
+ def test_render_with_non_cleaned_identifier
24
+ with_site do |site|
25
+ File.open('Rules', 'w') do |io|
26
+ io.write("layout '/foo/', :erb\n")
27
+ end
28
+
29
+ File.open('layouts/foo.erb', 'w') do |io|
30
+ io.write 'This is the <%= @layout.identifier %> layout.'
31
+ end
32
+
33
+ @site = Nanoc::SiteView.new(site)
34
+ @layouts = Nanoc::LayoutCollectionView.new(site.layouts)
35
+
36
+ assert_equal('This is the /foo/ layout.', render('/foo'))
37
+ end
38
+ end
39
+
40
+ def test_render_class
41
+ with_site do |site|
42
+ File.open('Rules', 'w') do |io|
43
+ io.write("layout '/foo/', :erb\n")
44
+ end
45
+
46
+ File.open('layouts/foo.erb', 'w') do |io|
47
+ io.write 'I am the <%= @layout.class %> class.'
48
+ end
49
+
50
+ @site = Nanoc::SiteView.new(site)
51
+ @layouts = Nanoc::LayoutCollectionView.new(site.layouts)
52
+
53
+ assert_equal('I am the Nanoc::LayoutView class.', render('/foo/'))
54
+ end
55
+ end
56
+
22
57
  def test_render_with_unknown_layout
23
58
  with_site do |site|
24
- @site = site
59
+ @site = Nanoc::SiteView.new(site)
60
+ @layouts = Nanoc::LayoutCollectionView.new(site.layouts)
25
61
 
26
62
  assert_raises(Nanoc::Int::Errors::UnknownLayout) do
27
63
  render '/dsfghjkl/'
@@ -31,14 +67,15 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
31
67
 
32
68
  def test_render_without_filter
33
69
  with_site do |site|
34
- @site = site
35
-
36
70
  File.open('Rules', 'w') do |io|
37
71
  io.write("layout '/foo/', nil\n")
38
72
  end
39
73
 
40
74
  File.open('layouts/foo.erb', 'w').close
41
75
 
76
+ @site = Nanoc::SiteView.new(site)
77
+ @layouts = Nanoc::LayoutCollectionView.new(site.layouts)
78
+
42
79
  assert_raises(Nanoc::Int::Errors::CannotDetermineFilter) do
43
80
  render '/foo/'
44
81
  end
@@ -47,14 +84,15 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
47
84
 
48
85
  def test_render_with_unknown_filter
49
86
  with_site do |site|
50
- @site = site
51
-
52
87
  File.open('Rules', 'w') do |io|
53
88
  io.write("layout '/foo/', :asdf\n")
54
89
  end
55
90
 
56
91
  File.open('layouts/foo.erb', 'w').close
57
92
 
93
+ @site = Nanoc::SiteView.new(site)
94
+ @layouts = Nanoc::LayoutCollectionView.new(site.layouts)
95
+
58
96
  assert_raises(Nanoc::Int::Errors::UnknownFilter) do
59
97
  render '/foo/'
60
98
  end
@@ -63,8 +101,6 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
63
101
 
64
102
  def test_render_with_block
65
103
  with_site do |site|
66
- @site = site
67
-
68
104
  File.open('Rules', 'w') do |io|
69
105
  io.write("layout '/foo/', :erb\n")
70
106
  end
@@ -73,6 +109,9 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
73
109
  io.write '[partial-before]<%= yield %>[partial-after]'
74
110
  end
75
111
 
112
+ @site = Nanoc::SiteView.new(site)
113
+ @layouts = Nanoc::LayoutCollectionView.new(site.layouts)
114
+
76
115
  _erbout = '[erbout-before]'
77
116
  result = render '/foo/' do
78
117
  _erbout << 'This is some extra content'
@@ -10,7 +10,7 @@ class Nanoc::Helpers::TaggingTest < Nanoc::TestCase
10
10
  # Check
11
11
  assert_equal(
12
12
  '(none)',
13
- tags_for(item)
13
+ tags_for(item, base_url: 'http://example.com/tag/')
14
14
  )
15
15
  end
16
16
 
@@ -33,7 +33,7 @@ class Nanoc::Helpers::TaggingTest < Nanoc::TestCase
33
33
  # Check
34
34
  assert_equal(
35
35
  'no tags for you, fool',
36
- tags_for(item, none_text: 'no tags for you, fool')
36
+ tags_for(item, none_text: 'no tags for you, fool', base_url: 'http://example.com/tag/')
37
37
  )
38
38
  end
39
39
 
@@ -43,9 +43,9 @@ class Nanoc::Helpers::TaggingTest < Nanoc::TestCase
43
43
 
44
44
  # Check
45
45
  assert_equal(
46
- "#{link_for_tag('foo', 'http://technorati.com/tag/')} ++ " \
47
- "#{link_for_tag('bar', 'http://technorati.com/tag/')}",
48
- tags_for(item, separator: ' ++ ')
46
+ "#{link_for_tag('foo', 'http://example.com/tag/')} ++ " \
47
+ "#{link_for_tag('bar', 'http://example.com/tag/')}",
48
+ tags_for(item, separator: ' ++ ', base_url: 'http://example.com/tag/')
49
49
  )
50
50
  end
51
51
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0a2
4
+ version: 4.0.0b1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-12 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -213,11 +213,6 @@ files:
213
213
  - lib/nanoc/helpers/tagging.rb
214
214
  - lib/nanoc/helpers/text.rb
215
215
  - lib/nanoc/helpers/xml_sitemap.rb
216
- - lib/nanoc/tasks.rb
217
- - lib/nanoc/tasks/clean.rake
218
- - lib/nanoc/tasks/clean.rb
219
- - lib/nanoc/tasks/deploy/rsync.rake
220
- - lib/nanoc/tasks/validate.rake
221
216
  - lib/nanoc/version.rb
222
217
  - nanoc.gemspec
223
218
  - tasks/doc.rake
@@ -278,7 +273,6 @@ files:
278
273
  - test/extra/core_ext/test_time.rb
279
274
  - test/extra/deployers/test_fog.rb
280
275
  - test/extra/deployers/test_rsync.rb
281
- - test/extra/test_file_proxy.rb
282
276
  - test/extra/test_filesystem_tools.rb
283
277
  - test/extra/test_link_collector.rb
284
278
  - test/extra/test_piper.rb
@@ -326,7 +320,6 @@ files:
326
320
  - test/helpers/test_tagging.rb
327
321
  - test/helpers/test_text.rb
328
322
  - test/helpers/test_xml_sitemap.rb
329
- - test/tasks/test_clean.rb
330
323
  - test/test_gem.rb
331
324
  homepage: http://nanoc.ws/
332
325
  licenses:
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'nanoc'
4
- require 'rake'
5
-
6
- # @api private
7
- module Nanoc::Tasks
8
- end
9
-
10
- Dir[File.dirname(__FILE__) + '/tasks/**/*.rb'].each { |f| load f }
11
- Dir[File.dirname(__FILE__) + '/tasks/**/*.rake'].each { |f| Rake.application.add_import(f) }
@@ -1,16 +0,0 @@
1
- # encoding: utf-8
2
-
3
- desc 'Remove output files generated by nanoc'
4
- task :clean do
5
- # Load site
6
- site = Nanoc::Int::Site.new('.')
7
- if site.nil?
8
- $stderr.puts 'The current working directory does not seem to be a ' \
9
- 'valid/complete nanoc site directory; aborting.'
10
- exit 1
11
- end
12
-
13
- # Clean
14
- clean = ::Nanoc::Tasks::Clean.new(site)
15
- clean.run
16
- end
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc::Tasks
4
- class Clean
5
- def initialize(site)
6
- @site = site
7
- end
8
-
9
- def run
10
- filenames.each do |filename|
11
- FileUtils.rm_f filename unless filename.nil?
12
- end
13
- end
14
-
15
- private
16
-
17
- def filenames
18
- @site.items.map do |item|
19
- item.reps.map(&:raw_path)
20
- end.flatten
21
- end
22
- end
23
- end
@@ -1,16 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'nanoc/cli'
4
-
5
- namespace :deploy do
6
- desc 'Upload the compiled site using rsync'
7
- task :rsync do
8
- dry_run = ENV['dry_run']
9
- config_name = ENV['config'] || :default
10
-
11
- cmd = ['deploy', '-t', config_name]
12
- cmd << '-n' if dry_run
13
-
14
- Nanoc::CLI.run cmd
15
- end
16
- end
@@ -1,30 +0,0 @@
1
- # encoding: utf-8
2
-
3
- namespace :validate do
4
- desc 'Validate the site’s HTML files'
5
- task :html do
6
- Nanoc::CLI.run %w( validate_html )
7
- end
8
-
9
- desc 'Validate the site’s CSS files'
10
- task :css do
11
- Nanoc::CLI.run %w( validate_css )
12
- end
13
-
14
- namespace :links do
15
- desc 'Validate the site’s internal links'
16
- task :internal do
17
- Nanoc::CLI.run %w( validate_links --internal )
18
- end
19
-
20
- desc 'Validate the site’s external links'
21
- task :external do
22
- Nanoc::CLI.run %w( validate_links --external )
23
- end
24
- end
25
-
26
- desc 'Validate the site’s internal and external links'
27
- task :links do
28
- Nanoc::CLI.run %w( validate_links )
29
- end
30
- end
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc::Extra::FileProxyTest < Nanoc::TestCase
4
- def test_create_many
5
- if_implemented do
6
- # Create test file
7
- File.open('test.txt', 'w') { |_io| }
8
-
9
- # Create lots of file proxies
10
- count = Process.getrlimit(Process::RLIMIT_NOFILE)[0] + 5
11
- file_proxies = []
12
- count.times { file_proxies << Nanoc::Extra::FileProxy.new('test.txt') }
13
- end
14
- end
15
- end
@@ -1,63 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc::Tasks::CleanTest < Nanoc::TestCase
4
- def test_simple
5
- if_have 'w3c_validators' do
6
- # Stub items
7
- items = [mock, mock]
8
- reps = [[mock, mock], [mock, mock]]
9
- items[0].expects(:reps).returns(reps[0])
10
- items[1].expects(:reps).returns(reps[1])
11
-
12
- # Create sample files
13
- [0, 1].each do |item_id|
14
- [0, 1].each do |rep_id|
15
- filename = "item-#{item_id}-rep-#{rep_id}.txt"
16
- reps[item_id][rep_id].expects(:raw_path).returns(filename)
17
- File.open(filename, 'w') { |io| io.write('hello') }
18
- assert File.file?(filename)
19
- end
20
- end
21
-
22
- # Stub site
23
- site = mock
24
- site.expects(:items).returns(items)
25
-
26
- # Create clean task
27
- clean = ::Nanoc::Tasks::Clean.new(site)
28
-
29
- # Run
30
- clean.run
31
-
32
- # Check
33
- [0, 1].each do |item_id|
34
- [0, 1].each do |rep_id|
35
- filename = "item-#{item_id}-rep-#{rep_id}.txt"
36
- assert !File.file?(filename)
37
- end
38
- end
39
- end
40
- end
41
-
42
- def test_with_nil_raw_path
43
- if_have 'w3c_validators' do
44
- # Stub items
45
- item = mock
46
- rep = mock
47
- item.expects(:reps).returns([rep])
48
-
49
- # Create sample file
50
- rep.expects(:raw_path).returns(nil)
51
-
52
- # Stub site
53
- site = mock
54
- site.expects(:items).returns([item])
55
-
56
- # Create clean task
57
- clean = ::Nanoc::Tasks::Clean.new(site)
58
-
59
- # Run
60
- clean.run
61
- end
62
- end
63
- end