Class: ProjectUtility

Inherits:
Object
  • Object
show all
Includes:
CLIHelper, FilesHelper, RegExpHelper
Defined in:
lib/joe_utils/utils/project_utility.rb

Constant Summary collapse

HELP_TEXT =
'Project utility:
executes basic administrative tasks with project, so far supported options:
s for skipping tests,
g for pushing to github,
e for pushing to heroku,
b for building a gem, notice, you need to be in the folder which is called as the .gemspec file of the gem,
p for pushing it to rubygems.org,
i for installing it locally,
h for help,
you can combine the options when it makes sense.
Text behind the command will be considered a message for git.'

Constants included from RegExpHelper

RegExpHelper::CLI_MESSAGE_INPUT, RegExpHelper::NO_SUCCESS

Constants included from CLIHelper

CLIHelper::MESSAGES

Instance Method Summary collapse

Methods included from FilesHelper

#add_to_open_zip, #catch_errno_enoent, #create_dir, #create_file, #create_file_by_template, #dir_exists?, #edit_file, #file_exists?, #find_in_all, #for_all_in_dir, #get_current_address, #get_current_folder, #load_file_text, #remove_dir, #replace_in_all, #unzip, #zip, #zip_folder

Methods included from CLIHelper

#build_gem, #commit_git, #commit_github, #deploy_heroku, #execute, #install_gem, #install_jgem, #push_rubygems, #rake_test

Instance Method Details

#process_input(input, options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/joe_utils/utils/project_utility.rb', line 21

def process_input(input, options = {})
  input.each do |arg|
    if arg[0..1] == '--'
      case arg[2..-1]
        when 'build'
          options[:gem_name] ||= get_current_folder
        when 'install'
          options[:install] = true
        when 'push'
          options[:push] = true
        when 'heroku'
          options[:heroku] = true
        when 'github'
          options[:github] = true
        else
          puts HELP_TEXT
          exit
      end
    elsif arg[0] == '-'
      arg[1..-1].each_char do |letter|
        case letter
          when 's'
            options[:skip_tests] = true
          when 'g'
            options[:github] = true
          when 'e'
            options[:heroku] = true
          when 'b'
            options[:gem_name] ||= get_current_folder
          when 'i'
            options[:install] = true
            options[:gem_name] ||= get_current_folder
          when 'p'
            options[:push] = true
            options[:gem_name] ||= get_current_folder
          else
            puts HELP_TEXT
            exit
        end
      end
    else
      options[:message] = arg
    end
  end
  options
end

#run(input = nil) ⇒ Object



68
69
70
71
72
73
74
75
76
77
# File 'lib/joe_utils/utils/project_utility.rb', line 68

def run(input = nil)
  options = process_input(input || ARGV)
  success = true
  success = rake_test unless options[:skip_tests]
  success &&= commit_git(options[:message])
  success &&= commit_github if options[:github]
  success &&= deploy_heroku if options[:heroku]
  success &&= build_gem(options[:gem_name], options) if options[:gem_name]
  success
end