lib/vendorer.rb in vendorer-0.1.8 vs lib/vendorer.rb in vendorer-0.1.9
- old
+ new
@@ -45,9 +45,21 @@
content = File.read(path)
result = yield content
File.open(path,'w'){|f| f.write(result) }
end
+ # Creates Vendorfile with examples
+ def init
+ separator = "<!-- extracted by vendorer init -->"
+ readme = File.read(File.expand_path('../../Readme.md', __FILE__))
+ examples = readme.split(separator)[1]
+ examples.gsub!(/```.*/,'') # remove ``` from readme
+ examples = examples.split("\n").map do |l|
+ (l.start_with? '#' or l.empty?) ? l : "# #{l}"
+ end.join("\n")
+ File.open('Vendorfile', 'w') { |f| f.write(examples.strip) }
+ end
+
private
def update_or_not(path)
update_requested = (@options[:update] and (@options[:update] == true or path.start_with?(@options[:update]+'/') or path == @options[:update]))
if update_requested or not File.exist?(path)