getPrimaryWord :: [Line] -> Int -> FilePath -> (Objective, Maybe Int, [Corner])
getPrimaryWord ls dpt path = case (extension path) of
   Nothing -> (NoObjective, Nothing, [])
   Just x
     | (x == "erb") || (x == "rhtml") -> (RegexpObjective fname_pattern $ "render.*" `mappend` basename_val, Nothing, [])
     | (x == "js")                    -> case primary_corner of
                                           Just x' -> (wordToObj $ getWord x', primary_lnum, all_corners)
                                           Nothing -> (NoObjective, primary_lnum, all_corners)
     | (x == "rb") || (x == "rake")   -> case primary_corner of
                                           Just (Corner (RbClass _) _) -> (NoObjective, primary_lnum, all_corners)
                                           Just (Corner (RbModule _) _) -> (NoObjective, primary_lnum, all_corners)
                                           Nothing -> (NoObjective, primary_lnum, all_corners)
                                           Just x' -> (wordToObj $ getWord x', primary_lnum, all_corners)
     | otherwise                      -> (NoObjective, Nothing, [])
   where
     (primary_corner, primary_lnum, all_corners) = getCorners ls dpt
     basename_val = dropFirstUnderScore $ toText' $ basename path
     fname_pattern = Just $ toText' $ dirname path
getPrimaryWord :: [Line] -> Int -> FilePath -> (Objective, Maybe Int, [Corner])
getPrimaryWord ls dpt path = case (extension path) of
   Nothing -> (NoObjective, Nothing, [])
   Just x
     | (x == "erb") || (x == "rhtml") -> (RegexpObjective fname_pattern $ "render.*" `mappend` basename_val, Nothing, [])
     | (x == "js")                    -> case primary_corner of
                                           Just x' -> (wordToObj $ getWord x', primary_lnum, all_corners)
                                           Nothing -> (NoObjective, primary_lnum, all_corners)
     | (x == "rb") || (x == "rake")   -> case primary_corner of
                                           Just (Corner (RbClass _) _) -> (NoObjective, primary_lnum, all_corners)
                                           Just (Corner (RbModule _) _) -> (NoObjective, primary_lnum, all_corners)
                                           Nothing -> (NoObjective, primary_lnum, all_corners)
                                           Just x' -> (wordToObj $ getWord x', primary_lnum, all_corners)
     | otherwise                      -> (NoObjective, Nothing, [])
   where
     (primary_corner, primary_lnum, all_corners) = getCorners ls dpt
     basename_val = dropFirstUnderScore $ toText' $ basename path
     fname_pattern = Just $ toText' $ dirname path
getPrimaryWord ls dpt path = case (extension path) of
   Nothing -> (NoObjective, Nothing, [])
   Just x
     | (x == "erb") || (x == "rhtml") -> (RegexpObjective fname_pattern $ "render.*" `mappend` basename_val, Nothing, [])
     | (x == "js")                    -> case primary_corner of
                                           Just x' -> (wordToObj $ getWord x', primary_lnum, all_corners)
                                           Nothing -> (NoObjective, primary_lnum, all_corners)
     | (x == "rb") || (x == "rake")   -> case primary_corner of
                                           Just (Corner (RbClass _) _) -> (NoObjective, primary_lnum, all_corners)
                                           Just (Corner (RbModule _) _) -> (NoObjective, primary_lnum, all_corners)
                                           Nothing -> (NoObjective, primary_lnum, all_corners)
                                           Just x' -> (wordToObj $ getWord x', primary_lnum, all_corners)
     | otherwise                      -> (NoObjective, Nothing, [])
   where
     (primary_corner, primary_lnum, all_corners) = getCorners ls dpt
     basename_val = dropFirstUnderScore $ toText' $ basename path
     fname_pattern = Just $ toText' $ dirname path