Class: Coconductor::Vendorer
- Inherits:
-
Object
- Object
- Coconductor::Vendorer
- Defined in:
- lib/coconductor/vendorer.rb
Constant Summary collapse
- OPTIONS =
%i[filename url repo replacements html source_path wiki].freeze
- INVALID_CHARS =
["\u202D", "\u202C", "\u200E", "\u200F"].freeze
- UPPERCASE_WORD_REGEX =
/(?:[A-Z]{3,}+ ?)+[A-Z_]+/.freeze
- UNMARKED_FIELD_REGEX =
/(?<= |^)#{UPPERCASE_WORD_REGEX}(?= |\.|,)/.freeze
Instance Attribute Summary collapse
-
#family ⇒ Object
readonly
Returns the value of attribute family.
-
#raw_content ⇒ Object
writeonly
Sets the attribute raw_content.
- #ref ⇒ Object
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
- #content ⇒ Object
- #dir ⇒ Object
- #filename ⇒ Object
-
#initialize(family, options = {}) ⇒ Vendorer
constructor
A new instance of Vendorer.
- #replacements ⇒ Object
- #source_path ⇒ Object
- #url ⇒ Object
- #vendor(version: '1.0') ⇒ Object
- #write_with_meta(content, version: '1.0') ⇒ Object
Constructor Details
#initialize(family, options = {}) ⇒ Vendorer
Returns a new instance of Vendorer.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/coconductor/vendorer.rb', line 22 def initialize(family, = {}) @family = family OPTIONS.each do |option| instance_variable_set("@#{option}", [option]) end logger.info "Vendoring #{family}" mkdir end |
Instance Attribute Details
#family ⇒ Object (readonly)
Returns the value of attribute family.
14 15 16 |
# File 'lib/coconductor/vendorer.rb', line 14 def family @family end |
#raw_content=(value) ⇒ Object
Sets the attribute raw_content
15 16 17 |
# File 'lib/coconductor/vendorer.rb', line 15 def raw_content=(value) @raw_content = value end |
#ref ⇒ Object
58 59 60 |
# File 'lib/coconductor/vendorer.rb', line 58 def ref @ref ||= 'master' end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
14 15 16 |
# File 'lib/coconductor/vendorer.rb', line 14 def repo @repo end |
Instance Method Details
#content ⇒ Object
46 47 48 |
# File 'lib/coconductor/vendorer.rb', line 46 def content content_normalized end |
#dir ⇒ Object
34 35 36 |
# File 'lib/coconductor/vendorer.rb', line 34 def dir @dir ||= File. family, vendor_dir end |
#filename ⇒ Object
38 39 40 |
# File 'lib/coconductor/vendorer.rb', line 38 def filename @filename ||= 'CODE_OF_CONDUCT.md' end |
#replacements ⇒ Object
62 63 64 |
# File 'lib/coconductor/vendorer.rb', line 62 def replacements @replacements ||= {} end |
#source_path ⇒ Object
42 43 44 |
# File 'lib/coconductor/vendorer.rb', line 42 def source_path @source_path ||= filename end |
#url ⇒ Object
50 51 52 |
# File 'lib/coconductor/vendorer.rb', line 50 def url @url || "https://github.com/#{repo}/raw/#{ref}/#{source_path}" end |
#vendor(version: '1.0') ⇒ Object
54 55 56 |
# File 'lib/coconductor/vendorer.rb', line 54 def vendor(version: '1.0') (content, version: version) end |
#write_with_meta(content, version: '1.0') ⇒ Object
66 67 68 69 |
# File 'lib/coconductor/vendorer.rb', line 66 def (content, version: '1.0') content = (content, 'version' => version) write(filepath(version), content) end |