lib/jekyll_push/branch.rb in jekyll_push-0.1.0 vs lib/jekyll_push/branch.rb in jekyll_push-0.1.1

- old
+ new

@@ -4,12 +4,11 @@ # # class Branch attr_reader :target - # @param target [String] the name of the Git branch to deploy to - # @param time [String] message with the time of deployment + # @param target [String] the name of the Git branch to deploy to def initialize(target) @target = JekyllPush::Utils.slugify target @time = Time.now.strftime('%H:%M on %Y-%m-%d') (class << self; include JekyllPush::Travis; end) if on_travis? @@ -21,29 +20,29 @@ raise JekyllPush::Error::NoOrigin, 'No remote origin was found for the project GitHub repository.' if @origin.empty? end # - # + # @return [Boolean] def on_travis? !!ENV.fetch('CI', false) end # - # + # @return [Boolean] def local? !on_travis? end # - # + # @return [Array] def git_commands ['git init && git add .', "git commit -m '#{@commit}'", "git remote add origin #{@origin}", "git push origin master:refs/heads/#{@target} --force"] end # - # + # @return [Nil] def push(dir) files = Dir.glob "#{dir}/**/*" raise JekyllPush::Error::NoFilesBuilt, "Found no files inside site directory '#{dir}' to push." if files.empty? puts Rainbow("\nFound the following _site files:").cyan @@ -55,16 +54,16 @@ git_commands.each { |cmd| system_try cmd } end # - # + # @return [Nil] def pretty_list(items) items.each { |i| puts "\t+ #{i.strip}" } end # - # + # @return [Nil] def system_try(command) puts Rainbow("\nTrying `#{command}`").cyan success = system command return if success