Module: Rubyzen

Defined in:
lib/rubyzen/core.rb,
lib/rubyzen/project.rb,
lib/rubyzen/version.rb,
lib/rubyzen/cache/parse_cache.rb,
lib/rubyzen/expectation_helpers.rb,
lib/rubyzen/parsers/a_s_t_parser.rb,
lib/rubyzen/assertions/zen_assertions.rb,
lib/rubyzen/matchers/zen_true_matcher.rb,
lib/rubyzen/providers/blocks_provider.rb,
lib/rubyzen/providers/macros_provider.rb,
lib/rubyzen/providers/raises_provider.rb,
lib/rubyzen/assertions/assert_zen_true.rb,
lib/rubyzen/matchers/zen_empty_matcher.rb,
lib/rubyzen/matchers/zen_false_matcher.rb,
lib/rubyzen/providers/rescues_provider.rb,
lib/rubyzen/assertions/assert_zen_empty.rb,
lib/rubyzen/assertions/assert_zen_false.rb,
lib/rubyzen/collections/base_collection.rb,
lib/rubyzen/collections/file_collection.rb,
lib/rubyzen/providers/requires_provider.rb,
lib/rubyzen/providers/call_site_provider.rb,
lib/rubyzen/providers/constants_provider.rb,
lib/rubyzen/providers/file_path_provider.rb,
lib/rubyzen/collections/blocks_collection.rb,
lib/rubyzen/collections/macros_collection.rb,
lib/rubyzen/collections/raises_collection.rb,
lib/rubyzen/declarations/file_declaration.rb,
lib/rubyzen/providers/attributes_provider.rb,
lib/rubyzen/providers/class_name_provider.rb,
lib/rubyzen/providers/visibility_provider.rb,
lib/rubyzen/collections/classes_collection.rb,
lib/rubyzen/collections/methods_collection.rb,
lib/rubyzen/collections/modules_collection.rb,
lib/rubyzen/collections/rescues_collection.rb,
lib/rubyzen/declarations/block_declaration.rb,
lib/rubyzen/declarations/class_declaration.rb,
lib/rubyzen/declarations/macro_declaration.rb,
lib/rubyzen/declarations/raise_declaration.rb,
lib/rubyzen/providers/line_number_provider.rb,
lib/rubyzen/providers/source_code_provider.rb,
lib/rubyzen/collections/requires_collection.rb,
lib/rubyzen/declarations/method_declaration.rb,
lib/rubyzen/declarations/module_declaration.rb,
lib/rubyzen/declarations/rescue_declaration.rb,
lib/rubyzen/collections/call_site_collection.rb,
lib/rubyzen/collections/constants_collection.rb,
lib/rubyzen/declarations/require_declaration.rb,
lib/rubyzen/providers/if_statements_provider.rb,
lib/rubyzen/providers/lines_of_code_provider.rb,
lib/rubyzen/collections/attributes_collection.rb,
lib/rubyzen/collections/parameters_collection.rb,
lib/rubyzen/declarations/constant_declaration.rb,
lib/rubyzen/collections/declaration_collection.rb,
lib/rubyzen/declarations/attribute_declaration.rb,
lib/rubyzen/declarations/call_site_declaration.rb,
lib/rubyzen/declarations/parameter_declaration.rb,
lib/rubyzen/providers/collection_filter_provider.rb,
lib/rubyzen/declarations/if_statement_declaration.rb

Overview

Rubyzen is a Ruby architectural linter that lets you write lint rules as unit tests. It wraps RuboCop AST to provide a high-level, easy-to-use API for enforcing architectural rules across a codebase.

‘require ’rubyzen’‘ loads this framework-agnostic core API only. To make an assertion on a collection in a test, require the respective adapter: rubyzen/rspec (the zen_* matchers) or rubyzen/minitest (the assert_zen_* assertions).

Examples:

Querying the project

project = Rubyzen::Project.new(["/path/to/src", "/path/to/spec"])
controllers = project.files.with_paths("controllers/").classes
controllers.all_methods.call_sites.with_name("where") # => CallSiteCollection

Using auto-discovery (from project root)

project = Rubyzen::Project.new  # scans app/, lib/, src/, spec/ automatically

Defined Under Namespace

Modules: Assertions, Cache, Collections, Declarations, ExpectationHelpers, Matchers, Parsers, Providers Classes: Configuration, Error, ParseError, Project

Constant Summary collapse

VERSION =

Returns the current gem version.

Returns:

  • (String)

    the current gem version

'0.2.0'

Class Method Summary collapse

Class Method Details

.configurationConfiguration

Returns the global configuration instance.

Returns:



67
68
69
# File 'lib/rubyzen/core.rb', line 67

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields the global configuration for customization.

Examples:

Rubyzen.configure do |config|
  config.paths = ['app', 'lib']
end

Yields:



60
61
62
# File 'lib/rubyzen/core.rb', line 60

def self.configure
  yield(configuration)
end