Class: Miyano::Push

Inherits:
Thor::Group
  • Object
show all
Defined in:
lib/miyano/cli/push.rb

Instance Method Summary collapse

Instance Method Details

#build_everytimeObject



33
34
35
# File 'lib/miyano/cli/push.rb', line 33

def build_everytime
  CLI.new.build
end

#check_if_firstObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/miyano/cli/push.rb', line 13

def check_if_first
  unless Dir.exist? File.join @dir, ".git"
    FileUtils.mkdir_p @dir
    FileUtils.cd @dir do
      p "Enter the url of your Github Pages repo"
      p "(eg: https://github.com/username/username.github.io)"
      p "WARN: It will delete all files already in the repo"
      print "repo url:";repo = STDIN.gets.chomp
      `git init`
      `git remote add origin #{repo}`
      `git pull origin master`
      files = Dir["*"]
      files.delete "CNAME"
      files.each do |f|
        FileUtils.rm_rf f
      end
    end
  end
end

#check_rootObject



7
8
9
10
11
# File 'lib/miyano/cli/push.rb', line 7

def check_root
  unless Dir.exist?("post") and Dir.exist?("layout")
     fail "!!wrong dirctory"
  end
end

#configsObject



3
4
5
# File 'lib/miyano/cli/push.rb', line 3

def configs
  @dir = "_site".freeze
end

#pushObject



37
38
39
40
41
42
43
# File 'lib/miyano/cli/push.rb', line 37

def push
  FileUtils.cd @dir do
    `git add .`
    `git commit -m "site updated at #{Time.now}"`
    `git push -u origin master`
  end
end