nanoc-core 4.11.2 → 4.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88b7b9df65548c9c0fc675054ce420c5b81c4be85f42fbe68357a69f74b8dfc3
4
- data.tar.gz: 668532d1aad92d0775cd521bcc0a17af669e6ccba9431d1e4858eb36e9c8d796
3
+ metadata.gz: 81268371fca3b0d630f91ce6290ca35c685092b8a0f62ead810cc973d4a24d68
4
+ data.tar.gz: 101af420b1fcd1701dd3c21392bdf6623121e952d64a3be09eed90ba4dde67b4
5
5
  SHA512:
6
- metadata.gz: 4eb2feeb52ae3925ae7a877934a595151835939281d3af4a8263b9b54f1ec848255aeb7c68490fb908d0591d3a0eb5378285267b31f7e68c5162a87202fece30
7
- data.tar.gz: 24f2f09de0e1d872a7253c9e6bc6f7679934ae78877c70bb0e009853a965abb4c3514bda94350dd4d8c13220205c1eb5b4fced77c29cb7e53b645399c8167f4c
6
+ metadata.gz: 7b82d40f993402eae07367d4ae9170b3d7ad7fc80013f3f8ab8c42d944a2fa240bb37a01b693f6cfb305490eed65992d14334ecf581bc470550fcd61f5b9be8d
7
+ data.tar.gz: 3bfe0233488f5c1df56f09af4059031fef6b622a99c8bbd7e23981a1f4aaa48c81854b19854ae086b22e24a6b8ac870d0c07914a67e24edff9f63dd3eb1a36a0
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc
4
+ module Core
5
+ # @private
6
+ class ActionProvider
7
+ extend DDPlugin::Plugin
8
+
9
+ def self.for(_site)
10
+ raise NotImplementedError
11
+ end
12
+
13
+ def rep_names_for(_item)
14
+ raise NotImplementedError
15
+ end
16
+
17
+ def action_sequence_for(_obj)
18
+ raise NotImplementedError
19
+ end
20
+
21
+ def need_preprocessing?
22
+ raise NotImplementedError
23
+ end
24
+
25
+ def preprocess(_site)
26
+ raise NotImplementedError
27
+ end
28
+
29
+ def postprocess(_site, _reps)
30
+ raise NotImplementedError
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc
4
+ module Core
5
+ class ActionSequence
6
+ include Nanoc::Core::ContractsSupport
7
+ include Enumerable
8
+ DDMemoize.activate(self)
9
+
10
+ attr_reader :item_rep
11
+ attr_reader :actions
12
+
13
+ def initialize(item_rep, actions: [])
14
+ @item_rep = item_rep
15
+ @actions = actions
16
+ end
17
+
18
+ contract C::None => Numeric
19
+ def size
20
+ @actions.size
21
+ end
22
+
23
+ contract Numeric => C::Maybe[Nanoc::Core::ProcessingAction]
24
+ def [](idx)
25
+ @actions[idx]
26
+ end
27
+
28
+ contract C::None => C::ArrayOf[Nanoc::Core::ProcessingAction]
29
+ def snapshot_actions
30
+ @actions.select { |a| a.is_a?(Nanoc::Core::ProcessingActions::Snapshot) }
31
+ end
32
+
33
+ contract C::None => Array
34
+ def paths
35
+ snapshot_actions.map { |a| [a.snapshot_names, a.paths] }
36
+ end
37
+
38
+ memoized def serialize
39
+ serialize_uncached
40
+ end
41
+
42
+ contract C::None => Array
43
+ def serialize_uncached
44
+ to_a.map(&:serialize)
45
+ end
46
+
47
+ contract C::Func[Nanoc::Core::ProcessingAction => C::Any] => self
48
+ def each
49
+ @actions.each { |a| yield(a) }
50
+ self
51
+ end
52
+
53
+ contract C::Func[Nanoc::Core::ProcessingAction => C::Any] => self
54
+ def map
55
+ self.class.new(
56
+ @item_rep,
57
+ actions: @actions.map { |a| yield(a) },
58
+ )
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc
4
+ module Core
5
+ class ActionSequenceBuilder
6
+ include Nanoc::Core::ContractsSupport
7
+
8
+ # Error that is raised when a snapshot with an existing name is made.
9
+ class CannotCreateMultipleSnapshotsWithSameNameError < ::Nanoc::Core::Error
10
+ include Nanoc::Core::ContractsSupport
11
+
12
+ contract Nanoc::Core::ItemRep, Symbol => C::Any
13
+ def initialize(rep, snapshot)
14
+ super("Attempted to create a snapshot with a duplicate name #{snapshot.inspect} for the item rep #{rep}")
15
+ end
16
+ end
17
+
18
+ def self.build(rep)
19
+ builder = new(rep)
20
+ yield(builder)
21
+ builder.action_sequence
22
+ end
23
+
24
+ def initialize(item_rep)
25
+ @item_rep = item_rep
26
+ @actions = []
27
+ end
28
+
29
+ contract Symbol, Hash => self
30
+ def add_filter(filter_name, params)
31
+ @actions << Nanoc::Core::ProcessingActions::Filter.new(filter_name, params)
32
+ self
33
+ end
34
+
35
+ contract String, C::Maybe[Hash] => self
36
+ def add_layout(layout_identifier, params)
37
+ @actions << Nanoc::Core::ProcessingActions::Layout.new(layout_identifier, params)
38
+ self
39
+ end
40
+
41
+ contract Symbol, C::Maybe[String] => self
42
+ def add_snapshot(snapshot_name, path)
43
+ will_add_snapshot(snapshot_name)
44
+ @actions << Nanoc::Core::ProcessingActions::Snapshot.new([snapshot_name], path ? [path] : [])
45
+ self
46
+ end
47
+
48
+ contract C::None => Nanoc::Core::ActionSequence
49
+ def action_sequence
50
+ Nanoc::Core::ActionSequence.new(@item_rep, actions: @actions)
51
+ end
52
+
53
+ private
54
+
55
+ def will_add_snapshot(name)
56
+ @_snapshot_names ||= Set.new
57
+ if @_snapshot_names.include?(name)
58
+ raise CannotCreateMultipleSnapshotsWithSameNameError.new(@item_rep, name)
59
+ else
60
+ @_snapshot_names << name
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc
4
+ module Core
5
+ class ChecksumCollection
6
+ include Nanoc::Core::ContractsSupport
7
+
8
+ c_obj = C::Or[Nanoc::Core::Item, Nanoc::Core::Layout, Nanoc::Core::Configuration, Nanoc::Core::CodeSnippet]
9
+
10
+ def initialize(checksums)
11
+ @checksums = checksums
12
+ end
13
+
14
+ contract c_obj => C::Maybe[String]
15
+ def checksum_for(obj)
16
+ @checksums[obj.reference]
17
+ end
18
+
19
+ contract c_obj => C::Maybe[String]
20
+ def content_checksum_for(obj)
21
+ @checksums[[obj.reference, :content]]
22
+ end
23
+
24
+ contract c_obj => C::Maybe[C::HashOf[Symbol, String]]
25
+ def attributes_checksum_for(obj)
26
+ @checksums[[obj.reference, :each_attribute]]
27
+ end
28
+
29
+ def to_h
30
+ @checksums
31
+ end
32
+ end
33
+ end
34
+ end
@@ -8,11 +8,6 @@ module Nanoc
8
8
  # @return [Nanoc::Core::Content]
9
9
  attr_reader :content
10
10
 
11
- # @return [Hash]
12
- def attributes
13
- @attributes.value
14
- end
15
-
16
11
  # @return [Nanoc::Core::Identifier]
17
12
  attr_reader :identifier
18
13
 
@@ -56,6 +51,11 @@ module Nanoc
56
51
  @attributes_checksum_data = attributes_checksum_data
57
52
  end
58
53
 
54
+ # @return [Hash]
55
+ def attributes
56
+ @attributes.value
57
+ end
58
+
59
59
  contract C::None => self
60
60
  # @return [void]
61
61
  def freeze
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc
4
+ module Core
5
+ # @api private
6
+ class Instrumentor
7
+ def self.call(key, *args)
8
+ stopwatch = DDMetrics::Stopwatch.new
9
+ stopwatch.start
10
+ yield
11
+ ensure
12
+ stopwatch.stop
13
+ Nanoc::Core::NotificationCenter.post(key, stopwatch.duration, *args)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -3,17 +3,17 @@
3
3
  module Nanoc
4
4
  module Core
5
5
  class TextualContent < Content
6
- contract C::None => String
7
- def string
8
- @string.value
9
- end
10
-
11
6
  contract C::Or[String, Proc], C::KeywordArgs[filename: C::Optional[C::Maybe[String]]] => C::Any
12
7
  def initialize(string, filename: nil)
13
8
  super(filename)
14
9
  @string = Nanoc::Core::LazyValue.new(string)
15
10
  end
16
11
 
12
+ contract C::None => String
13
+ def string
14
+ @string.value
15
+ end
16
+
17
17
  contract C::None => self
18
18
  def freeze
19
19
  super
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Core
5
- VERSION = '4.11.2'
5
+ VERSION = '4.11.3'
6
6
  end
7
7
  end
data/lib/nanoc/core.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  # Ruby stdlib
4
4
  require 'singleton'
5
+ require 'tmpdir'
5
6
 
6
7
  # External gems
7
8
  require 'json_schema'
@@ -11,6 +12,11 @@ require 'ddplugin'
11
12
  require 'hamster'
12
13
  require 'zeitwerk'
13
14
 
15
+ module Nanoc
16
+ module Core
17
+ end
18
+ end
19
+
14
20
  DDMemoize.enable_metrics
15
21
 
16
22
  inflector_class = Class.new(Zeitwerk::Inflector) do
@@ -27,7 +33,8 @@ end
27
33
  loader = Zeitwerk::Loader.new
28
34
  loader.inflector = inflector_class.new
29
35
  loader.push_dir(__dir__ + '/..')
30
- loader.ignore(File.expand_path('core/core_ext', __dir__))
36
+ loader.ignore(__dir__ + '/../nanoc-core.rb')
37
+ loader.ignore(__dir__ + '/core/core_ext')
31
38
  loader.setup
32
39
  loader.eager_load
33
40
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.11.2
4
+ version: 4.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-16 00:00:00.000000000 Z
11
+ date: 2019-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ddmemoize
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.0'
89
+ version: '2.1'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.0'
96
+ version: '2.1'
97
97
  description: Contains the core of Nanoc
98
98
  email: denis+rubygems@denis.ws
99
99
  executables: []
@@ -104,7 +104,11 @@ files:
104
104
  - README.md
105
105
  - lib/nanoc-core.rb
106
106
  - lib/nanoc/core.rb
107
+ - lib/nanoc/core/action_provider.rb
108
+ - lib/nanoc/core/action_sequence.rb
109
+ - lib/nanoc/core/action_sequence_builder.rb
107
110
  - lib/nanoc/core/binary_content.rb
111
+ - lib/nanoc/core/checksum_collection.rb
108
112
  - lib/nanoc/core/checksummer.rb
109
113
  - lib/nanoc/core/code_snippet.rb
110
114
  - lib/nanoc/core/configuration-schema.json
@@ -121,6 +125,7 @@ files:
121
125
  - lib/nanoc/core/error.rb
122
126
  - lib/nanoc/core/identifiable_collection.rb
123
127
  - lib/nanoc/core/identifier.rb
128
+ - lib/nanoc/core/instrumentor.rb
124
129
  - lib/nanoc/core/item.rb
125
130
  - lib/nanoc/core/item_collection.rb
126
131
  - lib/nanoc/core/item_rep.rb
@@ -140,7 +145,7 @@ files:
140
145
  - lib/nanoc/core/temp_filename_factory.rb
141
146
  - lib/nanoc/core/textual_content.rb
142
147
  - lib/nanoc/core/version.rb
143
- homepage: http://nanoc.ws/
148
+ homepage: https://nanoc.ws/
144
149
  licenses:
145
150
  - MIT
146
151
  metadata: {}
@@ -159,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
164
  - !ruby/object:Gem::Version
160
165
  version: '0'
161
166
  requirements: []
162
- rubygems_version: 3.0.2
167
+ rubygems_version: 3.0.3
163
168
  signing_key:
164
169
  specification_version: 4
165
170
  summary: Core of Nanoc