Sha256: b37fdc682500f9a6d6a98392dd368805232ca74fbecf62fb3d8a80b7678ec290

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

require 'eucalypt/errors'
require 'eucalypt/helpers'
require 'eucalypt/list'
require 'eucalypt/blog/namespaces/blog/__require__'
require 'eucalypt/blog/namespaces/blog-article/cli/article'

module Eucalypt
  class Blog < Thor
    include Thor::Actions
    include Eucalypt::Helpers
    include Eucalypt::Helpers::Messages
    include Eucalypt::Helpers::Gemfile
    using Colorize
    extend Eucalypt::List

    option :route, type: :string, aliases: '-r', default: 'blog', desc: "The route at which the blog lies"
    desc "setup", "Sets up the blog environment".colorize(:grey)
    def setup
      directory = File.expand_path('.')
      if Eucalypt.app? directory
        Out.setup 'Setting up blog environment...'

        gemfile_add(
          'Markdown and YAML front-matter parsing',
          {front_matter_parser: '0.2.0', rdiscount: '~> 2.2'},
          directory
        )

        generator = Eucalypt::Generators::Blog.new
        generator.destination_root = directory
        generator.helper
        generator.controller(route: options[:route])
        generator.views

        assets_file = File.join(directory, 'config', 'assets.rb')

        File.open(assets_file) do |f|
          return if f.read.include? "assets.append_path Eucalypt.path 'app', 'assets', 'blog'"
        end

        insert_into_file(
          assets_file,
          "  assets.append_path Eucalypt.path 'app', 'assets', 'blog'\n",
          after: "set :assets, Sprockets::Environment.new\n"
        )
      else
        Eucalypt::Error.wrong_directory
      end
    end

    def self.banner(task, namespace = false, subcommand = true)
      basename + ' ' + task.formatted_usage(self, true, subcommand).split(':').join(' ')
    end

    register(Eucalypt::BlogArticle, 'article', 'article [COMMAND]', 'Create, edit and destroy blog articles'.colorize(:grey))
  end

  class CLI < Thor
    include Eucalypt::Helpers
    using Colorize
    register(Blog, 'blog', 'blog [COMMAND]', 'Manage static blog environment'.colorize(:grey))
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eucalypt-0.5.1 lib/eucalypt/blog/namespaces/blog/cli/blog.rb
eucalypt-0.5.0 lib/eucalypt/blog/namespaces/blog/cli/blog.rb