Class: QiitaAll

Inherits:
Object
  • Object
show all
Defined in:
lib/qiita_org/all.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ QiitaAll

Returns a new instance of QiitaAll.



4
5
6
7
8
# File 'lib/qiita_org/all.rb', line 4

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

Instance Method Details

#check_options(string) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/qiita_org/all.rb', line 35

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

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/qiita_org/all.rb', line 10

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