Skip to content

Commit

Permalink
Merge 71884a5 into 87ceca1
Browse files Browse the repository at this point in the history
  • Loading branch information
notEthan committed Dec 13, 2019
2 parents 87ceca1 + 71884a5 commit 45f2b23
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions lib/jsi/base.rb
Expand Up @@ -55,10 +55,7 @@ def to_s
# @return [String] a name for a constant for this class, generated from the
# schema_id. only used if the class is not assigned to another constant.
def schema_classes_const_name
name = schema.schema_id.gsub(/[^\w]/, '_')
name = 'X' + name unless name[/\A[a-zA-Z]/]
name = name[0].upcase + name[1..-1]
name
'X' + schema.schema_id.gsub(/[^\w]/, '_')
end

# @return [String] a constant name of this class
Expand Down
2 changes: 1 addition & 1 deletion test/base_test.rb
Expand Up @@ -34,7 +34,7 @@
describe 'class name' do
let(:schema_content) { {'id' => 'https://jsi/BaseTest'} }
it 'generates a class name from schema_id' do
assert_equal('JSI::SchemaClasses::Https___jsi_BaseTest_', subject.class.name)
assert_equal('JSI::SchemaClasses::Xhttps___jsi_BaseTest_', subject.class.name)
end
it 'uses an existing name' do
assert_equal('NamedSchemaInstance', NamedSchemaInstance.name)
Expand Down

0 comments on commit 45f2b23

Please sign in to comment.