Class: Git2Mite::App
- Inherits:
-
Object
- Object
- Git2Mite::App
- Defined in:
- lib/git2mite/app.rb
Instance Method Summary collapse
- #check_if_git_repo! ⇒ Object
- #check_ruby_version! ⇒ Object
- #configuration ⇒ Object
- #get_api_key ⇒ Object
- #get_sub_domain ⇒ Object
-
#initialize ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
Instance Method Details
#check_if_git_repo! ⇒ Object
15 16 17 |
# File 'lib/git2mite/app.rb', line 15 def check_if_git_repo! @gui.error "Please change to a directory that is a git repository." unless @repo.is_git_repo? end |
#check_ruby_version! ⇒ Object
19 20 21 |
# File 'lib/git2mite/app.rb', line 19 def check_ruby_version! @gui.error "Sorry you need Ruby 1.8.7+ for this." if RUBY_VERSION < '1.8.7' end |
#configuration ⇒ Object
3 4 5 |
# File 'lib/git2mite/app.rb', line 3 def configuration @configuration ||= Git2Mite::Configuration.new end |
#get_api_key ⇒ Object
7 8 9 |
# File 'lib/git2mite/app.rb', line 7 def get_api_key configuration.api_key ||= @gui.ask('What is your api key?').strip end |
#get_sub_domain ⇒ Object
11 12 13 |
# File 'lib/git2mite/app.rb', line 11 def get_sub_domain configuration.sub_domain ||= @gui.ask('What is your account subdomain?').strip end |
#run ⇒ Object
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 |
# File 'lib/git2mite/app.rb', line 29 def run @gui.print_welcome check_if_git_repo! check_ruby_version! client = MiteClient.new("http://#{get_sub_domain}.mite.yo.lk", get_api_key) project_id = @gui.get_project_id(client.projects) user_id = @gui.get_user_id(User.all(client)) start_date = @gui.get_date('start date') end_date = @gui.get_date('end date') commits = @repo.commits start_date, end_date = @gui. commits.map{|date, , | }.uniq puts puts 'Writing commits to mite' commits.each do |date, , | next unless == entries = client.time_entries project_id, user_id, date if entries.empty? STDERR.puts "WARN no time entries for commit #{date.to_s}: #{}" else entry = entries[rand(entries.size)]['time_entry'] client. entry, print "." end end puts 'done' end |