Skip to content

Commit

Permalink
fix enum default value in generator, bumps version
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Aug 23, 2016
1 parent 061d636 commit 45b034b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/protobuf/generator.cr
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,10 @@ module Protobuf
type_name = unless field.type_name.nil?
t = field.type_name.not_nil!
t = t.gsub(/^\.{0,}#{package_name.not_nil!}\.*/, "") unless package_name.nil?
# STDERR.puts t
# STDERR.puts @package_map.to_s
to_strip = @package_map.find do |k,v|
t.match(/\.{0,}#{k}/)
end
t = t.gsub(/^\.{0,}#{to_strip[0]}/, "#{to_strip[1]}") if to_strip
# STDERR.puts t
t.gsub(/^\.*/, "").split(".").map(&.camelcase).join("::")
else
":#{field.type.to_s.sub(/^TYPE_/, "").downcase}"
Expand All @@ -276,7 +273,7 @@ module Protobuf
field.type_name.nil? ?
field.default_value :
field.type == CodeGeneratorRequest::FieldDescriptorProto::Type::TYPE_ENUM ?
"#{type_name}[#{field.default_value}]" : # enum
"#{type_name}::#{field.default_value}" : # enum
raise "can't use a default value for non-native / enum types"
case field.type
when CodeGeneratorRequest::FieldDescriptorProto::Type::TYPE_DOUBLE
Expand Down
2 changes: 1 addition & 1 deletion src/protobuf/version.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Protobuf
VERSION = "2.0.0"
VERSION = "2.0.1"
end

0 comments on commit 45b034b

Please sign in to comment.