dsl_evaluator 0.3.1 → 0.3.2

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: 641dfdf2c67b8959300970f5bc19894204a2d55a58d9652d7eccd6e18632c5e2
4
- data.tar.gz: 1e47b3a332e0af2f7fdaaaccfa7b561b53843d7e576f1f24eb9f11a00ea48d90
3
+ metadata.gz: 69172b455f5ffdc6c918bafdc703e588e2b1c30957e7e7613a6a8e77f705f77c
4
+ data.tar.gz: a6fd5725e5a190dcad901d0a7b4027e37ea4a3c5ab6b7162ecbd0212dbcf6749
5
5
  SHA512:
6
- metadata.gz: 7cb86de8092865008528a23d1e1762a8883a8c69af372c254c01fc6e5a46441ddeadb8ba4467fc7433fbce4f4ae613879b4a76412e6ca2b7f09bba60c47ac87b
7
- data.tar.gz: 9319047be3502508e571151109d3c11760050dc03f5eb97775409ce6bdc9025bf764680daec19b6c6ee2bb047eb8a453446d5003b2705febf52d0ca3e8f4bd71
6
+ metadata.gz: 574dcc68a1d64ab3c63580044b575e2dac4d5e2e5e192305755f49b4c9748126a9d7c74982dd9333ac140dad84a269d62bcc86ecad477f42cc951362240a79a1
7
+ data.tar.gz: b989216c8abf1ac4a0fa9dd93c1416393ec7f0500a4ddca07416f275226712a9019153ce447299672aca4b57c60a355e236ba2113950a79b703276d127e0f7ba
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [0.3.2] - 2024-04-22
7
+ - [#9](https://github.com/tongueroo/dsl_evaluator/pull/9) call line number in case of no color
8
+ - standardrb
9
+
6
10
  ## [0.3.1] - 2022-07-11
7
11
  - [#8](https://github.com/tongueroo/dsl_evaluator/pull/8) fix select pattern when not set
8
12
 
data/Rakefile CHANGED
@@ -3,4 +3,4 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,25 +1,25 @@
1
- require_relative 'lib/dsl_evaluator/version'
1
+ require_relative "lib/dsl_evaluator/version"
2
2
 
3
3
  Gem::Specification.new do |spec|
4
- spec.name = "dsl_evaluator"
5
- spec.version = DslEvaluator::VERSION
6
- spec.authors = ["Tung Nguyen"]
7
- spec.email = ["tongueroo@gmail.com"]
4
+ spec.name = "dsl_evaluator"
5
+ spec.version = DslEvaluator::VERSION
6
+ spec.authors = ["Tung Nguyen"]
7
+ spec.email = ["tongueroo@gmail.com"]
8
8
 
9
- spec.summary = "DSL evaluation library. It produces a human-friendly backtrace error"
10
- spec.homepage = "https://github.com/tongueroo/dsl_evaluator"
11
- spec.license = "MIT"
9
+ spec.summary = "DSL evaluation library. It produces a human-friendly backtrace error"
10
+ spec.homepage = "https://github.com/tongueroo/dsl_evaluator"
11
+ spec.license = "MIT"
12
12
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
13
 
14
14
  spec.metadata["homepage_uri"] = spec.homepage
15
15
 
16
16
  # Specify which files should be added to the gem when it is released.
17
17
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
19
19
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
20
  end
21
- spec.bindir = "exe"
22
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "activesupport"
@@ -15,7 +15,7 @@ module DslEvaluator
15
15
 
16
16
  config.logger = default_logger
17
17
  config.logger.formatter = Logger::Formatter.new
18
- config.logger.level = ENV['DSL_EVALUATOR_LOG_LEVEL'] || :info
18
+ config.logger.level = ENV["DSL_EVALUATOR_LOG_LEVEL"] || :info
19
19
 
20
20
  config.on_exception = :raise
21
21
 
@@ -29,7 +29,7 @@ module DslEvaluator
29
29
  end
30
30
 
31
31
  def default_logger
32
- Logger.new(ENV['DSL_EVALUATOR_LOG_PATH'] || $stderr)
32
+ Logger.new(ENV["DSL_EVALUATOR_LOG_PATH"] || $stderr)
33
33
  end
34
34
  memoize :default_logger
35
35
 
@@ -4,7 +4,7 @@ module DslEvaluator
4
4
  class Autoloader
5
5
  class Inflector < Zeitwerk::Inflector
6
6
  def camelize(basename, _abspath)
7
- map = { cli: "CLI", version: "VERSION" }
7
+ map = {cli: "CLI", version: "VERSION"}
8
8
  map[basename.to_sym] || super
9
9
  end
10
10
  end
@@ -3,7 +3,7 @@ module DslEvaluator
3
3
  def initialize(*args)
4
4
  super
5
5
  self.formatter = Formatter.new
6
- self.level = ENV['DSL_EVALUATOR_LOG_LEVEL'] || :info # note: only respected when config.logger not set in config/app.rb
6
+ self.level = ENV["DSL_EVALUATOR_LOG_LEVEL"] || :info # note: only respected when config.logger not set in config/app.rb
7
7
  end
8
8
 
9
9
  def format_message(severity, datetime, progname, msg)
@@ -12,7 +12,7 @@ module DslEvaluator
12
12
  else
13
13
  super # use the configured formatter
14
14
  end
15
- line =~ /\n$/ ? line : "#{line}\n"
15
+ /\n$/.match?(line) ? line : "#{line}\n"
16
16
  end
17
17
 
18
18
  # Used to allow output to always go to stdout
@@ -12,26 +12,26 @@ class DslEvaluator::Printer
12
12
  # windows: "C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/builder.rb:34:in `build'"
13
13
  # linux: "/home/ec2-user/.rvm/gems/ruby-3.0.3/gems/terraspace-1.1.1/lib/terraspace/compiler/dsl/syntax/mod.rb:4:in `<module:Mod>'"
14
14
  caller_line = args[0]
15
- parts = caller_line.split(':')
15
+ parts = caller_line.split(":")
16
16
  is_windows = caller_line.match(/^[a-zA-Z]:/) # windows vs linux
17
17
  calling_file = is_windows ? parts[1] : parts[0]
18
- line_number = is_windows ? parts[2] : parts[1]
18
+ line_number = is_windows ? parts[2] : parts[1]
19
19
  path = calling_file
20
20
  end
21
21
 
22
22
  check_line_number!(line_number)
23
23
  line_number = line_number.to_i
24
24
 
25
- logger.info "Here's the original caller line from:"
25
+ logger.info "Here's the original caller line #{line_number} from:"
26
26
  logger.info pretty_path(path).color(:green)
27
27
 
28
28
  contents = IO.read(path)
29
29
  content_lines = contents.split("\n")
30
30
  context = 5 # lines of context
31
- top, bottom = [line_number-context-1, 0].max, line_number+context-1
31
+ top, bottom = [line_number - context - 1, 0].max, line_number + context - 1
32
32
  lpad = content_lines.size.to_s.size
33
33
  content_lines[top..bottom].each_with_index do |line_content, index|
34
- current_line = top+index+1
34
+ current_line = top + index + 1
35
35
  if current_line == line_number
36
36
  printf("%#{lpad}d %s\n".color(:red), current_line, line_content)
37
37
  else
@@ -39,7 +39,7 @@ class DslEvaluator::Printer
39
39
  end
40
40
  end
41
41
 
42
- logger.info "Rerun with FULL_BACKTRACE=1 to see full backtrace" unless ENV['FULL_BACKTRACE']
42
+ logger.info "Rerun with FULL_BACKTRACE=1 to see full backtrace" unless ENV["FULL_BACKTRACE"]
43
43
  end
44
44
 
45
45
  def check_line_number!(line_number)
@@ -53,13 +53,12 @@ class DslEvaluator::Printer
53
53
  end
54
54
 
55
55
  def pretty_path(path)
56
- path.sub("#{Dir.pwd}/",'').sub(/^\.\//,'')
56
+ path.sub("#{Dir.pwd}/", "").sub(/^\.\//, "")
57
57
  end
58
58
 
59
59
  # Replace HOME with ~ - different from the main pretty_path
60
60
  def pretty_home(path)
61
- path.sub(ENV['HOME'], '~')
61
+ path.sub(ENV["HOME"], "~")
62
62
  end
63
63
  end
64
64
  end
65
-
@@ -11,7 +11,7 @@ module DslEvaluator
11
11
  line_number = info[:line_number].to_i
12
12
  logger.error "ERROR: #{@error.message}".color(:red)
13
13
  logger.error "Error evaluating #{pretty_path(path)}".color(:red)
14
- logger.error "Here's the line with the error:\n\n"
14
+ logger.error "Here's line #{line_number} with the error:\n\n"
15
15
  print_code(path, line_number)
16
16
  end
17
17
 
@@ -25,7 +25,7 @@ module DslEvaluator
25
25
 
26
26
  def info_from_message
27
27
  error_info = @error.message
28
- path, line_number, _ = error_info.split(':')
28
+ path, line_number, _ = error_info.split(":")
29
29
  {path: path, line_number: line_number}
30
30
  end
31
31
 
@@ -38,7 +38,7 @@ module DslEvaluator
38
38
  #
39
39
  def info_from_backtrace
40
40
  lines = @error.backtrace
41
- if ENV['FULL_BACKTRACE']
41
+ if ENV["FULL_BACKTRACE"]
42
42
  logger.error @error.message.color(:red)
43
43
  logger.error lines.join("\n")
44
44
  else
@@ -47,7 +47,7 @@ module DslEvaluator
47
47
  end
48
48
 
49
49
  error_info = lines.first
50
- parts = error_info.split(':')
50
+ parts = error_info.split(":")
51
51
  windows = error_info.match(/^[a-zA-Z]:/)
52
52
  path = windows ? parts[1] : parts[0]
53
53
  line_number = windows ? parts[2] : parts[1]
@@ -86,7 +86,7 @@ module DslEvaluator
86
86
  end
87
87
 
88
88
  def pretty_path(path)
89
- path.sub("#{config.root}/",'')
89
+ path.sub("#{config.root}/", "")
90
90
  end
91
91
 
92
92
  def logger
@@ -101,4 +101,4 @@ module DslEvaluator
101
101
  @error.message
102
102
  end
103
103
  end
104
- end
104
+ end
@@ -1,3 +1,3 @@
1
1
  module DslEvaluator
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
data/lib/dsl_evaluator.rb CHANGED
@@ -1,10 +1,10 @@
1
- require 'active_support'
2
- require 'active_support/core_ext/class'
3
- require 'active_support/core_ext/hash'
4
- require 'active_support/core_ext/string'
5
- require 'dsl_evaluator/version'
6
- require 'memoist'
7
- require 'rainbow/ext/string'
1
+ require "active_support"
2
+ require "active_support/core_ext/class"
3
+ require "active_support/core_ext/hash"
4
+ require "active_support/core_ext/string"
5
+ require "dsl_evaluator/version"
6
+ require "memoist"
7
+ require "rainbow/ext/string"
8
8
 
9
9
  require "dsl_evaluator/autoloader"
10
10
  DslEvaluator::Autoloader.setup
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsl_evaluator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-11 00:00:00.000000000 Z
11
+ date: 2024-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubygems_version: 3.3.12
114
+ rubygems_version: 3.4.19
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: DSL evaluation library. It produces a human-friendly backtrace error