Class: Avm::EacRedminePluginBase0::Sources::Base

Inherits:
Avm::EacRubyBase1::Sources::Base
  • Object
show all
Defined in:
lib/avm/eac_redmine_plugin_base0/sources/base.rb

Constant Summary collapse

DEFAULT_GEMFILE_PATH =
'SelfGemfile'
RUBOCOP_GEM_NAME =
'rubocop'
RUBOCOP_TEST_NAME =
'rubocop'
PARENT_RAKE_TASK_TEST_NAME =
'parent_rake_task'
INIT_SUBPATH =
'init.rb'

Instance Method Summary collapse

Instance Method Details

#default_gemfile_pathString

Returns:

  • (String)


17
18
19
# File 'lib/avm/eac_redmine_plugin_base0/sources/base.rb', line 17

def default_gemfile_path
  DEFAULT_GEMFILE_PATH
end

#default_test_commandsHash<String, EacRubyUtils::Envs::Command>

Returns:

  • (Hash<String, EacRubyUtils::Envs::Command>)


22
23
24
25
26
27
# File 'lib/avm/eac_redmine_plugin_base0/sources/base.rb', line 22

def default_test_commands
  r = {}
  r[PARENT_RAKE_TASK_TEST_NAME] = parent_rake_test_command if parent_rake_test_command?
  r[RUBOCOP_TEST_NAME] = rubocop_test_command if rubocop_test_command?
  r
end

#init_pathString

Returns:

  • (String)


30
31
32
# File 'lib/avm/eac_redmine_plugin_base0/sources/base.rb', line 30

def init_path
  path.join(INIT_SUBPATH)
end

#parent_rake_test_commandEacRubyUtils::Envs::Command

Returns:

  • (EacRubyUtils::Envs::Command)


45
46
47
# File 'lib/avm/eac_redmine_plugin_base0/sources/base.rb', line 45

def parent_rake_test_command
  ruby_parent.rake(parent_rake_test_task_name).chdir_root.envvar('RAILS_ENV', 'test')
end

#parent_rake_test_command?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/avm/eac_redmine_plugin_base0/sources/base.rb', line 40

def parent_rake_test_command?
  ruby_parent.rake_task?(parent_rake_test_task_name)
end

#parent_rake_test_task_nameString

Returns:

  • (String)


35
36
37
# File 'lib/avm/eac_redmine_plugin_base0/sources/base.rb', line 35

def parent_rake_test_task_name
  [gem_name, 'test'].map(&:variableize).join(':')
end

#rubocop_test_commandEacRubyUtils::Envs::Command

Returns:

  • (EacRubyUtils::Envs::Command)


50
51
52
53
54
# File 'lib/avm/eac_redmine_plugin_base0/sources/base.rb', line 50

def rubocop_test_command
  bundle('exec', 'rubocop', '--ignore-parent-exclusion')
    .envvar('RAILS_ENV', 'test')
    .chdir_root
end

#rubocop_test_command?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/avm/eac_redmine_plugin_base0/sources/base.rb', line 57

def rubocop_test_command?
  gemfile_path.exist? && gemfile_lock_gem_version(RUBOCOP_GEM_NAME).present?
end

#valid?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/avm/eac_redmine_plugin_base0/sources/base.rb', line 62

def valid?
  init_path.exist?
end