fire_watch 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/fire_watch-0.1.0.gem +0 -0
- data/lib/fire_watch/runner.rb +97 -86
- data/lib/fire_watch/version.rb +1 -1
- metadata +2 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1fc4bf1112190b8cf13ac8fd1f19f02d7cfdba58
         | 
| 4 | 
            +
              data.tar.gz: d59a610ffec4d26386657d512525b658bb81b354
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 75bfe76cf818d83c3de36df1398bdd828ccd4429573c1017ba6a4701a9a1ee5f4190fb0ea97171706e440fa36fba7c58056a69b1b25efd9a59e5ddaf3135670c
         | 
| 7 | 
            +
              data.tar.gz: ff9b43e8f72f39c407f8ff7c75abe6cf336997a989cd9c87870102a5afc45c91a5d7bfc1db179a22ada41a85834111aaac392d5fec0262d330f77391eeb24aef
         | 
| Binary file | 
    
        data/lib/fire_watch/runner.rb
    CHANGED
    
    | @@ -9,8 +9,8 @@ module FireWatch | |
| 9 9 |  | 
| 10 10 | 
             
                    cli = HighLine.new
         | 
| 11 11 | 
             
                    # Github Client
         | 
| 12 | 
            -
                    github_login = cli.ask('Github Login: ')
         | 
| 13 | 
            -
                    github_password = cli.ask('Github Password: ') { |q| q.echo = false }
         | 
| 12 | 
            +
                    github_login = "joew@samjoe.com"# cli.ask('Github Login: ')
         | 
| 13 | 
            +
                    github_password = "VPcYdAk9PFx3^uPn" # cli.ask('Github Password: ') { |q| q.echo = false }
         | 
| 14 14 | 
             
                    @github_client = Github.new(auto_pagination: true) do |config|
         | 
| 15 15 | 
             
                      config.basic_auth         = "#{github_login}:#{github_password}"
         | 
| 16 16 | 
             
                      if cli.agree("Do you use Two-Factor authentication (non-sms)?")
         | 
| @@ -30,25 +30,28 @@ module FireWatch | |
| 30 30 | 
             
                    end
         | 
| 31 31 |  | 
| 32 32 | 
             
                    milestones = @github_client.issues.milestones.list(user: 'wildland',repo: selected_repo.name, state: 'all').sort_by{|m| m.title}
         | 
| 33 | 
            -
                     | 
| 34 | 
            -
                     | 
| 35 | 
            -
             | 
| 36 | 
            -
                       | 
| 37 | 
            -
                        menu. | 
| 38 | 
            -
             | 
| 33 | 
            +
                    selected_milestones = []
         | 
| 34 | 
            +
                    done = false
         | 
| 35 | 
            +
                    loop do
         | 
| 36 | 
            +
                      cli.choose do |menu|
         | 
| 37 | 
            +
                        menu.prompt = "Add/Remove Milestones (#{selected_milestones.map{|p| p.title}.join(', ')}): "
         | 
| 38 | 
            +
                        milestones.each do |m|
         | 
| 39 | 
            +
                          menu.choice(m.title) do
         | 
| 40 | 
            +
                            if selected_milestones.include? m
         | 
| 41 | 
            +
                              selected_milestones.delete(m)
         | 
| 42 | 
            +
                            else 
         | 
| 43 | 
            +
                              selected_milestones.push(m)
         | 
| 44 | 
            +
                            end
         | 
| 45 | 
            +
                          end
         | 
| 39 46 | 
             
                        end
         | 
| 47 | 
            +
                        menu.choice("Done Adding Milestones") { done = true }
         | 
| 40 48 | 
             
                      end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
                    issues, pull_request_issues = @github_client.issues.list(user: 'wildland', repo: selected_repo.name, milestone: selected_milestone.number, state: 'all').partition{|i| i.pull_request == nil}
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                    pull_requests = pull_request_issues.map do |i|
         | 
| 46 | 
            -
                      @github_client.pull_requests.get(user: 'wildland', repo: selected_repo.name, number: i.number).body
         | 
| 49 | 
            +
                      break if done
         | 
| 47 50 | 
             
                    end
         | 
| 48 51 |  | 
| 49 52 | 
             
                    # Harvest Client
         | 
| 50 | 
            -
                    harvest_username = cli.ask('Harvest Username: ')
         | 
| 51 | 
            -
                    harvest_password = cli.ask('Harvest Password: ') { |q| q.echo = false }
         | 
| 53 | 
            +
                    harvest_username = "joe@wild.land" #cli.ask('Harvest Username: ')
         | 
| 54 | 
            +
                    harvest_password = "]ztJyVszDnI{96uB" #cli.ask('Harvest Password: ') { |q| q.echo = false }
         | 
| 52 55 | 
             
                    @harvest_client = Harvest.client(username: harvest_username, password: harvest_password, subdomain: 'wildland')
         | 
| 53 56 |  | 
| 54 57 | 
             
                    projects = @harvest_client.projects.all.sort_by{|p| p.name}
         | 
| @@ -105,89 +108,97 @@ module FireWatch | |
| 105 108 | 
             
                        "Labels"
         | 
| 106 109 | 
             
                      ]
         | 
| 107 110 |  | 
| 108 | 
            -
                       | 
| 109 | 
            -
                         | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
                          else
         | 
| 114 | 
            -
                            match_data["issue_number"].eql? issue.number.to_s
         | 
| 115 | 
            -
                          end
         | 
| 111 | 
            +
                      selected_milestones.each do |selected_milestone|
         | 
| 112 | 
            +
                        issues, pull_request_issues = @github_client.issues.list(user: 'wildland', repo: selected_repo.name, milestone: selected_milestone.number, state: 'all').partition{|i| i.pull_request == nil}
         | 
| 113 | 
            +
             | 
| 114 | 
            +
                        pull_requests = pull_request_issues.map do |i|
         | 
| 115 | 
            +
                          @github_client.pull_requests.get(user: 'wildland', repo: selected_repo.name, number: i.number).body
         | 
| 116 116 | 
             
                        end
         | 
| 117 117 |  | 
| 118 | 
            -
                         | 
| 119 | 
            -
             | 
| 120 | 
            -
             | 
| 121 | 
            -
             | 
| 122 | 
            -
                               | 
| 123 | 
            -
             | 
| 124 | 
            -
                              "" | 
| 125 | 
            -
             | 
| 126 | 
            -
                              issue.labels.nil? || issue.labels.find{|l| l.name.include?"size:"}.nil? ? "" : issue.labels.find{|l| l.name.include?"size:"}.name, 
         | 
| 127 | 
            -
                              "",
         | 
| 128 | 
            -
                              issue.state, 
         | 
| 129 | 
            -
                              "",
         | 
| 130 | 
            -
                              issue.labels.nil? ? "" : issue.labels.compact.map{|l| l.name}.join(', ')
         | 
| 131 | 
            -
                            ]
         | 
| 132 | 
            -
                        else 
         | 
| 133 | 
            -
                          relevant_time_entries.chunk{|i| i.user_id }.each do |user_id, user_time_entries|
         | 
| 134 | 
            -
                            user = harvest_users.find{|u| u.id == user_id}
         | 
| 135 | 
            -
                            csv << [
         | 
| 136 | 
            -
                              selected_repo.name, 
         | 
| 137 | 
            -
                              selected_milestone.title, 
         | 
| 138 | 
            -
                              issue.number, 
         | 
| 139 | 
            -
                              issue.title, 
         | 
| 140 | 
            -
                              projects.select{|p| user_time_entries.map(&:project_id).uniq.include? p.id}.map(&:name).join(', '),
         | 
| 141 | 
            -
                              "#{user.first_name} #{user.last_name}", # Who
         | 
| 142 | 
            -
                              issue.labels.nil? ? "" : issue.labels.find{|l| l.name.include?"size:"}.name, 
         | 
| 143 | 
            -
                              user_time_entries.inject(0){|sum, e| sum + e.hours },
         | 
| 144 | 
            -
                              issue.state, 
         | 
| 145 | 
            -
                              "",
         | 
| 146 | 
            -
                              issue.labels.nil? ? "" : issue.labels.map{|l| l.name}.join(', ')
         | 
| 147 | 
            -
                            ]
         | 
| 118 | 
            +
                        issues.each do |issue|
         | 
| 119 | 
            +
                          relevant_time_entries, time_entries  = time_entries.partition do |entry|
         | 
| 120 | 
            +
                            match_data = /.?#(?<issue_number>\d+)/.match(entry.notes)
         | 
| 121 | 
            +
                            if match_data.nil?
         | 
| 122 | 
            +
                              false
         | 
| 123 | 
            +
                            else
         | 
| 124 | 
            +
                              match_data["issue_number"].eql? issue.number.to_s
         | 
| 125 | 
            +
                            end
         | 
| 148 126 | 
             
                          end
         | 
| 149 | 
            -
                        end
         | 
| 150 | 
            -
                      end
         | 
| 151 127 |  | 
| 152 | 
            -
             | 
| 153 | 
            -
             | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 128 | 
            +
                          if relevant_time_entries.empty?
         | 
| 129 | 
            +
                             csv << [
         | 
| 130 | 
            +
                                selected_repo.name, 
         | 
| 131 | 
            +
                                selected_milestone.title, 
         | 
| 132 | 
            +
                                issue.number, 
         | 
| 133 | 
            +
                                issue.title, 
         | 
| 134 | 
            +
                                "",
         | 
| 135 | 
            +
                                "",
         | 
| 136 | 
            +
                                issue.labels.nil? || issue.labels.find{|l| l.name.include?"size:"}.nil? ? "" : issue.labels.find{|l| l.name.include?"size:"}.name, 
         | 
| 137 | 
            +
                                "",
         | 
| 138 | 
            +
                                issue.state, 
         | 
| 139 | 
            +
                                "",
         | 
| 140 | 
            +
                                issue.labels.nil? ? "" : issue.labels.compact.map{|l| l.name}.join(', ')
         | 
| 141 | 
            +
                              ]
         | 
| 142 | 
            +
                          else 
         | 
| 143 | 
            +
                            relevant_time_entries.chunk{|i| i.user_id }.each do |user_id, user_time_entries|
         | 
| 144 | 
            +
                              user = harvest_users.find{|u| u.id == user_id}
         | 
| 145 | 
            +
                              csv << [
         | 
| 146 | 
            +
                                selected_repo.name, 
         | 
| 147 | 
            +
                                selected_milestone.title, 
         | 
| 148 | 
            +
                                issue.number, 
         | 
| 149 | 
            +
                                issue.title, 
         | 
| 150 | 
            +
                                projects.select{|p| user_time_entries.map(&:project_id).uniq.include? p.id}.map(&:name).join(', '),
         | 
| 151 | 
            +
                                "#{user.first_name} #{user.last_name}", # Who
         | 
| 152 | 
            +
                                issue.labels.nil? ? "" : issue.labels.find{|l| l.name.include?"size:"}.name, 
         | 
| 153 | 
            +
                                user_time_entries.inject(0){|sum, e| sum + e.hours },
         | 
| 154 | 
            +
                                issue.state, 
         | 
| 155 | 
            +
                                "",
         | 
| 156 | 
            +
                                issue.labels.nil? ? "" : issue.labels.map{|l| l.name}.join(', ')
         | 
| 157 | 
            +
                              ]
         | 
| 158 | 
            +
                            end
         | 
| 159 159 | 
             
                          end
         | 
| 160 160 | 
             
                        end
         | 
| 161 | 
            -
             | 
| 162 | 
            -
             | 
| 163 | 
            -
             | 
| 164 | 
            -
                             | 
| 165 | 
            -
                             | 
| 166 | 
            -
             | 
| 167 | 
            -
                             | 
| 168 | 
            -
             | 
| 169 | 
            -
                             | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
                            pr.labels.nil? ? "" : pr.labels.map{|l| l.name}.join(', ')
         | 
| 174 | 
            -
                          ]
         | 
| 175 | 
            -
                        else 
         | 
| 176 | 
            -
                          relevant_time_entries.chunk{|i| i.user_id }.each do |user_id, user_time_entries|
         | 
| 177 | 
            -
                            user = harvest_users.find{|u| u.id == user_id}
         | 
| 178 | 
            -
                            csv << [
         | 
| 161 | 
            +
             | 
| 162 | 
            +
                        pull_requests.each do |pr|
         | 
| 163 | 
            +
                          relevant_time_entries, time_entries  = time_entries.partition do |entry|
         | 
| 164 | 
            +
                            match_data = /.?#(?<issue_number>\d+)/.match(entry.notes)
         | 
| 165 | 
            +
                            if match_data.nil?
         | 
| 166 | 
            +
                              false
         | 
| 167 | 
            +
                            else
         | 
| 168 | 
            +
                              match_data["issue_number"].eql? pr.number.to_s
         | 
| 169 | 
            +
                            end
         | 
| 170 | 
            +
                          end
         | 
| 171 | 
            +
                          if relevant_time_entries.empty?
         | 
| 172 | 
            +
                             csv << [
         | 
| 179 173 | 
             
                              selected_repo.name, 
         | 
| 180 174 | 
             
                              selected_milestone.title, 
         | 
| 181 175 | 
             
                              pr.number, 
         | 
| 182 176 | 
             
                              pr.title, 
         | 
| 183 | 
            -
                               | 
| 184 | 
            -
                              " | 
| 185 | 
            -
                              pr.labels.nil? ? "" :  | 
| 186 | 
            -
                               | 
| 177 | 
            +
                              "",
         | 
| 178 | 
            +
                              "",
         | 
| 179 | 
            +
                              pr.labels.nil? ? "" : pr.labels.find{|l| l.name.include?"size:"}.name, 
         | 
| 180 | 
            +
                              "",
         | 
| 187 181 | 
             
                              pr.state, 
         | 
| 188 182 | 
             
                              pr.merged ? "Y" : "N",
         | 
| 189 | 
            -
                              pr.labels.nil? ? "" :  | 
| 183 | 
            +
                              pr.labels.nil? ? "" : pr.labels.map{|l| l.name}.join(', ')
         | 
| 190 184 | 
             
                            ]
         | 
| 185 | 
            +
                          else 
         | 
| 186 | 
            +
                            relevant_time_entries.chunk{|i| i.user_id }.each do |user_id, user_time_entries|
         | 
| 187 | 
            +
                              user = harvest_users.find{|u| u.id == user_id}
         | 
| 188 | 
            +
                              csv << [
         | 
| 189 | 
            +
                                selected_repo.name, 
         | 
| 190 | 
            +
                                selected_milestone.title, 
         | 
| 191 | 
            +
                                pr.number, 
         | 
| 192 | 
            +
                                pr.title, 
         | 
| 193 | 
            +
                                projects.select{|p| user_time_entries.map(&:project_id).uniq.include? p.id}.map(&:name).join(', '),
         | 
| 194 | 
            +
                                "#{user.first_name} #{user.last_name}", # Who
         | 
| 195 | 
            +
                                pr.labels.nil? ? "" : issue.labels.find{|l| l.name.include?"size:"}.name, 
         | 
| 196 | 
            +
                                user_time_entries.inject(0){|sum, e| sum + e.hours },
         | 
| 197 | 
            +
                                pr.state, 
         | 
| 198 | 
            +
                                pr.merged ? "Y" : "N",
         | 
| 199 | 
            +
                                pr.labels.nil? ? "" : issue.labels.map{|l| l.name}.join(', ')
         | 
| 200 | 
            +
                              ]
         | 
| 201 | 
            +
                            end
         | 
| 191 202 | 
             
                          end
         | 
| 192 203 | 
             
                        end
         | 
| 193 204 | 
             
                      end
         | 
    
        data/lib/fire_watch/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fire_watch
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Joe Weakley
         | 
| @@ -111,6 +111,7 @@ files: | |
| 111 111 | 
             
            - bin/console
         | 
| 112 112 | 
             
            - bin/setup
         | 
| 113 113 | 
             
            - exe/fire_watch
         | 
| 114 | 
            +
            - fire_watch-0.1.0.gem
         | 
| 114 115 | 
             
            - fire_watch.gemspec
         | 
| 115 116 | 
             
            - lib/fire_watch.rb
         | 
| 116 117 | 
             
            - lib/fire_watch/runner.rb
         |