Sha256: a4e2f8807fac903efe5c3bb0e6d3b351575e63b8ed66560a0210fe3d9a3331fa

Contents?: true

Size: 1.17 KB

Versions: 9

Compression:

Stored size: 1.17 KB

Contents

require "colorize"

class QiitaAll
  def initialize(argv)
    check_options(argv)
    @files = Dir.glob("*.org")
    p @files
  end

  def run()
    @files.each do |file|
      unless @exclude_files.empty?
        next if @exclude_files.include?(file)
        #if @exclude_files.include?(file)
         # next
        #end
      end

      unless @mode
        puts file.blue
        if File.read(file).match(/#\+qiita_(.+)/)
          system ("qiita post #{file} open") if File.read(file).match(/#\+(.+)_public/)
          system ("qiita post #{file} teams") if File.read(file).match(/#\+(.+)_teams/)
          system ("qiita post #{file} private") if File.read(file).match(/#\+(.+)_private/)
        else
          system ("qiita post #{file}")
        end
      else
        puts "qiita post #{file} #{@mode}".blue
        system "qiita post #{file} #{@mode}"
      end
    end
  end

  def check_options(string)
    ["teams", "private", "public"].each do |i|
      if string.include?(i)
        @mode = i
        break
      else
        @mode = false
      end
    end

    @exclude_files = []
    if string.include?("--exclude")
      @exclude_files = string.grep(/.org/)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
qiita_org-0.2.2 lib/qiita_org/all.rb
qiita_org-0.2.1 lib/qiita_org/all.rb
qiita_org-0.1.41 lib/qiita_org/all.rb
qiita_org-0.1.40 lib/qiita_org/all.rb
qiita_org-0.1.39 lib/qiita_org/all.rb
qiita_org-0.1.38 lib/qiita_org/all.rb
qiita_org-0.1.37 lib/qiita_org/all.rb
qiita_org-0.1.35 lib/qiita_org/all.rb
qiita_org-0.1.34 lib/qiita_org/all.rb