Sha256: d593af8dccc5bcfae5f8303beb2b9b96ab96678e891f5710531d4b220f9abc54

Contents?: true

Size: 1.14 KB

Versions: 26

Compression:

Stored size: 1.14 KB

Contents

module Writefully
  module Tools
    class Initializer
      include Celluloid

      INITIALIZE_SCRIPT = File.dirname(__FILE__) + "/../../../scripts/initialize.sh"

      attr_reader :message, :api

      def initialize message
        @message = message
        @api = Github.new oauth_token: message[:auth_token]
      end

      def add_sample_content
        Writefully.logger.info "Adding Sample content #{message[:site_slug]}"
        Source.sample_content_paths.map do |path|
          api.repos.contents.create  message[:user_name], 
                                     message[:site_slug], 
                                     path, sample_content_for(path.split('/').last)     
        end
      end

      def build_content_folder
        Writefully.logger.info "Creating content folder #{message[:site_slug]}"
        system(content_folder_setup_command)
      end

      def content_folder_setup_command
        ['bash', INITIALIZE_SCRIPT, Writefully.options[:content], message[:site_slug], message[:ssh_url]].join(' ')
      end

      def sample_content_for file_name
        Source.sample_content_properties(file_name)
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
writefully-0.8.2 lib/writefully/tools/initializer.rb
writefully-0.8.1 lib/writefully/tools/initializer.rb
writefully-0.8.0 lib/writefully/tools/initializer.rb
writefully-0.7.1 lib/writefully/tools/initializer.rb
writefully-0.6.12 lib/writefully/tools/initializer.rb
writefully-0.6.11 lib/writefully/tools/initializer.rb
writefully-0.6.10 lib/writefully/tools/initializer.rb
writefully-0.6.9 lib/writefully/tools/initializer.rb
writefully-0.6.7 lib/writefully/tools/initializer.rb
writefully-0.6.6 lib/writefully/tools/initializer.rb
writefully-0.6.5 lib/writefully/tools/initializer.rb
writefully-0.6.4 lib/writefully/tools/initializer.rb
writefully-0.6.3 lib/writefully/tools/initializer.rb
writefully-0.6.2 lib/writefully/tools/initializer.rb
writefully-0.5.1 lib/writefully/tools/initializer.rb
writefully-0.5.0 lib/writefully/tools/initializer.rb
writefully-0.4.10 lib/writefully/tools/initializer.rb
writefully-0.4.8 lib/writefully/tools/initializer.rb
writefully-0.4.7 lib/writefully/tools/initializer.rb
writefully-0.4.6 lib/writefully/tools/initializer.rb