Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store temp data per output dir #1071

Merged
merged 12 commits into from Jan 19, 2017

Revert "Do not store temp data per-env"

This reverts commit 70eaae5.
  • Loading branch information...
ddfreyne committed Jan 17, 2017
commit a12149db9d30ce0517d7b00138654e4beccf7d8b
@@ -11,8 +11,8 @@ class ChecksumStore < ::Nanoc::Int::Store
c_obj = C::Or[Nanoc::Int::Item, Nanoc::Int::Layout, Nanoc::Int::Configuration, Nanoc::Int::CodeSnippet]

contract C::KeywordArgs[site: C::Maybe[Nanoc::Int::Site], objects: C::IterOf[c_obj]] => C::Any
def initialize(site: nil, objects:) # rubocop:disable Lint/UnusedMethodArgument
super('tmp/checksums', 1)
def initialize(site: nil, objects:)
super(Nanoc::Int::Store.tmp_path_for(env_name: (site.config.env_name if site), store_name: 'checksums'), 1)

@objects = objects

@@ -7,8 +7,8 @@ class CompiledContentCache < ::Nanoc::Int::Store
include Nanoc::Int::ContractsSupport

contract C::KeywordArgs[env_name: C::Maybe[String], items: C::IterOf[Nanoc::Int::Item]] => C::Any
def initialize(env_name: nil, items:) # rubocop:disable Lint/UnusedMethodArgument
super('tmp/compiled_content', 2)
def initialize(env_name: nil, items:)
super(Nanoc::Int::Store.tmp_path_for(env_name: env_name, store_name: 'compiled_content'), 2)

@items = items
@cache = {}
@@ -7,8 +7,8 @@ class DependencyStore < ::Nanoc::Int::Store
attr_accessor :objects

# @param [Array<Nanoc::Int::Item, Nanoc::Int::Layout>] objects
def initialize(objects, env_name: nil) # rubocop:disable Lint/UnusedMethodArgument
super('tmp/dependencies', 4)
def initialize(objects, env_name: nil)
super(Nanoc::Int::Store.tmp_path_for(env_name: env_name, store_name: 'dependencies'), 4)

@objects = objects
@new_objects = []
@@ -4,8 +4,8 @@ class OutdatednessStore < ::Nanoc::Int::Store
include Nanoc::Int::ContractsSupport

contract C::KeywordArgs[site: C::Maybe[Nanoc::Int::Site], reps: Nanoc::Int::ItemRepRepo] => C::Any
def initialize(site: nil, reps:) # rubocop:disable Lint/UnusedMethodArgument
super('tmp/outdatedness', 1)
def initialize(site: nil, reps:)
super(Nanoc::Int::Store.tmp_path_for(env_name: (site.config.env_name if site), store_name: 'outdatedness'), 1)

@outdated_reps = Set.new
@all_reps = reps
@@ -4,8 +4,8 @@ module Nanoc::Int
#
# @api private
class RuleMemoryStore < ::Nanoc::Int::Store
def initialize(env_name: nil) # rubocop:disable Lint/UnusedMethodArgument
super('tmp/rule_memory', 1)
def initialize(env_name: nil)
super(Nanoc::Int::Store.tmp_path_for(env_name: env_name, store_name: 'rule_memory'), 1)

@rule_memories = {}
end
@@ -36,6 +36,13 @@ def initialize(filename, version)
@version = version
end

# Logic for building tmp path from active environment and store name
# @api private
contract C::KeywordArgs[env_name: C::Maybe[String], store_name: String] => String
def self.tmp_path_for(env_name:, store_name:)
File.join('tmp', env_name.to_s, store_name)
end

# @group Loading and storing data

# @return The data that should be written to the disk

This file was deleted.

Oops, something went wrong.
@@ -34,4 +34,26 @@ def test_delete_and_reload_on_error
store.load
assert_equal(nil, store.data)
end

def test_tmp_path_with_nil_env
tmp_path_for_checksum = Nanoc::Int::Store.tmp_path_for(env_name: nil, store_name: 'checksum')
tmp_path_for_rule_memory = Nanoc::Int::Store.tmp_path_for(env_name: nil, store_name: 'rule_memory')
tmp_path_for_dependencies = Nanoc::Int::Store.tmp_path_for(env_name: nil, store_name: 'dependencies')
tmp_path_for_compiled_content = Nanoc::Int::Store.tmp_path_for(env_name: nil, store_name: 'compiled_content')
assert_equal('tmp/checksum', tmp_path_for_checksum)
assert_equal('tmp/rule_memory', tmp_path_for_rule_memory)
assert_equal('tmp/dependencies', tmp_path_for_dependencies)
assert_equal('tmp/compiled_content', tmp_path_for_compiled_content)
end

def test_tmp_path_with_test_env
tmp_path_for_checksum = Nanoc::Int::Store.tmp_path_for(env_name: 'test', store_name: 'checksum')
tmp_path_for_rule_memory = Nanoc::Int::Store.tmp_path_for(env_name: 'test', store_name: 'rule_memory')
tmp_path_for_dependencies = Nanoc::Int::Store.tmp_path_for(env_name: 'test', store_name: 'dependencies')
tmp_path_for_compiled_content = Nanoc::Int::Store.tmp_path_for(env_name: 'test', store_name: 'compiled_content')
assert_equal('tmp/test/checksum', tmp_path_for_checksum)
assert_equal('tmp/test/rule_memory', tmp_path_for_rule_memory)
assert_equal('tmp/test/dependencies', tmp_path_for_dependencies)
assert_equal('tmp/test/compiled_content', tmp_path_for_compiled_content)
end
end
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.