Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ruby_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ jobs:
with:
# Can see versions using `curl https://cache.ruby-lang.org/pub/misc/ci_versions/cruby.json`
# We don't need the latest bleeding edge.
# Ruby 4.0 is not yet released, so exclude it.
stable-ruby-versions: |
exclude: [head]
exclude: [head, "4.0"]

build_from_hash:
name: "[from_hash] Build & Test"
Expand Down
9 changes: 9 additions & 0 deletions ruby/optify/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,12 @@ Sorbet/ForbidTTypeAlias:

Sorbet/ForbidTUnsafe:
Enabled: true

Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: diff_comma

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: diff_comma

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: diff_comma
3 changes: 3 additions & 0 deletions ruby/optify/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,8 @@
},
"[ruby]": {
"editor.formatOnSave": true
},
"[yaml]": {
"editor.formatOnSave": true
}
}
2 changes: 1 addition & 1 deletion ruby/optify/benchmarks/get_canonical_feature_names.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
['a', feature_a, 'b', feature_b],
['a', feature_a, 'b', feature_b, 'A_with_comments', 'a', 'B'],
['a', feature_a, 'b', feature_b, 'A_with_comments', 'a', 'B', 'a', feature_a, 'b', feature_b, 'A_with_comments', 'a', 'B', 'a', feature_a, 'b', feature_b, 'A_with_comments',
'a', 'B']
'a', 'B'],
]

#: (Optify::OptionsProvider, Array[String]) -> Array[String]
Expand Down
4 changes: 2 additions & 2 deletions ruby/optify/benchmarks/get_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[feature_a],
['a', feature_a, 'b', feature_b],
['a', feature_a, 'b', feature_b, 'A_with_comments', 'a', 'B', 'a', feature_a, 'b', feature_b, 'A_with_comments', 'a', 'B', 'a', feature_a, 'b', feature_b, 'A_with_comments',
'a', 'B']
'a', 'B'],
]

# Configurable values test suite
Expand All @@ -39,7 +39,7 @@
%w[simple with_files_in_arguments],
%w[simple complex_deep_merge],
%w[simple complex_wide_structure],
%w[simple complex_deep_merge complex_nested_objects complex_wide_structure]
%w[simple complex_deep_merge complex_nested_objects complex_wide_structure],
]

Benchmark.bm do |x|
Expand Down
20 changes: 10 additions & 10 deletions ruby/optify/lib/optify_ruby/provider_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ def get_options_with_cache(key, feature_names, config_class, _cache_options, pre
cache_key = [key, feature_names, are_configurable_strings_enabled, config_class]
@cache #: as !nil
.fetch(cache_key) do
# Handle a cache miss.
# Handle a cache miss.

# We can avoid converting the features names because they're already converted from filtering above, if that was desired.
# We don't need the constraints because we filtered the features above.
# We already know there are no overrides because we checked above.
preferences = GetOptionsPreferences.new
preferences.skip_feature_name_conversion = true
preferences.enable_configurable_strings if are_configurable_strings_enabled
# We can avoid converting the features names because they're already converted from filtering above, if that was desired.
# We don't need the constraints because we filtered the features above.
# We already know there are no overrides because we checked above.
preferences = GetOptionsPreferences.new
preferences.skip_feature_name_conversion = true
preferences.enable_configurable_strings if are_configurable_strings_enabled

result = _get_options(key, feature_names, config_class, nil, preferences)
result = _get_options(key, feature_names, config_class, nil, preferences)

@cache #: as !nil
.[]= cache_key, result
@cache #: as !nil
.[]= cache_key, result
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions ruby/optify/optify.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
'bug_tracker_uri' => 'https://github.com/juharris/optify/issues',
# Not needed because it's the same as the source_code_uri
# 'homepage_uri' => 'https://github.com/juharris/optify',
'source_code_uri' => 'https://github.com/juharris/optify'
'source_code_uri' => 'https://github.com/juharris/optify',
}

# Cross-compilation
Expand All @@ -44,7 +44,7 @@ Gem::Specification.new do |spec|

spec.add_development_dependency 'rake-compiler', '~> 1.3.0'
spec.add_development_dependency 'rbs', '~> 4.0.0.dev.4'
spec.add_development_dependency 'rubocop', '~> 1.76.1'
spec.add_development_dependency 'rubocop', '~> 1.82.1'
spec.add_development_dependency 'rubocop-sorbet', '~> 0.11.0'
spec.add_development_dependency 'sorbet', sorbet_version, sorbet_version_upper_bound
spec.add_development_dependency 'tapioca', '~> 0.17.7'
Expand Down
14 changes: 7 additions & 7 deletions ruby/optify/test/additional_features_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def test_provider_get_options_with_overrides_complex
'rootString' => 'new string',
'myObject' => {
'one' => 1321,
'something new for test_provider_get_options_with_overrides' => 'hello'
}
}
'something new for test_provider_get_options_with_overrides' => 'hello',
},
},
}

opts_json = provider.get_options_json_with_preferences('myConfig', ['a'], preferences)
Expand All @@ -78,12 +78,12 @@ def test_configurable_values_get_all_options_with_overrides
'message' => {
'$type' => 'Optify.ConfigurableString',
'base' => {
'liquid' => 'Hello {{ name }}!'
'liquid' => 'Hello {{ name }}!',
},
'arguments' => {
'name' => 'from the test'
}
}
'name' => 'from the test',
},
},
}

features = []
Expand Down
8 changes: 4 additions & 4 deletions ruby/optify/test/metadata_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def test_features_with_metadata
name: 'feature_A',
aliases: ['a'],
details: 'The file is for testing.',
owners: 'a-team@company.com'
}
owners: 'a-team@company.com',
},
)
assert_equal(expected_metadata, a_metadata)

Expand All @@ -26,8 +26,8 @@ def test_features_with_metadata
name: 'feature_B/initial',
aliases: ['b'],
details: { 'description' => 'This is a description of the feature.' },
owners: 'team-b@company.com'
}
owners: 'team-b@company.com',
},
)
assert_equal(expected_metadata, b_metadata)

Expand Down
2 changes: 1 addition & 1 deletion ruby/optify/test/optify_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_features_and_aliases
'b',
'feature_A',
'feature_B/initial'],
features_and_aliases
features_and_aliases,
)
end
end
Expand Down
4 changes: 2 additions & 2 deletions ruby/optify/test/schema_validation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_invalid_file_fails_schema_validation
invalid_file_path = File.join(temp_dir, 'invalid.json')

invalid_config = {
invalidProperty: 'this property is not allowed by the schema'
invalidProperty: 'this property is not allowed by the schema',
}
File.write(invalid_file_path, JSON.dump(invalid_config))

Expand All @@ -45,7 +45,7 @@ def test_schema_validation_with_provider_builder
invalid_file_path = File.join(temp_dir, 'invalid.json')

invalid_config = {
invalidProperty: 'this property is not allowed by the schema'
invalidProperty: 'this property is not allowed by the schema',
}
File.write(invalid_file_path, JSON.dump(invalid_config))

Expand Down