Skip to content

Commit

Permalink
Merge pull request #112 from Earlopain/no-ostruct
Browse files Browse the repository at this point in the history
Remove dependency on `ostruct`
  • Loading branch information
PikachuEXE authored Dec 28, 2024
2 parents 84486c5 + 2789df1 commit 34a5a11
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions lib/gem/release/data.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
require 'erb'
require 'ostruct'
require_relative 'helper/string'

module Gem
module Release
class Data < Struct.new(:git, :gem, :opts)
include Helper::String

KEYS = %i[
gem_name gem_path module_names author email homepage
licenses summary description files bin_files
].freeze

def data
{
gem_name: gem_name,
gem_path: gem_path,
module_names: module_names,
author: user_name,
email: user_email,
homepage: homepage,
licenses: licenses,
summary: '[summary]',
description: '[description]',
files: files,
bin_files: bin_files
}
KEYS.map { |key| [key, send(key)] }.to_h
end

private
Expand All @@ -41,11 +33,11 @@ def user_login
git.user_login || '[your login]'
end

def user_name
def author
git.user_name || '[your name]'
end

def user_email
def email
git.user_email || '[your email]'
end

Expand All @@ -72,6 +64,14 @@ def bin_files
def strategy
STRATEGIES[(opts[:strategy] || :glob).to_sym] || STRATEGIES[:glob]
end

def summary
'[summary]'
end

def description
'[description]'
end
end
end
end
2 changes: 1 addition & 1 deletion lib/gem/release/files/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def binding
end

def context
Context.new(data)
Context.new(*data.values)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gem/release/files/template/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Gem
module Release
module Files
class Template
class Context < OpenStruct
class Context < Struct.new(*Gem::Release::Data::KEYS)
class Const < Struct.new(:type, :names)
def define(&block)
lines = build(names) { |name| "#{type} #{name}" }
Expand Down

0 comments on commit 34a5a11

Please sign in to comment.