Exemplo n.º 1
0
    def run_rubocop(self, view):
        s = sublime.load_settings(SETTINGS_FILE)

        use_rvm = view.settings().get('check_for_rvm', s.get('check_for_rvm'))
        use_rbenv = view.settings().get('check_for_rbenv',
                                        s.get('check_for_rbenv'))
        cmd = view.settings().get('rubocop_command', s.get('rubocop_command'))
        rvm_path = view.settings().get('rvm_auto_ruby_path',
                                       s.get('rvm_auto_ruby_path'))
        rbenv_path = view.settings().get('rbenv_path', s.get('rbenv_path'))
        cfg_file = view.settings().get('rubocop_config_file',
                                       s.get('rubocop_config_file'))
        chdir = view.settings().get('rubocop_chdir', s.get('rubocop_chdir'))

        if cfg_file:
            cfg_file = FileTools.quote(cfg_file)

        runner = RubocopRunner({
            'use_rbenv': use_rbenv,
            'use_rvm': use_rvm,
            'custom_rubocop_cmd': cmd,
            'rvm_auto_ruby_path': rvm_path,
            'rbenv_path': rbenv_path,
            'on_windows': sublime.platform() == 'windows',
            'rubocop_config_file': cfg_file,
            'chdir': chdir,
            'is_st2': sublime.version() < '3000'
        })
        output = runner.run([view.file_name()],
                            ['--format', 'emacs']).splitlines()

        return output
  def run_rubocop(self, view):
    s = sublime.load_settings(SETTINGS_FILE)

    use_rvm = view.settings().get('check_for_rvm', s.get('check_for_rvm'))
    use_rbenv = view.settings().get('check_for_rbenv', s.get('check_for_rbenv'))
    cmd = view.settings().get('rubocop_command', s.get('rubocop_command'))
    rvm_path = view.settings().get('rvm_auto_ruby_path', s.get('rvm_auto_ruby_path'))
    rbenv_path = view.settings().get('rbenv_path', s.get('rbenv_path'))
    cfg_file = view.settings().get('rubocop_config_file', s.get('rubocop_config_file'))
    chdir = view.settings().get('rubocop_chdir', s.get('rubocop_chdir'))

    if cfg_file:
      cfg_file = FileTools.quote(cfg_file)

    runner = RubocopRunner(
      {
        'use_rbenv': use_rbenv,
        'use_rvm': use_rvm,
        'custom_rubocop_cmd': cmd,
        'rvm_auto_ruby_path': rvm_path,
        'rbenv_path': rbenv_path,
        'on_windows': sublime.platform() == 'windows',
        'rubocop_config_file': cfg_file,
        'chdir': chdir,
        'is_st2': sublime.version() < '3000'
      }
    )
    output = runner.run([view.file_name()], ['--format', 'emacs']).splitlines()

    return output
Exemplo n.º 3
0
 def run_rubocop(self, path):
   s = sublime.load_settings(SETTINGS_FILE)
   use_rvm = s.get('check_for_rvm')
   use_rbenv = s.get('check_for_rbenv')
   cmd = s.get('rubocop_command')
   rvm_path = s.get('rvm_auto_ruby_path')
   rbenv_path = s.get('rbenv_path')
   runner = RubocopRunner(use_rbenv, use_rvm, cmd, rvm_path, rbenv_path)
   output = runner.run(path, '--format emacs').splitlines()
   return output
  def load_config(self):
    s = sublime.load_settings(SETTINGS_FILE)
    use_rvm = s.get('check_for_rvm')
    use_rbenv = s.get('check_for_rbenv')
    self.rubocop_command = s.get('rubocop_command')
    rvm_auto_ruby_path = s.get('rvm_auto_ruby_path')
    rbenv_path = s.get('rbenv_path')

    runner = RubocopRunner(use_rbenv, use_rvm, self.rubocop_command, rvm_auto_ruby_path, rbenv_path)
    self.rubocop_command = runner.command_string() + ' {options} {path}'
Exemplo n.º 5
0
  def load_config(self):
    s = sublime.load_settings(SETTINGS_FILE)
    use_rvm = s.get('check_for_rvm')
    use_rbenv = s.get('check_for_rbenv')
    self.rubocop_command = s.get('rubocop_command')
    rvm_auto_ruby_path = s.get('rvm_auto_ruby_path')
    rbenv_path = s.get('rbenv_path')

    self.runner = RubocopRunner(use_rbenv, use_rvm, self.rubocop_command, rvm_auto_ruby_path, rbenv_path)
    self.rubocop_command = self.runner.command_string() + ' {options} {path}'
Exemplo n.º 6
0
 def load_config(self):
   s = sublime.load_settings(SETTINGS_FILE)
   cfg_file = s.get('rubocop_config_file')
   if cfg_file:
     cfg_file = FileTools.quote(cfg_file)
   self.runner = RubocopRunner(
     {
       'use_rbenv': s.get('check_for_rbenv'),
       'use_rvm': s.get('check_for_rvm'),
       'custom_rubocop_cmd': s.get('rubocop_command'),
       'rvm_auto_ruby_path': s.get('rvm_auto_ruby_path'),
       'rbenv_path': s.get('rbenv_path'),
       'on_windows': self.on_windows(),
       'rubocop_config_file': cfg_file,
       'is_st2': self.is_st2()
     }
   )
Exemplo n.º 7
0
class RubocopCommand(sublime_plugin.TextCommand):
  def run(self, edit):
    self.load_config()

  def load_config(self):
    s = sublime.load_settings(SETTINGS_FILE)
    cfg_file = s.get('rubocop_config_file')
    if cfg_file:
      cfg_file = FileTools.quote(cfg_file)
    self.runner = RubocopRunner(
      {
        'use_rbenv': s.get('check_for_rbenv'),
        'use_rvm': s.get('check_for_rvm'),
        'custom_rubocop_cmd': s.get('rubocop_command'),
        'rvm_auto_ruby_path': s.get('rvm_auto_ruby_path'),
        'rbenv_path': s.get('rbenv_path'),
        'on_windows': (sublime.platform() == 'windows'),
        'rubocop_config_file': cfg_file
      }
    )

  def used_options(self):
    return ''

  def run_rubocop_on(self, path, file_list=False):
    if not path:
      return

    if not file_list:
      # Single item to check.
      quoted_file_path = FileTools.quote(path)
      working_dir = os.path.dirname(path)
    else:
      # Multiple files to check.
      working_dir = '.'
      quoted_file_path = ''
      for file in path:
        quoted_file_path += FileTools.quote(file) + ' '

    rubocop_cmd = self.runner.command_string(
      quoted_file_path, self.used_options()
    )
    self.run_shell_command(rubocop_cmd, working_dir)

  def run_shell_command(self, command, working_dir='.'):
    if not command:
      return

    self.view.window().run_command('exec', {
      'cmd': [command],
      'shell': True,
      'working_dir': working_dir,
      'file_regex': r"^([^:]+):([0-9]*)",
    })
Exemplo n.º 8
0
class RubocopCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.load_config()

    def load_config(self):
        s = sublime.load_settings(SETTINGS_FILE)
        use_rvm = s.get('check_for_rvm')
        use_rbenv = s.get('check_for_rbenv')
        self.rubocop_command = s.get('rubocop_command')
        rvm_auto_ruby_path = s.get('rvm_auto_ruby_path')
        rbenv_path = s.get('rbenv_path')

        self.runner = RubocopRunner(use_rbenv, use_rvm, self.rubocop_command,
                                    rvm_auto_ruby_path, rbenv_path)
        self.rubocop_command = self.runner.command_string(
        ) + ' {options} {path}'

    def used_options(self):
        return ''

    def command_with_options(self):
        return self.rubocop_command.replace('{options}', self.used_options())

    def run_rubocop_on(self, path, file_list=False):
        if not path:
            return

        if not file_list:
            # Single item to check.
            quoted_file_path = FileTools.quote(path)
            working_dir = os.path.dirname(quoted_file_path)
        else:
            # Multiple files to check.
            working_dir = '.'
            quoted_file_path = ''
            for file in path:
                quoted_file_path += FileTools.quote(file) + ' '

        cop_command = self.command_with_options()
        rubocop_cmd = cop_command.replace('{path}', quoted_file_path)

        self.run_shell_command(rubocop_cmd, working_dir)

    def run_shell_command(self, command, working_dir='.'):
        if not command:
            return

        self.view.window().run_command(
            'exec', {
                'cmd': [command],
                'shell': True,
                'working_dir': working_dir,
                'file_regex': r"^([^:]+):([0-9]*)",
            })
Exemplo n.º 9
0
class RubocopCommand(sublime_plugin.TextCommand):
  def run(self, edit):
    self.load_config()

  def load_config(self):
    s = sublime.load_settings(SETTINGS_FILE)
    use_rvm = s.get('check_for_rvm')
    use_rbenv = s.get('check_for_rbenv')
    self.rubocop_command = s.get('rubocop_command')
    rvm_auto_ruby_path = s.get('rvm_auto_ruby_path')
    rbenv_path = s.get('rbenv_path')

    self.runner = RubocopRunner(use_rbenv, use_rvm, self.rubocop_command, rvm_auto_ruby_path, rbenv_path)
    self.rubocop_command = self.runner.command_string() + ' {options} {path}'

  def used_options(self):
    return ''

  def command_with_options(self):
    return self.rubocop_command.replace('{options}', self.used_options())

  def run_rubocop_on(self, path, file_list=False):
    if not path:
      return

    if not file_list:
      # Single item to check.
      quoted_file_path = FileTools.quote(path)
      working_dir = os.path.dirname(quoted_file_path)
    else:
      # Multiple files to check.
      working_dir = '.'
      quoted_file_path = ''
      for file in path:
        quoted_file_path += FileTools.quote(file) + ' '

    cop_command = self.command_with_options()
    rubocop_cmd = cop_command.replace('{path}', quoted_file_path)

    self.run_shell_command(rubocop_cmd, working_dir)

  def run_shell_command(self, command, working_dir='.'):
    if not command:
      return

    self.view.window().run_command('exec', {
      'cmd': [command],
      'shell': True,
      'working_dir': working_dir,
      'file_regex': r"^([^:]+):([0-9]*)",
    })
Exemplo n.º 10
0
 def run_rubocop(self, path):
   s = sublime.load_settings(SETTINGS_FILE)
   use_rvm = s.get('check_for_rvm')
   use_rbenv = s.get('check_for_rbenv')
   cmd = s.get('rubocop_command')
   rvm_path = s.get('rvm_auto_ruby_path')
   rbenv_path = s.get('rbenv_path')
   cfg_file = s.get('rubocop_config_file')
   if cfg_file:
     cfg_file = FileTools.quote(cfg_file)
   runner = RubocopRunner(
     {
       'use_rbenv': use_rbenv,
       'use_rvm': use_rvm,
       'custom_rubocop_cmd': cmd,
       'rvm_auto_ruby_path': rvm_path,
       'rbenv_path': rbenv_path,
       'on_windows': sublime.platform() == 'windows',
       'rubocop_config_file': cfg_file
     }
   )
   output = runner.run(path, '--format emacs').splitlines()
   return output
Exemplo n.º 11
0
 def load_config(self):
   s = sublime.load_settings(SETTINGS_FILE)
   cfg_file = s.get('rubocop_config_file')
   if cfg_file:
     cfg_file = FileTools.quote(cfg_file)
   self.runner = RubocopRunner(
     {
       'use_rbenv': s.get('check_for_rbenv'),
       'use_rvm': s.get('check_for_rvm'),
       'custom_rubocop_cmd': s.get('rubocop_command'),
       'rvm_auto_ruby_path': s.get('rvm_auto_ruby_path'),
       'rbenv_path': s.get('rbenv_path'),
       'on_windows': (sublime.platform() == 'windows'),
       'rubocop_config_file': cfg_file
     }
   )
Exemplo n.º 12
0
 def load_config(self):
     s = sublime.load_settings(SETTINGS_FILE)
     cfg_file = s.get("rubocop_config_file")
     if cfg_file:
         cfg_file = FileTools.quote(cfg_file)
     self.runner = RubocopRunner(
         {
             "use_rbenv": s.get("check_for_rbenv"),
             "use_rvm": s.get("check_for_rvm"),
             "custom_rubocop_cmd": s.get("rubocop_command"),
             "rvm_auto_ruby_path": s.get("rvm_auto_ruby_path"),
             "rbenv_path": s.get("rbenv_path"),
             "on_windows": self.on_windows(),
             "rubocop_config_file": cfg_file,
             "is_st2": self.is_st2(),
         }
     )
class RubocopCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.load_config()

    def load_config(self):
        s = sublime.load_settings(SETTINGS_FILE)
        cfg_file = s.get('rubocop_config_file')
        if cfg_file:
            cfg_file = FileTools.quote(cfg_file)
        self.runner = RubocopRunner({
            'use_rbenv':
            s.get('check_for_rbenv'),
            'use_rvm':
            s.get('check_for_rvm'),
            'custom_rubocop_cmd':
            s.get('rubocop_command'),
            'rvm_auto_ruby_path':
            s.get('rvm_auto_ruby_path'),
            'rbenv_path':
            s.get('rbenv_path'),
            'on_windows':
            self.on_windows(),
            'rubocop_config_file':
            cfg_file,
            'is_st2':
            self.is_st2()
        })

    def on_windows(self):
        return sublime.platform() == 'windows'

    def is_st2(self):
        return int(sublime.version()) < 3000

    def is_st3(self):
        return int(sublime.version()) >= 3000

    def used_options(self):
        return []

    def current_project_folder(self):
        if self.is_st3():
            project = sublime.active_window().project_data()
            project_base_path = os.path.dirname(
                sublime.active_window().project_file_name() or '')
            if not (project is None):
                if 'folders' in project:
                    folders = project['folders']
                    if len(folders) > 0:
                        first_folder = folders[0]
                        if 'path' in first_folder:
                            path = first_folder['path']
                            return (path
                                    if os.path.isabs(path) else os.path.join(
                                        project_base_path, path)) or ''
        else:
            folders = sublime.active_window().folders()
            if (not (folders is None)) and (len(folders) > 0):
                return folders[0]
        return ''

    def run_rubocop_on(self, pathlist):
        if len(pathlist) == 0:
            return

        working_dir = self.current_project_folder()

        quoted_paths = []
        for path in pathlist:
            quoted_paths.append(FileTools.quote(path))

        rubocop_cmd = self.runner.command_string(quoted_paths,
                                                 self.used_options())

        self.run_shell_command(rubocop_cmd, working_dir)

    def run_shell_command(self, command, working_dir):
        self.view.window().run_command(
            'exec', {
                'cmd': command,
                'shell': True,
                'working_dir': working_dir,
                'file_regex': r"^(.*):(\d*):(\d*): (.: .*$)"
            })
Exemplo n.º 14
0
class RubocopCommand(sublime_plugin.TextCommand):
  def run(self, edit):
    self.load_config()

  def load_config(self):
    s = sublime.load_settings(SETTINGS_FILE)
    cfg_file = s.get('rubocop_config_file')
    if cfg_file:
      cfg_file = FileTools.quote(cfg_file)
    self.runner = RubocopRunner(
      {
        'use_rbenv': s.get('check_for_rbenv'),
        'use_rvm': s.get('check_for_rvm'),
        'custom_rubocop_cmd': s.get('rubocop_command'),
        'rvm_auto_ruby_path': s.get('rvm_auto_ruby_path'),
        'rbenv_path': s.get('rbenv_path'),
        'on_windows': self.on_windows(),
        'rubocop_config_file': cfg_file,
        'is_st2': self.is_st2()
      }
    )

  def on_windows(self):
    return sublime.platform() == 'windows'

  def is_st2(self):
    return int(sublime.version()) < 3000

  def is_st3(self):
    return int(sublime.version()) >= 3000

  def used_options(self):
    return []

  def current_project_folder(self):
    if self.is_st3():
      project = sublime.active_window().project_data()
      project_base_path = os.path.dirname(sublime.active_window().project_file_name() or '')
      if not (project is None):
        if 'folders' in project:
          folders = project['folders']
          if len(folders) > 0:
            first_folder = folders[0]
            if 'path' in first_folder:
              path = first_folder['path']
              return (path if os.path.isabs(path) else os.path.join(project_base_path, path)) or ''
    else:
      folders = sublime.active_window().folders()
      if (not (folders is None)) and (len(folders) > 0):
        return folders[0]
    return ''

  def run_rubocop_on(self, pathlist):
    if len(pathlist) == 0:
      return

    working_dir = self.current_project_folder()

    quoted_paths = []
    for path in pathlist:
      quoted_paths.append(FileTools.quote(path))

    rubocop_cmd = self.runner.command_string(
      quoted_paths,
      self.used_options()
    )

    self.run_shell_command(rubocop_cmd, working_dir)

  def run_shell_command(self, command, working_dir):
    self.view.window().run_command('exec', {
      'cmd': command,
      'shell': True,
      'working_dir': working_dir,
      'file_regex': r"^(.*):(\d*):(\d*): (.: .*$)"
    })
Exemplo n.º 15
0
class RubocopCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.load_config()

    def load_config(self):
        s = sublime.load_settings(SETTINGS_FILE)
        cfg_file = s.get("rubocop_config_file")
        if cfg_file:
            cfg_file = FileTools.quote(cfg_file)
        self.runner = RubocopRunner(
            {
                "use_rbenv": s.get("check_for_rbenv"),
                "use_rvm": s.get("check_for_rvm"),
                "custom_rubocop_cmd": s.get("rubocop_command"),
                "rvm_auto_ruby_path": s.get("rvm_auto_ruby_path"),
                "rbenv_path": s.get("rbenv_path"),
                "on_windows": self.on_windows(),
                "rubocop_config_file": cfg_file,
                "is_st2": self.is_st2(),
            }
        )

    def on_windows(self):
        return sublime.platform() == "windows"

    def is_st2(self):
        return int(sublime.version()) < 3000

    def is_st3(self):
        return int(sublime.version()) >= 3000

    def used_options(self):
        return []

    def current_project_folder(self):
        if self.is_st3():
            project = sublime.active_window().project_data()
            if not (project is None):
                if "folders" in project:
                    folders = project["folders"]
                    if len(folders) > 0:
                        first_folder = folders[0]
                        if "path" in first_folder:
                            return first_folder["path"] or ""
        else:
            folders = sublime.active_window().folders()
            if (not (folders is None)) and (len(folders) > 0):
                return folders[0]
        return ""

    def run_rubocop_on(self, pathlist):
        if len(pathlist) == 0:
            return

        working_dir = self.current_project_folder()

        quoted_paths = []
        for path in pathlist:
            quoted_paths.append(FileTools.quote(path))

        rubocop_cmd = self.runner.command_string(quoted_paths, self.used_options())

        self.run_shell_command(rubocop_cmd, working_dir)

    def run_shell_command(self, command, working_dir):
        self.view.window().run_command(
            "exec",
            {"cmd": command, "shell": True, "working_dir": working_dir, "file_regex": r"^(.*):(\d*):\d*: .: .*$"},
        )