lazy_names 0.2.0 → 2.0.0

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.
data/README.md CHANGED
@@ -1,6 +1,13 @@
1
+ [![rake](https://github.com/zhisme/lazy_names/actions/workflows/rake.yml/badge.svg)](https://github.com/zhisme/lazy_names/actions/workflows/rake.yml)
2
+ [![Gem Version](https://badge.fury.io/rb/lazy_names.svg?icon=si%3Arubygems)](https://badge.fury.io/rb/lazy_names)
3
+ ![Gem Total Downloads](https://img.shields.io/gem/dt/lazy_names)
4
+ [![Hits-of-Code](https://hitsofcode.com/github/zhisme/lazy_names?branch=master)](https://hitsofcode.com/github/zhisme/lazy_names/view?branch=master)
5
+ [![codecov](https://codecov.io/gh/zhisme/lazy_names/graph/badge.svg?token=ZQXGBALJSK)](https://codecov.io/gh/zhisme/lazy_names)
6
+ ![GitHub License](https://img.shields.io/github/license/zhisme/lazy_names)
7
+
1
8
  # lazy_names
2
9
 
3
- LazyNames helps programmer to type faster very-long class names, constants by defining them on a shorter version.
10
+ lazy_names helps programmer to type faster very-long class names constants by defining them on a shorter version.
4
11
  If you are lazy like me typing many times a day in console long constants then this gem will ease your development process.
5
12
 
6
13
  ## Why
@@ -8,6 +15,18 @@ If you are lazy like me typing many times a day in console long constants then t
8
15
  Consider this example from pry terminal session.
9
16
  ![Lazy names in action](https://media.giphy.com/media/7CtRJfp2yocsOu9zEA/source.gif)
10
17
 
18
+ The idea is to reduce typing of long namespaced constants to shorter versions. It's very useful when you have a lot of nested namespaces and you need to access them frequently. This gem will take your responsibility to redefine constants to shorter versions and making constant/classes validations.
19
+
20
+ ## Why Plain Ruby? (v2.0+)
21
+
22
+ LazyNames v2.0 uses plain Ruby instead of YAML because:
23
+
24
+ - ✅ **Intuitive**: Same syntax you'd write in `.irbrc`/`.pryrc`
25
+ - ✅ **IDE Support**: Syntax highlighting and autocomplete work out of the box
26
+ - ✅ **Validation**: Constants are validated at load time
27
+ - ✅ **Simpler**: No YAML parsing, no extra abstraction
28
+ - ✅ **Ruby-native**: Write Ruby to configure Ruby
29
+
11
30
  ## Installation
12
31
 
13
32
  1. Add this line to your application's Gemfile:
@@ -44,7 +63,9 @@ bundle
44
63
 
45
64
  4. Create your own lazy_names config where you define constants
46
65
  ```bash
47
- cp .lazy_names.tt.yml ~/.lazy_names.yml
66
+ touch ~/.lazy_names.rb
67
+ # or for project-specific config
68
+ touch .lazy_names.rb
48
69
  ```
49
70
 
50
71
  5. Login into your rails or non-rails console
@@ -55,67 +76,105 @@ $ bundle exec rails c # or bin/console
55
76
 
56
77
  ## Configuration
57
78
 
58
- ### Global definition
79
+ Create a `.lazy_names.rb` file in your project root or home directory:
80
+
81
+ ```ruby
82
+ # .lazy_names.rb
83
+ MUCC = Models::Users::CreditCard
84
+ SPP = Services::PaymentProcessor
85
+ CAVUC = Controllers::API::V1::UsersController
86
+ ```
87
+
88
+ ### File Lookup Priority
89
+
90
+ LazyNames looks for configuration in this order:
91
+
92
+ 1. `./.lazy_names.rb` (project-specific) — **recommended**
93
+ 2. `~/.lazy_names.rb` (global fallback)
94
+
95
+ ### Project-Specific Configuration (Recommended)
59
96
 
60
- Take a look onto `lazy_names.tt.yml` it has very basic template for you to start.
97
+ **This is the preferred approach.** Create `.lazy_names.rb` in your project root:
61
98
 
62
- ```yml
63
- ---
64
- my_awesome_project:
65
- definitions:
66
- 'Models::Users::CreditCard': 'MUCC'
99
+ ```ruby
100
+ # myproject/.lazy_names.rb
101
+ MUCC = Models::Users::CreditCard
102
+ SPP = Services::PaymentProcessor
67
103
  ```
68
- `my_awesome_project` should be you project/folder name
69
104
 
70
- So consider this example:
105
+ Why project-specific files are better:
106
+ - Version controlled with your project (or gitignored for personal shortcuts)
107
+ - Explicit about what's loaded — no surprises
108
+ - Each project has exactly the shortcuts it needs
109
+ - No conflicts between projects
110
+
111
+ Don't forget to add it to `.gitignore` if you don't want to share:
71
112
  ```sh
72
- $ pwd
73
- /Users/name/my_awesome_project
74
- ```
75
- The last folder name of you ruby project must match the same one in your configuration.
76
- After **definitions** sections you can actually redefine your long constants.
77
- So in this example `Models::Users::CreditCard` is your real project constant and
78
- `MUCC` will be your short variant of it, so you can access `Models::Users::CreditCard`
79
- from `MUCC`. `MUCC` and any other right hand side can be any value, you define the best-suitable names.
80
-
81
- You can define as many constants as you want. The same rule applies for projects.
82
- Your config can have multiple constant definitions per namespace.
83
- ```yml
84
- ---
85
- my_awesome_project:
86
- definitions:
87
- 'Models::Users::CreditCard': 'MUCC'
88
- my_another_project:
89
- definitions:
90
- 'OtherLongConst': 'Short'
113
+ echo '.lazy_names.rb' >> .gitignore
91
114
  ```
92
115
 
93
- ### Project definitions
116
+ ### Global Configuration
94
117
 
95
- In the meantime you can put your `.lazy_names.yml` config directly to project folder, it will be looked up firstly from project.
96
- Just do not forget to put in your `.gitignore`. I believe every developer defines shorter versions of constants by his own opinion.
97
- ```sh
98
- echo '.lazy_names.yml' >> .gitignore
118
+ For shortcuts that work across multiple projects, create `~/.lazy_names.rb` in your home directory.
119
+
120
+ **Important:** Use `if defined?()` guards since constants vary between projects:
121
+
122
+ ```ruby
123
+ # ~/.lazy_names.rb
124
+ # Generic Rails shortcuts (usually available)
125
+ AR = ActiveRecord if defined?(ActiveRecord)
126
+ AM = ActionMailer if defined?(ActionMailer)
127
+
128
+ # Only defined if these exist in the current project
129
+ MU = Models::User if defined?(Models::User)
99
130
  ```
100
- If project folder doesn't contain any `.lazy_names.yml`, it will fallback to home directory.
101
131
 
102
- Configuration per project a bit different: you don't need to specify global scope `my_awesome_project`, you can skip forward to definitions
103
- ```yml
104
- ---
105
- definitions:
106
- 'Models::Users::CreditCard: 'MUCC'
132
+ **Note:** v2.0 intentionally removed namespace/project scoping that existed in v1.x YAML configs. The `if defined?()` pattern is simpler and achieves the same result without magic.
133
+
134
+ ### Validation
135
+
136
+ LazyNames validates each line:
137
+
138
+ - ✅ Must be a constant assignment: `SHORT = Full::Constant::Path`
139
+ - ✅ Constant must exist in your application
140
+ - ⚠️ Invalid lines are skipped with a warning
141
+
142
+ ### Examples
143
+
144
+ ```ruby
145
+ # Comments are allowed
146
+ MUCC = Models::Users::CreditCard
147
+
148
+ # Blank lines are fine
149
+
150
+ SPP = Services::PaymentProcessor
151
+
152
+ # Underscores and numbers in short names
153
+ API_V1 = API::V1
154
+ CACHE2 = Cache::RedisCache
107
155
  ```
108
- Example config can be found in `.lazy_names.tt.project.yml`
156
+
157
+ ## Migrating from v1.x to v2.0
158
+
159
+ LazyNames v2.0 removes YAML support in favor of plain Ruby configuration.
160
+
161
+ **Upgrading from v1.x?** See the complete [Migration Guide](MIGRATION_FROM_V1.md) for:
162
+ - Automated conversion script
163
+ - Step-by-step instructions
164
+ - Troubleshooting tips
165
+ - New features in v2.0
109
166
 
110
167
  ## Development
111
168
 
112
169
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
170
+ After you make changes ensure to run `rake rubocop` to check if your code meets linter standards.
113
171
 
114
172
  To install this gem onto your local machine, run `bundle exec rake install`.
115
173
 
116
174
  ## Contributing
117
175
 
118
176
  Bug reports and pull requests are welcome on GitHub at https://github.com/zhisme/lazy_names.
177
+ Ensure the CI build is green by validating tests are passing and coverage is not decreased.
119
178
 
120
179
  ## License
121
180
 
data/Rakefile CHANGED
@@ -1,6 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
3
6
 
4
- RSpec::Core::RakeTask.new(:spec)
7
+ task default: %i[clean rubocop spec]
5
8
 
6
- task default: :spec
9
+ desc 'Run RuboCop'
10
+ RuboCop::RakeTask.new(:rubocop)
11
+
12
+ RSpec::Core::RakeTask.new(:spec)
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'lazy_names'
data/bin/convert_to_v2 ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'yaml'
5
+
6
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
7
+ def convert_yaml_to_ruby
8
+ yaml_file = '.lazy_names.yml'
9
+ ruby_file = '.lazy_names.rb'
10
+
11
+ unless File.exist?(yaml_file)
12
+ puts "No #{yaml_file} found in current directory"
13
+ exit 1
14
+ end
15
+
16
+ if File.exist?(ruby_file)
17
+ puts "#{ruby_file} already exists. Remove it first or merge manually."
18
+ exit 1
19
+ end
20
+
21
+ begin
22
+ yaml = YAML.load_file(yaml_file)
23
+ definitions = extract_definitions(yaml)
24
+
25
+ if definitions.empty?
26
+ puts "No definitions found in #{yaml_file}"
27
+ exit 1
28
+ end
29
+
30
+ File.open(ruby_file, 'w') do |f|
31
+ f.puts '# Converted from .lazy_names.yml'
32
+ f.puts ''
33
+ definitions.each do |full, short|
34
+ f.puts "#{short} = #{full}"
35
+ end
36
+ end
37
+
38
+ puts "✓ Converted #{definitions.size} definitions to #{ruby_file}"
39
+ puts ''
40
+ puts 'Next steps:'
41
+ puts " 1. Review #{ruby_file}"
42
+ puts " 2. Delete #{yaml_file}"
43
+ puts ' 3. Update lazy_names gem to v2.0'
44
+ rescue StandardError => e
45
+ puts "Error: #{e.message}"
46
+ exit 1
47
+ end
48
+ end
49
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
50
+
51
+ def extract_definitions(yaml)
52
+ if yaml['definitions']
53
+ yaml['definitions']
54
+ elsif yaml.is_a?(Hash) && yaml.values.first.is_a?(Hash)
55
+ yaml.values.first['definitions'] || {}
56
+ else
57
+ {}
58
+ end
59
+ end
60
+
61
+ convert_yaml_to_ruby
data/lazy_names.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'lazy_names/version'
@@ -9,10 +11,10 @@ Gem::Specification.new do |spec|
9
11
  spec.email = ['evdev34@gmail.com']
10
12
 
11
13
  spec.description = <<~DESC
12
- lazy_names is ruby programmer friend. You can save your time not typing long
13
- error-phone constants/classes but defining short and nice versions of them.
14
+ lazy_names is ruby programmer friend. Define short aliases for long constant names using plain Ruby.
15
+ Save your time not typing long constants/classes by defining short and intuitive versions of them.
14
16
  DESC
15
- spec.summary = 'Define short constants to frequently used classes/constants'
17
+ spec.summary = 'Define short aliases for long constant names using plain Ruby'
16
18
  spec.homepage = 'https://github.com/zhisme/lazy_names'
17
19
  spec.license = 'MIT'
18
20
 
@@ -23,9 +25,6 @@ Gem::Specification.new do |spec|
23
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
26
  spec.require_paths = ['lib']
25
27
 
26
- spec.add_development_dependency 'bundler', '~> 1.16'
27
- spec.add_development_dependency 'pry', '~> 0.13'
28
- spec.add_development_dependency 'rake', '~> 10.0'
29
- spec.add_development_dependency 'rspec', '~> 3.0'
30
- spec.required_ruby_version = '>= 2.3.3'
28
+ spec.required_ruby_version = '>= 2.7'
29
+ spec.metadata['rubygems_mfa_required'] = 'true'
31
30
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LazyNames
4
+ class LineValidator
5
+ ASSIGNMENT_PATTERN = /\A\s*([A-Z][A-Z0-9_]*)\s*=\s*([A-Z][A-Za-z0-9_:]*)\s*\z/.freeze
6
+
7
+ class ValidationResult
8
+ attr_reader :valid, :short_name, :full_constant, :error
9
+
10
+ def initialize(valid:, short_name: nil, full_constant: nil, error: nil)
11
+ @valid = valid
12
+ @short_name = short_name
13
+ @full_constant = full_constant
14
+ @error = error
15
+ end
16
+
17
+ def valid?
18
+ @valid
19
+ end
20
+ end
21
+
22
+ def self.validate(line)
23
+ return skip_result if skip_line?(line)
24
+
25
+ match = line.match(ASSIGNMENT_PATTERN)
26
+ return invalid_result('Invalid syntax') unless match
27
+
28
+ short_name = match[1]
29
+ full_constant = match[2]
30
+
31
+ return invalid_result("Constant #{full_constant} not found") unless constant_exists?(full_constant)
32
+
33
+ ValidationResult.new(
34
+ valid: true,
35
+ short_name: short_name,
36
+ full_constant: full_constant
37
+ )
38
+ end
39
+
40
+ def self.skip_line?(line)
41
+ line.strip.empty? || line.strip.start_with?('#')
42
+ end
43
+
44
+ def self.constant_exists?(constant_path)
45
+ Object.const_get(constant_path)
46
+ true
47
+ rescue NameError
48
+ false
49
+ end
50
+
51
+ def self.skip_result
52
+ ValidationResult.new(valid: false)
53
+ end
54
+
55
+ def self.invalid_result(error)
56
+ ValidationResult.new(valid: false, error: error)
57
+ end
58
+
59
+ private_class_method :skip_line?, :constant_exists?, :skip_result, :invalid_result
60
+ end
61
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LazyNames
4
+ class RubyLoader
5
+ CONFIG_FILE = '.lazy_names.rb'
6
+
7
+ def self.load!(binding)
8
+ new.load!(binding)
9
+ end
10
+
11
+ def initialize
12
+ @loaded_count = 0
13
+ @skipped_count = 0
14
+ @error_count = 0
15
+ end
16
+
17
+ def load!(binding)
18
+ path = find_config_file
19
+ unless path
20
+ Kernel.warn("No #{CONFIG_FILE} found")
21
+ return
22
+ end
23
+
24
+ puts "Loading definitions from #{path}"
25
+
26
+ File.readlines(path).each_with_index do |line, index|
27
+ line_number = index + 1
28
+ process_line(line, line_number, binding)
29
+ end
30
+
31
+ log_summary
32
+ end
33
+
34
+ private
35
+
36
+ def find_config_file
37
+ project_config = File.join(Dir.pwd, CONFIG_FILE)
38
+ return project_config if File.exist?(project_config)
39
+
40
+ home_config = File.join(Dir.home, CONFIG_FILE)
41
+ return home_config if File.exist?(home_config)
42
+
43
+ nil
44
+ end
45
+
46
+ def process_line(line, line_number, binding)
47
+ result = LineValidator.validate(line)
48
+
49
+ if result.valid?
50
+ eval_line(line, binding)
51
+ @loaded_count += 1
52
+ elsif result.error
53
+ Kernel.warn("Line #{line_number}: #{result.error} - #{line.strip}")
54
+ @error_count += 1
55
+ else
56
+ # Blank line or comment - skip silently
57
+ @skipped_count += 1
58
+ end
59
+ rescue StandardError => e
60
+ Kernel.warn("Line #{line_number}: #{e.message}")
61
+ @error_count += 1
62
+ end
63
+
64
+ def eval_line(line, binding)
65
+ binding.eval(line)
66
+ end
67
+
68
+ def log_summary
69
+ puts "Loaded #{@loaded_count} definitions" if @loaded_count.positive?
70
+ Kernel.warn("Skipped #{@error_count} invalid lines") if @error_count.positive?
71
+ end
72
+ end
73
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LazyNames
2
- VERSION = '0.2.0'.freeze
4
+ VERSION = '2.0.0'
3
5
  end
data/lib/lazy_names.rb CHANGED
@@ -1,21 +1,11 @@
1
- require 'lazy_names/version'
2
- require 'lazy_names/find_namespace'
3
- require 'lazy_names/config_loader'
4
- require 'lazy_names/config'
5
- require 'lazy_names/config_validator'
6
- require 'lazy_names/definer'
7
- require 'lazy_names/logger'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lazy_names/version'
4
+ require_relative 'lazy_names/line_validator'
5
+ require_relative 'lazy_names/ruby_loader'
8
6
 
9
7
  module LazyNames
10
8
  def self.load_definitions!(top_level_binding = TOPLEVEL_BINDING)
11
- basic_config = LazyNames::ConfigLoader
12
- .(namespace: LazyNames::FindNamespace.())
13
- config = LazyNames::Config.new(basic_config.definitions, basic_config.path)
14
- config.validate!
15
- LazyNames::Definer.(config, top_level_binding)
16
-
17
- LazyNames::Logger.warn_undefined(config.errors.undefined, config.path)
18
- LazyNames::Logger.warn_duplicate_definition(config.errors.already_defined, config.path)
19
- LazyNames::Logger.warn_empty_definitions(config.constants.to_a.empty?, config.path)
9
+ RubyLoader.load!(top_level_binding)
20
10
  end
21
11
  end
metadata CHANGED
@@ -1,107 +1,52 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_names
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhisme
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-19 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.16'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.16'
27
- - !ruby/object:Gem::Dependency
28
- name: pry
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.13'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.13'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '10.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '3.0'
11
+ date: 2026-01-12 00:00:00.000000000 Z
12
+ dependencies: []
69
13
  description: |
70
- lazy_names is ruby programmer friend. You can save your time not typing long
71
- error-phone constants/classes but defining short and nice versions of them.
14
+ lazy_names is ruby programmer friend. Define short aliases for long constant names using plain Ruby.
15
+ Save your time not typing long constants/classes by defining short and intuitive versions of them.
72
16
  email:
73
17
  - evdev34@gmail.com
74
18
  executables: []
75
19
  extensions: []
76
20
  extra_rdoc_files: []
77
21
  files:
22
+ - ".github/dependabot.yml"
23
+ - ".github/workflows/codecov.yml"
24
+ - ".github/workflows/codeql.yml"
25
+ - ".github/workflows/rake.yml"
78
26
  - ".gitignore"
79
- - ".lazy_names.tt.project.yml"
80
- - ".lazy_names.tt.yml"
27
+ - ".lazy_names.tt.rb"
81
28
  - ".rspec"
82
29
  - ".rubocop.yml"
83
30
  - ".ruby-version"
84
- - ".travis.yml"
85
31
  - Gemfile
86
32
  - Gemfile.lock
87
33
  - LICENSE.txt
34
+ - MIGRATION_FROM_V1.md
88
35
  - README.md
89
36
  - Rakefile
90
37
  - bin/console
38
+ - bin/convert_to_v2
91
39
  - bin/setup
92
40
  - lazy_names.gemspec
93
41
  - lib/lazy_names.rb
94
- - lib/lazy_names/config.rb
95
- - lib/lazy_names/config_loader.rb
96
- - lib/lazy_names/config_validator.rb
97
- - lib/lazy_names/definer.rb
98
- - lib/lazy_names/find_namespace.rb
99
- - lib/lazy_names/logger.rb
42
+ - lib/lazy_names/line_validator.rb
43
+ - lib/lazy_names/ruby_loader.rb
100
44
  - lib/lazy_names/version.rb
101
45
  homepage: https://github.com/zhisme/lazy_names
102
46
  licenses:
103
47
  - MIT
104
- metadata: {}
48
+ metadata:
49
+ rubygems_mfa_required: 'true'
105
50
  post_install_message:
106
51
  rdoc_options: []
107
52
  require_paths:
@@ -110,16 +55,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
55
  requirements:
111
56
  - - ">="
112
57
  - !ruby/object:Gem::Version
113
- version: 2.3.3
58
+ version: '2.7'
114
59
  required_rubygems_version: !ruby/object:Gem::Requirement
115
60
  requirements:
116
61
  - - ">="
117
62
  - !ruby/object:Gem::Version
118
63
  version: '0'
119
64
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.5.2
65
+ rubygems_version: 3.3.26
122
66
  signing_key:
123
67
  specification_version: 4
124
- summary: Define short constants to frequently used classes/constants
68
+ summary: Define short aliases for long constant names using plain Ruby
125
69
  test_files: []
@@ -1,3 +0,0 @@
1
- ---
2
- definitions:
3
- 'Models::Users::CreditCard': 'MUCC'
data/.lazy_names.tt.yml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- my_awesome_project:
3
- definitions:
4
- 'Models::Users::CreditCard': 'MUCC'
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.3.3
7
- before_install: gem install bundler -v 1.16.3
@@ -1,40 +0,0 @@
1
- module LazyNames
2
- class Config
3
- extend Forwardable
4
-
5
- attr_reader :path, :validator
6
-
7
- def_delegator :@validator, :errors
8
-
9
- def initialize(definitions, path)
10
- @definitions = definitions
11
- @path = path
12
- @validator = ConfigValidator.new(definitions.values, definitions.keys)
13
- end
14
-
15
- def constants
16
- definitions.keys
17
- end
18
-
19
- def lazy_names
20
- definitions.values
21
- end
22
-
23
- def lazy_name(name)
24
- definitions[name]
25
- end
26
-
27
- def validate!
28
- validator.()
29
- remove_invalid_definitions!
30
- end
31
-
32
- private
33
-
34
- def remove_invalid_definitions!
35
- errors.undefined.each { |name| definitions.delete(name) }
36
- end
37
-
38
- attr_reader :definitions
39
- end
40
- end