Sha256: cd48832414e90098f87592876e56a2512998ec369ad16a6a0952d14fe71e59e2

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

module Timber
  class CLI
    module OSHelper
      def self.copy_to_clipboard?
        `which pbcopy` != ""
      rescue Exception
        false
      end

      def self.copy_to_clipboard(input)
        ::IO.popen('pbcopy', 'w') { |f| f << input }
        true
      rescue Exception
        false
      end

      def self.git_commit_changes
        begin
          `git add config/initializers/timber.rb`
        rescue Exception
        end

        `git commit -am 'Install the timber logger'`
        true
      rescue Exception
        false
      end

      def self.has_git?
        begin
          `which git` != ""
        rescue Exception
          false
        end
      end

      # Attemps to open a URL in the user's default browser across
      # the popular operating systems.
      def self.open(link)
        if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
          system "start #{link}"
        elsif RbConfig::CONFIG['host_os'] =~ /darwin/
          system "open #{link}"
        elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
          system "xdg-open #{link}"
        end
        true
      rescue Exception
        false
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
timber-2.1.0.rc2 lib/timber/cli/os_helper.rb
timber-2.1.0.rc1 lib/timber/cli/os_helper.rb