Sha256: f72905548e70824ac990353496792e815ff0a8c07150137da920bced129a574d

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module Love
  module Share
    class << self

      def md(by_gemname = false)
        if by_gemname
          render_by_gem Love.gems
        else
          render_by_author Love.authors
        end
      end

      private

      def render_by_author(authors)
        template = File.read(Love.root.join '../templates/md/by_author.md.erb')
        author_template = File.read(Love.root.join '../templates/md/_author.md.erb')
        content = ''
        authors.each do |author|
          content << ERB.new(author_template).result(binding)
        end
        File.open('./LOVE.md', 'w+') do |f|
          f.write ERB.new(template).result(binding)
        end
      end

      def render_by_gem(gems)
        template = File.read(Love.root.join '../templates/md/by_gem.md.erb')
        gem_template = File.read(Love.root.join '../templates/md/_gem.md.erb')
        content = ''
        gems.each do |gem|
          content << ERB.new(gem_template).result(binding)
        end
        File.open('./LOVE.md', 'w+') do |f|
          f.write ERB.new(template).result(binding)
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
share_some_love-0.0.5 lib/love/share.rb