Class: Gem::Release::Files::Template
- Inherits:
-
Object
- Object
- Gem::Release::Files::Template
- Defined in:
- lib/gem/release/files/template.rb,
lib/gem/release/files/template/context.rb
Defined Under Namespace
Classes: Context
Constant Summary collapse
- FILES =
{ '.gitignore' => '.gitignore', 'Gemfile' => 'Gemfile', 'gemspec' => '%{gem_name}.gemspec', 'license' => 'MIT-LICENSE.md', 'main.rb' => 'lib/%{gem_path}.rb', 'version.rb' => 'lib/%{gem_path}/version.rb' }.freeze
- PATH =
File.('../..', __FILE__)
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#opts ⇒ Object
Returns the value of attribute opts.
-
#source ⇒ Object
Returns the value of attribute source.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
- #exists? ⇒ Boolean
- #filename ⇒ Object
-
#initialize(source, target, data, opts) ⇒ Template
constructor
A new instance of Template.
- #write ⇒ Object
Constructor Details
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
19 20 21 |
# File 'lib/gem/release/files/template.rb', line 19 def data @data end |
#opts ⇒ Object
Returns the value of attribute opts.
19 20 21 |
# File 'lib/gem/release/files/template.rb', line 19 def opts @opts end |
#source ⇒ Object
Returns the value of attribute source.
19 20 21 |
# File 'lib/gem/release/files/template.rb', line 19 def source @source end |
#target ⇒ Object
Returns the value of attribute target.
19 20 21 |
# File 'lib/gem/release/files/template.rb', line 19 def target @target end |
Instance Method Details
#exists? ⇒ Boolean
43 44 45 |
# File 'lib/gem/release/files/template.rb', line 43 def exists? File.exist?(target.to_s) end |
#filename ⇒ Object
30 31 32 |
# File 'lib/gem/release/files/template.rb', line 30 def filename File.basename(target) end |
#write ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/gem/release/files/template.rb', line 34 def write return false if exists? FileUtils.mkdir_p(File.dirname(target)) File.write(target, render) FileUtils.chmod('+x', target) if opts[:executable] true end |